Posts

Showing posts from April, 2011

php - MySQL query on money format -

i got table prices has values similar following: price ----------- 21,781.00 27,615.00 46,565.00 46,565.00 48,565.00 571.00 830.00 0.00 by doing query: select * tprice order price=0, convert(price, decimal) asc i following result: 21,781.00 27,615.00 46,565.00 46,565.00 48,565.00 571.00 830.00 and, doing query: select * tprice order price=0, convert(price, decimal) desc i 830.00 571.00 48,565.00 46,565.00 46,565.00 27,615.00 21,781.00 0.00 why 830.00 , 571.00 not been ordered properly? edit: i've changed query to: select * tprice order price=0, replace(',','',price), price asc it seems working "a bit better". result: 830.00 571.00 48,565.00 46,565.00 46,565.00 27,615.00 21,781.00 0.00 still trying other variations... select price, convert(replace(replace(price, ",", ""), ".", ""),unsigned integer) formattedprice testtest order formattedprice; this should work. explana

c - Does inserting memory sync barrier after writing and before reading sharing variable also ensure the cache coherency -

if variable(not volatile) read/write accessed 2 threads without using locking , avoid locking , volatile using memory sync barriers before reading , after writing variable. i read memory sync barrier serializes read/write operations mean write/read reflected in parallel other threads. cause processor cache invalidated thread can latest value instead of value in cache ? the reason not using locks/volatile variable trying learn use memory sync barrier. may can me remove overhead of locks.

Java fallback pattern -

i'm trying find nice way of implementing service relies on third-party library class. have 'default' implementation use fallback in case library unavailable or can not provide answer. public interface service { public object compute1(); public object compute2(); } public class defaultservice implements service { @override public object compute1() { // ... } @override public object compute2() { // ... } } the actual implementation of service like: public class serviceimpl implements service { service defaultservice = new defaultservice(); thirdpartyservice thirdpartyservice = new thirdpartyservice(); @override public object compute1() { try { object obj = thirdpartyservice.customcompute1(); return obj != null ? obj : defaultservice.compute1(); } catch (exception e) { return defaultservice.compute1(); } } @override pu

html - Left & Right Background CSS in div changes body content container width -

i put display background on left , right side of website. now in place body container appearing wider before. why be? can see isn't code in below? div#multi-background { width: 100%; height: 100%; background-image: url(http://cdn.shopify.com/s/files/1/0834/6311/t/2/assets/right-1.png), url(http://cdn.shopify.com/s/files/1/0834/6311/t/2/assets/left-1.png); background-position: center right, top left; background-repeat: no-repeat; } @media screen , (min-width: 481px) { //happens when screen size >= 481px div#multi-background { width: 100%; height: 100%; background-image: url(http://cdn.shopify.com/s/files/1/0834/6311/t/2/assets/right-1.png), url(http://cdn.shopify.com/s/files/1/0834/6311/t/2/assets/left-1.png); background-position: center right, top left; background-repeat: no-repeat; } } @media screen , (max-width: 481px) { //happens when screen size &l

Running shell script with java on linux -

i moving runescape private server windows linux. server has run.bat start up. @echo off title project kingscape java -cp bin;deps/poi.jar;deps/mysql.jar;deps/mina.jar;deps/slf4j.jar;deps/slf4j-nop.jar;deps/jython.jar;log4j-1.2.15.jar;-server -xx:+aggressiveheap -xx:maxheapfreeratio=90 -xx:minheapfreeratio=90 -xx:+disableexplicitgc -xx:+relaxaccesscontrolcheck -xx:+useparallelgc -xx:compilethreshold=1 -xx:threadstacksize=128 server.server pause i converted following .sh script: #!/bin/bash java -classpath bin:deps/poi.jar:deps/mysql.jar:deps/mina.jar:deps/slf4j.jar:deps/slf4j-nop.jar:deps/jython.jar:log4j-1.2.15.jar:server.server read i have openjdk 7 installed. when try run run.sh file terminal shows me following: usage: java [-options] class [args...] (to execute class) or java [-options] -jar jarfile [args...] (to execute jar file) options include: -d32 use 32-bit data model if available -d64 use 64-bit data model if

javascript - Setting zoom level doesn't work on Google Map -

i'm learning web developing , i'm using javascript show google map. here code: <!doctype html> <html> <head> <title>google map</title> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function loaddata(callback) { var xobj = new xmlhttprequest(); xobj.overridemimetype("application/json"); xobj.onreadystatechange = function () { if (xobj.readystate == 4 && xobj.status == "200") callback(xobj.responsetext); } xobj.open("get", "data.json", true); xobj.send(null); } window.onload = function () { loaddata(function(response) { markers = json.parse(response); var mapoptions = {

python - Numpy, grouping every N continuous element? -

i extract groups of every n continuous elements array. numpy array this: a = numpy.array([1,2,3,4,5,6,7,8]) i wish have (n=5): array([[1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7], [4,5,6,7,8]]) so can run further functions such average , sum. how produce such array? you use rolling_window blog def rolling_window(a, window): shape = a.shape[:-1] + (a.shape[-1] - window + 1, window) strides = a.strides + (a.strides[-1],) return np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides) in [37]: = np.array([1,2,3,4,5,6,7,8]) in [38]: rolling_window(a, 5) out[38]: array([[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) i liked @divkar's solution. however, larger arrays , windows, may want use rolling_window ? in [55]: = np.arange(1000) in [56]: %timeit rolling_window(a, 5) 100000 loops, best of 3: 9.02 µs per loop in [57]: %timeit broadcast_f(a, 5) 10000 loops, best of 3: 87.7 µs

html - Changing the fontsize with javascript -

the code below adds <font size="x">$text</font> wysiwyg editor's textarea: /** * set size context */ this.set_size_context = function(sizestate) { if (this.buttons['fontsize']) { if (typeof sizestate == 'undefined') { sizestate = this.editdoc.querycommandvalue('fontsize'); } switch (sizestate) { case null: case '': { if (is_moz) { sizestate = this.translate_fontsize(this.editdoc.body.style.fontsize); } } break; } if (sizestate != this.sizestate) { this.sizestate = sizestate; var i; if (this.popupmode) { (i in this.sizeoptions) { if (yahoo.lang.hasownproperty(this.sizeoptions, i)) {

'TRIM' or 'PROPER' in BigQuery -

is there way normalize strings in bigquery? my dataset looks like: alfa beta alfa beta alfa beta //with space after 'beta' by can use lower or upper normalize letters don't know how eliminate spaces before , after text. bigquery have function ' trim ' in excel? bigquery have ltrim (trims spaces left) , rtrim (trims spaces right) functions. (strings functions documentation @ https://cloud.google.com/bigquery/query-reference#stringfunctions missed them, fix shortly).

php - how to select latest record from table by using Group by statements -

i fetch chat messages table , group according sender id messages table msg_id msg(messages) sender(user id) receiver (user id) time (timestamp) ------------------------------------------------------------------------------ 1 hello bro 1 2 12am 2 hello 2 1 12am 3 disscuss 1 2 12:01am 4 free 1 2 12:03am ----------------------------------------------------- **user table** ----------------------------------------------------- u_id user_name 1 khalid 2 brain 3 abdullah then when make query select sender.user_name sender, receiver.user_name receiver, messages.time msgtime, messages.msg msg,sender.u_id u_id, sender.user_name user_name messages left join user sender on messages.sender = sender.u_id

python - Updating multiple objects without creating separate variables for them -

in game, "enemies" created objects class level loads. when screen refreshes, each need update x , y positions. since there multiple enemies, need create long piece of code telling every enemy object update. for example: enemy1 = enemy() enemy2 = enemy() enemy3 = enemy() ... enemy1.update() enemy2.update() enemy3.update() ... i need way create these objects when needed without needing create variable every single one, , function make objects in enemy class update when screen refreshes. you can that: class enemy(object): def __init__(self): pass def update(self): pass # call function during updates. enemies = [] iter in range(10): enemies.append(enemy()) # creating 10 enemies , appending list enemy in enemies: enemy.update() #updating every enemy in list answer easy. during creating enemy append list. later, if need calculate x/y position iterate on list. remember remove or del enemy list if don't need anymore.

Using multiple filter functions in google sheets elastically -

in google spreadsheet, have summary sheet importing information multiple sheets. 1 of filter function looks following: =filter(sheet2!a14:a27, (sheet2!k14:k27="y") + (sheet2!k14:k27="r")) i have multiple filter functions one. problem facing have assign static number of rows result of function result dynamic (could 1 row or 15 rows). i have been searching exhaustively couldnt find way elastically results of filter functions appended (with perhaps empty row/header row between each of results). one solution gave on 1 of forums assign static number of rows each , hide empty rows using script did not seem clean solution (but may have fallback on that) also, thought of using scripts if understand correctly, scripts can 'triggered' menus, onopen, onedit etc. may not intuitive (one has reload spreadsheet see change in case of onopen(), etc.) using custom functions again cause same problem because custom functions run on specific cell (and dont know c

java - How to Move JLabes Around -

Image
import java.awt.flowlayout; import javax.swing.jframe; import javax.swing.jlabel; public class gui_window extends jframe { private jlabel main_l; public gui_window() { setlayout(new flowlayout()); main_l = new jlabel("did know possible bind keys?"); add(main_l); } public static void main (string args[]) { gui_window gui = new gui_window(); gui.setdefaultcloseoperation(jframe.exit_on_close); gui.setsize(300,300); gui.setvisible(true); gui.settitle("gamers audiomute"); gui.setresizable(true); } } i know how move "did know" label around. state how align left, right, middle , how move around coordinates? you can use methods included in swing classes. try mainl.sethorizontalalignment(swingcon

java - How to determine if one number is within a certain range of another -

i determine if 1 number within range of number. for instance, if have number 50 , , input number i , able determine if i within 10 digits of 50 . in other words, i in range of 40 49 or 51 60. how go doing that? you can take absolute value of difference , check whether less 10, or can skip absolute value part , test whether difference between -10 , 10 (and not zero, if want exclude equality).

java - How do I pass variables into a new android activity, with the ability to use them throughout the class? -

i'm trying pass variable activity, getting null object reference. my intent declaration makes use of putextra() public void launch_test(view view) { playsound.start(); intent launch_test = new intent(this, test.class); launch_test.putextra("num_rows", 4); launch_test.putextra("num_cols", 4); startactivity(launch_test); } and activity class (test) calls extras, public class test extends activity { intent launch_test = getintent(); bundle extras = launch_test.getextras(); int num_rows = launch_test.getintextra("num_rows", 0); int num_cols = launch_test.getintextra("num_cols", 0); button buttons[][] = new button[num_rows][num_cols]; etc... but i'm getting null object reference when try run in emulator. i assume use if statement check nulls, android studio isn't letting me use if statement in area of code. if place if statement oncreate function, won't able use variables throughout class,

ios - Receive voip push notification after reboot -

after implementing voip push notification pushkit, following handler can called when send notification device. - (void)pushregistry:(pkpushregistry *)registry didreceiveincomingpushwithpayload:(pkpushpayload *)payload fortype:(nsstring *)type it works when app in background or killed user. however, doesn't work after rebooting ios. my question pushkit work after rebooting?

Java run time error.missing static main method -

https://github.com/joywang1994/question2/blob/master/test2.java this code. has run time error says don't have static main method why? how fix it? thank help! i guess running wrong class file start program. create 3 class file name huffmantree,huffmannode , huffmancode. copying github. ran huffmancode class file. program compile , runs out error. dont have c:\eclipse\programmes\datastructure\infix.dat file got file not found exception. ignoring main method called without trouble.

osx - How do I change my python idle and general version from 3.4.3 to 2.7.9 -

i have been searching answers , have not found any.i wondering how change default idle 2.7.9. downloaded 3.4.3 first , don't know how change 2.7.9. want change can run pygame. on console, write idle press tab: $ idle tab idle idle-python2.7 it spit out python idle versions on path: maybe idle-python2.7 want? you can directly write idle-python2.7 , press enter : if there python idle version, start.

jquery - Trigger an event if there are validation errors? -

i need add handle circumstance form validation fails. i've read this , explains have add handler follows: $('form').bind('invalid-form.validate', function () { console.log('form invalid!'); }); but event fires when try submit form. i need handle event that's fired time form post-validated (i.e. element loses focus etc.). what i'm trying achieve is, have large form (~50 fields), , it's splitted in bootstrap tabs . want, when there new validation failure or success, set or clear error class in tab title of tab contains invalid/valid elements. p.s. question not on how set classes in tabs. want know event(s) handle in order notified upon each validation state change in entire form. i need add handler circumstance form validation fails. $('input, textarea, select').on('focusout keyup', function() { if ($('form').valid()) { // } }); i want, when there validation error, set err

python - Django Form Clean Method Test Error -

i'm testing form wrote earlier. reason, test won't pass. it's form ignoring data pass it, , don't see why. traceback tells me user variable in clean method of form none, though user passed form. traceback: ... in clean if user.pk not userwebsite.user.pk: attributeerror: 'nonetype' object has no attribute 'pk' the form: class createauditform(forms.form): user = forms.modelchoicefield(queryset=user.objects.all(), widget=hiddeninput) website = forms.modelchoicefield(queryset=userwebsite.objects.all(), widget=hiddeninput) emails = forms.charfield( max_length=250, required=false ) def clean_user(self): user = self.cleaned_data.get('user', none) if not user.groups.filter(name__iexact='subscribed').exists() , not user.groups.filter(name__iexact='addon').exists(): raise forms.validationerror(_("you must have active subscription request \ website audi

Reliability of having arithmetic shift in c++ when targeting x86 -

so according c++ spec the value of e1 >> e2 e1 right-shifted e2 bit positions. if e1 has unsigned type or if e1 has signed type , non-negative value, value of result integral part of quotient of e1/2^e2. if e1 has signed type , negative value, resulting value implementation-defined. so it's implementation defined, if i'm using bug-free compiler targetting x86 platform, , im right shifting using signed type, there reason doubt not shift in signed bits? (x86 supports arithmetic shift obviously) do not confuse "implementation defined" "undefined". "implementation defined" means, literally, "the implementation must define it". it's not random, or should have determine experiment. behavior defined implementation, , standard-conforming implementations document these behavior details (because fail non-conformant in itself). barring implementation bugs, programs faithfully exhibit behavior defined c++ im

api - Finishing YoutubeStandAlonePlayer after completing video in Android? -

how detect when youtube video ends in youtubestandaloneplayer using google api youtube player, have finish player , write instructions after once video completes? intent intent = youtubestandaloneplayer.createvideointent( mactivity , developer_key, video_id, starttimemillis, autoplay, lightboxmode); startactivity(intent); this not possible because youtubestandaloneplayer activity related youtube app app doesn't have control on other apps activity. as said in documentation of youtube player api, the second option use youtubestandaloneplayer start video playback in separate activity. simpler use, gives less flexibility , control on video playback. standaloneplayer supports 2 modes, either fullscreen or lightbox. in lightbox mode, activity launching player still visible behind player, dimmed. link:- docs

android - Alertdialog automatically do action after timer -

i trying create alertdialog gives user yes or no choice if neither button pressed in timeframe deafult action occurs. wondering if possible sure, possible, recommend display timer not let user poker face when dialog gets closed no interaction. here steps follow: to create dialog use dialogfragment this tutorial create one. to start timer , callback calls when time ticking, use countdowntimer , in doc have example. finally when time finished make call dialogfragment#dismiss() close dialog no user interaction. remember cancel timer if user interacts dialog, avoid leaking resources.

python - PyopenGL glReadPixels -

i tried use glreadpixels method color code simple triangle in screen, without secondary render functions, etc. didn't give result. code: import pygame pg opengl.gl import * pg.display.set_mode((500,500),pg.opengl) glclearcolor(0.5,0.0,0.5,0.0) done=0 def first(): glcolor3f(0.5,0.6,0.7) glbegin(gl_triangles) glvertex(0.0,0.0,0.0) glvertex(1.0,0.0,0.0) glvertex(0.0,1.0,0.0) glend() cl=0 clock=pg.time.clock() while not done: event in pg.event.get(): if event.type==pg.quit: done=1 elif event.type==pg.mousebuttondown: pos=pg.mouse.get_pos() color=glreadpixels(pos[0],pos[1],1,1,gl_rgb,gl_float) print color, pos[0], pos[1]) glclear(gl_color_buffer_bit) first() pg.display.flip() clock.tick(20) pg.quit() but gives same color output: [[[ 0.50196081 0. 0.50196081]]] 288 217 how can fix it? your main problem glreadpixels accepts bottom-left origin , pygame gives top

node.js - Jade block not rendering -

i'm sure i'm missing small thing. i'm playing around jade templates in express. i'm trying experiment blocks , extensions. reason block isn't working. here jade templates: layout.jade doctype html html head title= title link(rel='stylesheet', href='/stylesheets/bootstrap.min.css') link(rel='stylesheet', href='/stylesheets/style.css') script(src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js') script(src='/javascripts/bootstrap.min.js') body block content index.jade extends layout block content header section h1 hello p. first jade template how incredibly exciting! main div(class="row") div(class="col-md-6") block colone div(class="col-md-6") block coltwo colone.jade extends ind

python - I have python3.4 but no pip or ensurepip.. is something wrong with my python3.4 version? -

i've read in multiple places python3.4 ships pip. os lubuntu 14.04 , default python version python 2.7.6 in /usr/bin it says have python3.4 installed (when run python3 -v says have python 3.4.0). made post earlier last week: how use pip 3 python 3.4? one of comments reply said "it may worth mentioning python3.4 should ship pip default. python3 -m pip should work out of box. if not, there's python -m ensurepip bootstrap pip. get-pip.py should not necessary here." i can confirm not have pip because did pip -v and said pip not installed. tried running python3 -m pip and said /usr/bin/python3: no module named pip i tried python -m ensurepip python3 -m ensurepip and said /usr/bin/python: no module named ensurepip /usr/bin/python3: no module named ensurepip with said, there wrong version of python3 because not have pip or ensurepip? i'm asking because i've read in multiple places (for example, in previous question) python3.4 comes pip

Gerrit event on Jenkins doesn't trigger automatically on git push -

Image
i'm new jenkins/gerrit. i'm trying integrate gerrit jenkins. i've jenkins project setup triggered when there changeset created (push) in git repository, hosted gerrit project. master branch doesn't accept direct push. use following command push repository. git push origin head:refs/for/master now, when push, jenkins project doesn't kick off automatically. can manually trigger gerrit event with, "query , trigger gerrit patches". below gerrit server , trigger plugin version. gerrit server version: 2.10.3.1 gerrit trigger plugin: 2.12.0 i pretty followed gerrit trigger plugin guideline. jenkins project setup in screenshot (1-3). and gerrit project access permission, project inherits all-projects. here screenshot (4). this seems solved now. key following. gerrit project -branches -type: path -pattern: "" i using type "plain" , pattern "master". didn't work.

Javascript. Replace HTML content of a Div -

Image
so building website when click on small image displays bigger above. along image being enlarged text overlays image describing , can't seem code change text right. text more complicated uses spans etc have place html code , displays text without formatting. // image 1 - football function change1() { document .getelementbyid("mainpic") .src = "http://files.stv.tv/imagebase/170/623x349/170248-lossiemouth-fc.jpg" ; document .getelementbyid("imagecaption") .innerhtml = "<span>lossiemouth football club<span class='spacer'></span><br /><span class='spacer'></span>come watch game of football!</span>" ; } // image 2 - football function change2() { document .getelementbyid("mainpic") .src = "http://www.visitscotland.com/wsimgs/course%206_704927777.jpg[productmain]" ; do

android - OnCreate not called on Activity -

i've created abstractactivity , abstractformactivity rid of boilerplate code, content may irrelevant question, post anyway, maybe misunterstood so, there are: public abstract class abstractactivity extends actionbaractivity { protected objectgraph graph; @inject public bus bus; @inject public app app; @override public void oncreate(bundle savedinstancestate, persistablebundle persistentstate) { super.oncreate(savedinstancestate, persistentstate); setcontentview(getlayout()); setupinjection(); } public void setupinjection() { graph = ((app) getapplication()).createscopedgraph(getmodule()); graph.inject(this); bus.register(this); butterknife.inject(this); } protected abstract object getmodule(); protected abstract int getlayout(); } and public abstract class abstractformactivity<t extends entidadebase> extends abstractactivity implements form<t> {

php - SQL injection - update two tables at once in a non-stacked mysql_query -

i'm learning advanced sql injection techniques, find harder. i've got php code this(i can't change this, it's php + mysql 5.6.19[innodb] ): $newvalue = $_post['newvalue']; if ($newvalue > 1000) mysql_query("update `table` set `column1`='".$newvalue."' `id`='".$id."'"); i've worked out way fool php little bit passing valid number @ beginning in post parameter, this(this 1 changes other column value, that's nice, works ): 1001', `column2` = 'some_value' `id` = 'some_other_value';# now i'd change(update) other table in same update query. remember! can't change code , mysql_query doesn't allow stacked queries(you can't perform multiple queries separating them semicolon). in theory, might this(of course, doesn't work): 1001' `id` = 'some_other_value' or (update `table2` set ... = ... limit 1);# or(some theoretical trick): 1001'*(u

swift - Cannot subscript a value of type 'Double' with an index of type 'Double' -

have subscript error here i'm not sure why. time made sure types matched i'm getting error because match. cannot subscript value of type '[double]' index of type 'double' let maxperiod:double = 1.5 let minperiod:double = 0.1 let invalidentry:float = -100 let maxperiodstostore:double = 20 let averagesize:int = 20 class detector { let session = avcapturesession() var camera : avcapturedevice? var upvals: [float] = [] var downvals: [float] = [] var upvalindex: int? var downvalindex: int? var lastval: float? var periodstart: float? var periods: [double] = [] var periodtimes: [double] = [] var periodindex: int? var started: bool? var freq: float? var average: float? var wasdown: bool? func reset() { var i:double = 0; < maxperiodstostore; i++ { periods[i] = invalidentry // error: cannot subscript value of type '[double]' index of type 'double

functional programming - How do I get keepWhen behaviour in Elm 0.15? -

Image
the keepwhen function earlier versions of elm removed. have ported elm application 0.14, i'm stuck @ trying 1 part of work, it's using keepwhen . so i'm looking function like keepwhen : signal bool -> -> signal -> signal i have found filter : (a -> bool) -> -> signal -> signal but it's not quite same thing, , haven't figured out how work. answer: import utility package the easiest way use signal.extra.keepwhen signal-extra package. (full disclosure: i'm author) important implementation detail notice implementation isn't trivial. implementation in package (the signal module imported unqualified): keepwhen : signal bool -> -> signal -> signal keepwhen boolsig asig = zip boolsig asig |> sampleon asig |> keepif fst (true, a) |> map snd the important difference version in kqr's answer sampleon keeps output of keepwhen updating when boolean input changes. difference between

Bootstrap Carousel Slider Doesn't Transition How I Want In Mobile View -

i've added carousel slider website http://www.joekonst.com . it looks fine apart when view on iphone. when slide transitions on kind of flashes white on left hand side when slides change. the funny thing when view browser size smallest size possible looks fine, when view on mobile device looks wrong! any ideas? thanks joe :) <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>tech enthusiast!</title> <link href="joekonst/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="joekonst/mystyles/css/mystyles.css" rel="stylesheet" media="screen"> <link rel="stylesheet" href="joekonst/mystyles/css/

postgresql - Postgres row_to_json produces invalid JSON with double escaped quotes -

postgres escapes quotes incorrectly when creating json export. note double quotes in below update... update models set column='"hello"' id=1; copy (select row_to_json(models) (select column shaders id=1) shaders) '/output.json'; the contents of output.json: {"column":"\\"hello\\""} you can see quotes escaped improperly , creates invalid json. should be: {"column":"\"hello\""} how can fix postgres bug or work around it? this not json related. it's way text format (default) in copy command handles backslashes. the postgresql documentation - copy : backslash characters ( \ ) can used in copy data quote data characters might otherwise taken row or column delimiters. in particular, following characters must preceded backslash if appear part of column value: backslash itself , newline, carriage return, , current delimiter character. (emphasis mine.) can solve

html - Javascript checking @ in email -

i trying check html input form see if contains @ symbol. html: <input id="emailcheck" type="text" name="uid" /> <input type="button" value="continue" onclick="continueplease()" /> <br> <p id="invalidemail"></p> javascript: var @ = document.getelementbyid("emailcheck").value.indexof("@"); function continueplease() { if (at == -1) { document.getelementbyid("invalidemail").innerhtml = "<font color=red>please enter valid email.</font>"; } else { changedata(); } } function changedata() { document.getelementbyid("title").innerhtml = "<font color=#33ff00> information confirmed </font>"; document.getelementbyid("lock").innerhtml = "<font color=red>this account locked.</font>"; document.getelementbyid("time").in

How to add elements to a C# list from MATLAB? -

i have created list 5 int32 integers in matlab: gentype = net.genericclass('system.collections.generic.list',... 'system.int32'); arr = net.createarray(gentype, 5) now don't know how add elements list. i tried , failed using: arr.setvalue(1) arr.setvalue(1,1) arr.setvalue(1,1,1,1) arr(1)=1 ...etc. try out following code, should started: list = net.creategeneric('system.collections.generic.list',... {'system.int32'},100); list.add(5) list.add(6) = 0:list.count - 1 disp(list.item(i)) end

perl: finding the region with the greatest width from a list -

i have table having following structure gene transcript exon length nm_1 1 10 nm_1 2 5 nm_1 3 20 nm_2 1 10 nm_2 2 5 nm_2 3 50 b nm_5 1 10 ... ... ... ... so basically, table consists of column human genes. second column contains transcript name. same gene can have multiple transcripts. third column contains exon number. every gene consists of multiple exons. fourth column contains length of each exon. now want create new table looking this: gene transcript length nm_2 65 b nm_5 10 ... ... ... so want find longest transcript each gene. means when there multiple transcripts (column transcript) each gene (column gene), need make sum of values in length column exons of transcript of gene. so in example there 2 transcripts gene a: nm_1 , nm_2. each has 3

java - Looking for advice on project. Parsing logical expression -

Image
i'm looking advice on school project. supposed create program takes logical expression , outputs truth table it. creating of truth table me not difficult @ , i've wrote methods in java it. know if there classes in java use parse expression me , put stack. if not i'm looking on parsing expression. it's parentheses me whenever try , think through. if easier in other language open doing in that. perl next best language. some examples (p && q) -> r (p || q || r) && ((p -> r) -> q) if you're allowed use parser generator tool antlr, here's how started. grammar simple logic-language this: grammar logic; parse : expression eof ; expression : implication ; implication : or ('->' or)* ; or : , ('||' and)* ; , : not ('&&' not)* ; not : '~' atom | atom ; atom : id | '(' expression ')' ; id : ('a'..'z' | &#

C++ program to calculate the sum of all five-digit odd numbers? -

i'm having problem following simple code, don't know why output become negative... program supposed calculate sum of odd , five-digit numbers 10001, 10003, 10005, etc. #include <iostream> using namespace std; int main() { int num, sum = 0; (num = 10001 ; num <= 99999 ; num+=2){ sum += num; } cout << num << " " << sum; return 0; } it means there overflow of type int. type can not represent sum. advice declare variable sum like long long int sum = 0; after can compare result maximum value stored in type int. example #include <limits> //... std::cout << std::numeric_limits<int>::max() << " " << sum << std::endl;;

c - With arrays, why is it the case that a[5] == 5[a]? -

as joel points out in stack overflow podcast #34 , in c programming language (aka: k & r), there mention of property of arrays in c: a[5] == 5[a] joel says it's because of pointer arithmetic still don't understand. why a[5] == 5[a] ? the c standard defines [] operator follows: a[b] == *(a + b) therefore a[5] evaluate to: *(a + 5) and 5[a] evaluate to: *(5 + a) a pointer first element of array. a[5] value that's 5 elements further a , same *(a + 5) , , elementary school math know equal (addition commutative ).

java - back button- Confirm form resubmission using jsp, servlet and filter -

this question has answer here: prevent user seeing visited secured page after logout 5 answers i followed examples saw here write code confirm form resubmission when press browser button after logout. using 2 jsp pages, index page contains login form , welcome page displays after suuccessful login. login servlet processes login data , sets session atribute , logout servlet removes session atribute , invalidate session. a filter checks session attribute , sets no-cache...on browser. other aspect works fine when press button after logout,it displays "confirm form resubmission". please think not getting right. need help. thank you. are doing logout post method? if yes, logout browser sending data server, when press button brower assumes trying reload, , ask confirm form submit. wont problem until unless, user logout other wise have check filter

access vba - Linking 2 combo boxes -

i know best way create combo box linked selection of combo box. example, in combo box number 1 selects 'fruits', options in combo box number 2 mango, orange , kiwi.. when user selects in combo box number 1 'vegetables', in combo box number 2 options carrot, artichoke, , tomato. both combo boxes should linked same table called produce. i don't have trouble building query support combo box number one, don't understand how can link selected query supporting combo box number 2. there several ways how this, easiest 1 , 1 use setting different row source combobox2 when change event (or afterupdate , depending on needs) of combobox1 fired. example: i have 2 tables animals 1 dog 2 cat 3 mouse 4 rabbit cars 1 audi 2 bmw 3 ferrari 4 porsche 5 mclaren on form have 2 comboboxes, second 1 based on selection of first one, contains 2 options: animals, cars. sample code: private sub combo1_change() dim cmb1 combobox: set cmb1 = me.comb

html - Safari is not showing a webpage -

the webpage not showing in safari, other browsers rendering --> firefox, chrome (i not counting ie, need not check in ie). want reason why webpage not being shown in safari. may possible reason? <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>one-great-thing</title> <style> body { margin: 0; padding: 0; font-size: 62.5%; } #image-slider { position: relative; } #image-slider > div { overflow: hidden; } #container { position: relative; overflow: hidden; } #container .content{ position: absolute; top: 10%; left: 0; color: #000; text-align: center; width: 100%; font-size: 6em; padding: 80px 0px; font-weight: bold; back

c - OpenGL lighting vector normalization -

Image
i attempting find vector normalization arbitrary object loaded opengl program. trying calculate normals vertices. have gathered need first calculate normals faces, find average of normals vertices. when run program of object lit correctly, part not. triangles on each independent face seems lit correctly, not adjacent face. calculate normal of each vertex assume have find normalized average of 6 connecting triangles, attempting did not seem work. here code using trying calculate normals of each face. vec3 one, two; for(int = 0; < vertices.vertexnumber; += 3) { one.x = point3[i+1].x - point3[i].x; one.y = point3[i+1].y - point3[i].y; one.z = point3[i+1].z - point3[i].z; two.x = point3[i+2].x - point3[i].x; two.y = point3[i+2].y - point3[i].y; two.z = point3[i+2].z - point3[i].z; vec3 normal = normalizevec3(crossvec3(one, two)); normalized[i] = normal; } and function using normalize vectors vec3 normalizevec3(vec3 v) { float veclength =

Clear all cells from specified cell in Excel using VBA -

good evening, have worksheet procedure: public sub cleaning(list string) worksheets(list).range("d5:xfd1048576").clear end sub it works , clear in range d5:xfd1048576 , quiet unsure if solution problem. want procedure clear on right of d5 , down d5 cell. can please me this? your procedure not solve problem descriebed. this, need clear columns on right side of column d (that means starting e), , clear rows below 5 (that means starting row 6). here piece of code should work: public sub extracleaning(list string) worksheets(list).columns("e:xfd").clear worksheets(list).rows("6:1048576").clear end sub

c++ - Cannot connect slots from another class -

i try write little application experiments , more. write in own file (menu -> menu.cpp etc.). want create menu action, works interacting action doesnt. thats i've done far: menu.cpp #include "menu.h" #include <qmenubar> #include <qmenu> #include <qaction> void menu::setupmenu(qmainwindow *window) { qmenubar *mb = new qmenubar(); qmenu *filemenu = new qmenu("file"); qaction *newact = new qaction("new...", window); window->connect(newact, signal(triggered()), this, slot(newfile())); filemenu->addaction(newact); mb->addmenu(filemenu); window->setmenubar(mb); } void menu::newfile() { printf("hello world!"); } menu.h #ifndef menu_h #define menu_h #include <qobject> #include <qmainwindow> #include <qwidget> #include <qmenubar> class menu : public qobject { public: void setupmenu(qmainwindow *window); private slots: void newfile(); }; #

PHP Pass by reference in foreach -

this question has answer here: strange behavior of foreach 2 answers i have code: $a = array ('zero','one','two', 'three'); foreach ($a &$v) { } foreach ($a $v) { echo $v.php_eol; } can explain why output is: 0 1 2 two . from zend certification study guide. because on second loop, $v still reference last array item, it's overwritten each time. you can see that: $a = array ('zero','one','two', 'three'); foreach ($a &$v) { } foreach ($a $v) { echo $v.'-'.$a[3].php_eol; } as can see, last array item takes current loop value: 'zero', 'one', 'two', , it's 'two'... : )

html - Showing the desktop version of a fully responsive website on tablets -

how 1 go creating responsive site (ie. 'fluid') doesn't end displaying narrow "mobile" version on tablet? (usually mobile version of website designed thumbs in mind. it's basic, single column, , isn't suited larger mobile devices tablets.) even if you've designed scale gracefully every width, still need viewport setting tell user's phone display content @ right width... setting appears honoured tablets, too. i realise can use detection solution (like mobile detect ) it's not fluid (although suppose use mobile detect insert viewport meta tag if mobile phone detected). there better way tablets display desktop version? i feel i'm missing obvious trick! how should work when adopted css standards: use @media queries in css, along @viewport css tag, instead of meta viewport tag. there's explanation of how here: http://www.html5hacks.com/blog/2012/11/28/elegantly-resize-your-page-with-the-at-viewport-css-declaration/