Posts

Showing posts from January, 2012

java - LinearLayout cannot be cast to a class I've created -

java - LinearLayout cannot be cast to a class I've created - my exception: caused by: java.lang.classcastexception: android.widget.linearlayout cannot cast dismo.ufrj.br.bradmobile.headerclass i've created class, headerclass, extends linearlayout. cant seem cast right way.(header linearlayout) here's code headerclass = (headerclass) findviewbyid(r.id.header); the problem stated in error message: layout contains linearlayout , , effort cast own class. can't that. instead, need alter xml read: <dismo.ufrj.br.bradmobile.headerclass .... .... .... > .... </dismo.ufrj.br.bradmobile.headerclass> inheritance doesn't matter much here, since headerclass extends linearlayout , cast above xml linearlayout in code. java android android-layout android-linearlayout

c - File locking between threads and processes -

c - File locking between threads and processes - i have programme spawns multiple processes or threads, each of writes line on file, don't want line mixed up, need exclusive access file. more specifically, in first case, have process f spawns several kid processes (c1, c2, c3, c4, ...), , want block access f, c2, c3, c4, ... when c1 writing. in sec case, have same process f spawns several threads (t1, t2, t3, t4, ...) and, again, want block access f, t2, t3, t4, ... when t1 writing. i'm guessing function flock() takes care of first part, threads case? , windows platform? you can utilize locking mechanism want. between threads, mutex simplest. access file protected mutex, no 2 threads seek write file @ same time. for processes, can utilize process-shared mutex. on windows, can utilize named mutex. c windows multithreading unix locking

javascript - Add class with a particular div -

javascript - Add class with a particular div - i have div <div class="newdiv"> it generating in loop, like <div class="newdiv"> <div class = "innerdiv"> somecode </div> </div> <div class="newdiv"> <div class = "innerdiv"> somecode </div> </div> <div class="newdiv"> <div class = "innerdiv"> somecode </div> </div> now want add together class "brightdiv" div generated @ odd places like with first , 3rd div. what should add together class "brightdiv" along "newdiv" every div @ odd place? try : can utilize :odd or :even select odd / elements, depend on index position , not natural number count. in case, want first , 3rd position div i.e. index= 0 , 2 index position , hence utilize :even . $('div.newdiv:even').addclass(...

timeout - How do I have 'brew install most' use a different ftp address since the current one times out? -

timeout - How do I have 'brew install most' use a different ftp address since the current one times out? - i'd install most brew . i've tried recently, ftp address timing out, , i'm not sure how tell brew utilize different location retrieve source. how can tell brew utilize different url when attempts download most-5.0.0a.tar.bz2 lib? if type in brew edit most , it'll open text editor url. editing , saving file results in brew installing new url. as can see in example, url download location changed accordingly: # changed url ftp:// notrealftp://..... $ brew edit $ brew install ==> installing ==> downloading notrealftp://space.mit.edu/pub/davis/most/most-5.0.0a.tar.bz2 curl: (1) protocol notrealftp not supported or disabled in libcurl error: failed download resource "most" download failed: notrealftp://space.mit.edu/pub/davis/most/most-5.0.0a.tar.bz2 timeout homebrew

C program to split char using strtok and strchr -

C program to split char using strtok and strchr - i have next c programme split char* its user entred value in format "111/222". (code produce right output) in cases , value entered "/222". char* ptr ="/222" ; char* val1 , *val2; val1 = strchr( ptr, '/'); if ( val1 != null) val1++; val2 = strtok(ptr,"/"); myoutput : val1 = 222 val2 = 222 i dont know how get val1 = "" (as empty char) val2 = 222 thanks in advance ur help! the easiest way check if string start / or not. if then, set val1 "" , val2 have point (ptr + 1). else currently c

build - Custom Makefile With Eclipse CDT -

build - Custom Makefile With Eclipse CDT - i have c++ project 3 .hpp files , 1 .cpp file, , custom makefile. code , makefile project existed, right clicked in project explorer, , did import->existing code makefile project named project , pointed location root dir of project contains of files. , selected mingw gcc toolchain because compiler have. went project->properties->c/c++ build , unchecked generate makefiles automatically then changed build directory choosing file system , navigating root directory of project contains of files. build directory c:\users\ryan\desktop\school\cse\cse 100\pa1-rbridges then changed build command make -f c:\users\ryan\desktop\school\cse\cse 100\pa1-rbridges\makefile bst bst target in makefile , makefile @ location. when click hammer on toolbar build project, nil happens. when seek run project, launch failed: binary not found. i want project utilize makefile , build properly. have searched google , stack overflow hours trying figur...

javascript - how to pass an array elements to log set of parameters in one line -

javascript - how to pass an array elements to log set of parameters in one line - once upon time advertisement assignment task on 1 of interviews hasn't been giving me sleep since: need log arguments -object in console in 1 line date in end. objects(to able inspect those), not string( array prototype.join() - not solution in case) a fail attempt(out of function scope): var fn = function () { var arr = array.prototype.slice.call(arguments); arr.push(new date().tojson()); function.prototype.call.apply( console.log, arr ); } fn( 1, 'a', [2, 3], {a:1} ); logs: uncaught typeerror: illegal invocation any ideas? use logging function.prototype.call.apply( console.log.bind(console), arr ); instead of function.prototype.call.apply( console.log, arr ); it work. javascript arguments prototype

python - Sieve of Eratosthenes - Primes between X and N -

python - Sieve of Eratosthenes - Primes between X and N - i found highly optimised implementation of sieve of eratosthenes python on code review. have rough thought of it's doing must admit details of it's workings elude me. i still utilize little project (i'm aware there libraries utilize function). here's original: ''' sieve of eratosthenes implementation gareth rees http://codereview.stackexchange.com/questions/42420/sieve-of-eratosthenes-python ''' def sieve(n): """return array of primes below n.""" prime = numpy.ones(n//3 + (n%6==2), dtype=numpy.bool) in range(3, int(n**.5) + 1, 3): if prime[i // 3]: p = (i + 1) | 1 prime[ p*p//3 ::2*p] = false prime[p*(p-2*(i&1)+4)//3::2*p] = false result = (3 * prime.nonzero()[0] + 1) | 1 result[0] = 3 homecoming numpy.r_[2,result] what i'm trying acco...

c++ - OpenVPN TAP I/O operations blocks forever -

c++ - OpenVPN TAP I/O operations blocks forever - following code hangs forever when getoverlappedresult gets called, have not much experience in windows async io operations, implemented per understanding. have used access virtual network interface (by openvpn - tap/tun interface kernel driver installed properly). i found place hangs, don't know reason why hangs ? nread = 0; memset(data_buffer, '\0', nread); overlapped overlapped_read; memset(&overlapped_read, 0, sizeof(overlapped_read)); overlapped_read.offset = 0; overlapped_read.hevent = createevent(null, false, false, null); if ( readfile(fd, data_buffer, len, &nread, &overlapped_read) == false ) { if (getlasterror() != error_io_pending) { std::cerr << "readfile failed : " << getlasterror() << std::endl; homecoming false; } else { dword dwres = waitforsingleobject(overlapped_read.hevent, infinite); if(dwres == wait_object_0) {...

GridGain - Load data from HBase -

GridGain - Load data from HBase - i have application queries hbase , persist info oracle database. these info used study generation. know whether same approach possible when using gridgain in place of oracle database. possible hbase info , load gridgain memory cache , utilize generating reports? i think approach of loading info gridgain cache right approach. 1 time loaded, either able run parallel computations or distributed sql queries straight on gridgain cache. gridgain

windows - WIX / MSI value not removed -

windows - WIX / MSI value not removed - i'm using wix 3.8 build installer. have custom property this: <property id="foo" value="1234" /> which i'm using set custom registry value: <registrykey id='id1' root='hklm' key='software\acme\bar' action='create'> ... <registryvalue type='binary' name='foobinary' value='[foo]'/> ... it works fine when uninstall package, foobinary stays in registry. happens if utilize custom property. doing wrong? acording documentation can add together forcedeleteonuninstall attribute value yes registrykey element. set attribute 'yes' remove key values , subkeys when parent component uninstalled. note value useful if programme creates additional values or subkeys under key , want uninstall remove them. msi removes values , subkeys creates, alternative adds additional overhead uninstall. default "no"....

On extjs 5, how to disable an action column item? -

On extjs 5, how to disable an action column item? - at first, 1 have it, can gridpanel , , cannot action column . i find #grid >#itemid null, #grid good. could help me this? columns: [{ xtype: 'actioncolumn', items: [{ isdisabled: me.fnisdisabled, ... ... fnisdisabled: function(grid, rowindex, colindex, items , rec){ homecoming rec.get('global'); }, will disable action in rows corresponding record has property global set true . you won't have fiddle column @ all... extjs

Spring MVC multiple selection using backend bean -

Spring MVC multiple selection using backend bean - i creating web application in spring mvc using spring form capabilities.when submit jsp form,i getting info string array multiple selection box on controller,and stores in database.when user edit records how can display selected alternative items in multiple selection box. this map used fill multiple selection box. map mp = new hashmap(); mp.put("111", "test1"); mp.put("112", "test2"); mp.put("113", "test3"); mp.put("114", "test4"); mv.addobject("cat", mp); this map user seleted alternative list ,fetched db. map selmap = new hashmap(); selmap.put("111", "test1"); selmap.put("114", "test4"); mv.addobject("selcat", selmap); how can show test1 , test4 selected on edit page in same order. need result in format. i give illustration using spring annotations: work referenced...

Unselectable items in a Combo Box in an Excel VBA -

Unselectable items in a Combo Box in an Excel VBA - i have combo box (in user form in excel) info source set of menu items headers (a named range in worksheet). right now, workaround erase these headers (e.g. main course, desserts, beverages, etc.) still know if it's possible add together these unselectable headers end user has distinctions between different menu items. help much appreciated :) e.g. main courses (**unselectable**) roast beef mashed potato (selectable) spicy spareribs (selectable) beef stroganoff (selectable) roast chicken (selectable) desserts (**unselectable**) mango float (selectable) brownies (selectable) lemon squares (selectable) no afaik, can't that. below 2 alternatives. take pick :) alternative 1 deselect moment user selects relevant header. example private sub userform_initialize() combobox1.style = fmstyledropdownlist combobox1.additem "--- main courses ---" combobox1.additem "roast beef mashed p...

python - Could not Import Pandas: TypeError -

python - Could not Import Pandas: TypeError - i wanted utilize next pandas, not import @ all. https://github.com/pydata/pandas/releases/download/v0.15.0/pandas-0.15.0.win-amd64-py2.7.exe however not import it: import pandas pd traceback (most recent phone call last): file "<pyshell#0>", line 1, in <module> import pandas pd file "c:\python27\lib\site-packages\pandas\__init__.py", line 45, in <module> pandas.io.api import * file "c:\python27\lib\site-packages\pandas\io\api.py", line 15, in <module> pandas.io.gbq import read_gbq file "c:\python27\lib\site-packages\pandas\io\gbq.py", line 39, in <module> if looseversion(_google_api_client_version >= '1.2.0'): file "c:\python27\lib\distutils\version.py", line 265, in __init__ self.parse(vstring) file "c:\python27\lib\distutils\version.py", line 274, in parse self.component_re.split(vstring)...

spring mvc - @SessionAttributes and @ResponseBody do not work together -

spring mvc - @SessionAttributes and @ResponseBody do not work together - i have created simple "test" controller keeps counter in session print how many times request handler called. @controller @sessionattributes("counter") public class mycontroller { @modelattribute("counter") public counter addcounter(){ system.out.println("counter added model"); homecoming new counter(); } @requestmapping("printcounter") @responsebody public string printcounter(model model){ counter counter = (counter)model.asmap().get("counter"); int currval = counter.getvalue(); system.out.println("current value: " + currval); counter.increment(); homecoming "hello-view"; } } every thing works fine, when seek utilize @responsebody on response fails next error: java.lang.illegalstateexception: cannot create session after re...

javascript - Joi validation multiple conditions -

javascript - Joi validation multiple conditions - i have next schema: var testschema = joi.object().keys({ a: joi.string(), b: joi.string(), c: joi.string().when('a', {'is': 'avalue', then: joi.string().required()}) }); but add together status on c field definition required when: a == 'avalue' , b=='bvalue' how can that? you can concatenate 2 when rules: var schema = { a: joi.string(), b: joi.string(), c: joi.string().when('a', { is: 'avalue', then: joi.string().required() }).concat(joi.string().when('b', { is: 'bvalue', then: joi.string().required() })) }; javascript hapijs joi

c - Converting uint8_t to int issues -

c - Converting uint8_t to int issues - i trying communicate usb dongle via serial communication. communication works, cant device correctly parse communication. devices reads message , compares hardcoded c-string. parses , recognizes it's right string, when seek parse value after : character, returns 0x00000000 , have no thought why. i've tried using char cast , utilize atoi, tried using simple ascii translation, , doing bitwise add-on operation shown here: convert subset of vector<uint8_t> int for example: send "heart rate:55" parses , recognizes "heart rate:" when tell go find 55 , bring stuff it, gives me 0x00000000 heres snippet: const uint8_t hrmset[] = "heart rate:"; /** find : character in string , break apart find if matches, , determine value of value of desired heart rate. **/ int parse(uint8_t *input, uint8_t size) { (uint8_t = 0; < size; i++) { if (input[i] == ':') { ...

css - Loading images in HTML -

css - Loading images in HTML - we doing html project. in project, using many images. please verify below scenarios, scenario 1: uploading single image (a.jpg) in main page setting width , loading image (a.jpg) in 950x450 sizes. in description page setting width , loading image (a.jpg) in 400x200 sizes. in footer setting width , loading image (a.jpg) in 50x50 sizes. scenario 2: uploading re-create of single images different size (a_size1.jpg, a_size2.jpg) in main page loading a_size1.jpg. in description page loading a_size2.jpg. which scenario need follow? , why? scenario 1: there performance issue? scenario 2: fast, more memory space. scenario 1: there performance issue? yes. because in description , footer pages, image total size loaded. bandwidth wasted , loading slower scenario 2: fast, more memory space. yes, it's faster while loading image. cost not memory space, it's hard disk space. load images memory when image requested. , in f...

php - Laravel redirect back as a link -

php - Laravel redirect back as a link - we utilize redirect::back() within controller redirection lastly visited page but, there laravel function utilize in views link? you can utilize helper: {{ url::previous() }} so this: <a href="{{ url::previous() }}">go back</a> php laravel-4

php - Getting plain text from json API -

php - Getting plain text from json API - so have api: http://85.17.32.4:8707/status-json.xsl and want extract few things it, started off basic: <?php echo json_decode('http://85.17.32.4:8707/status-json.xsl'); it gave absolutely no result. next try: <?php $var = json_decode('http://85.17.32.4:8707/status-json.xsl'); var_dump($var); it retourned null . then tried making curl function: <?php $url = 'http://85.17.32.4:8707/status-json.xsl'; $ch = curl_init(); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_url,$url); $result=curl_exec($ch); curl_close($ch); var_dump(json_decode($result, true)); this returned null. have farther options? thanks. yes, have farther options: check json_last_error_msg , see whether there issue json decoding: $json = json_decode($result, true); # check if there has been error decoding: if (! isset($json)) { ec...

javascript - How to make the variable available in the methods of the class? -

javascript - How to make the variable available in the methods of the class? - i apologize question, starting larn javascript. i have 2 methods: manager.prototype.filters = function () { var user = []; ... manager.prototype.filters_main = function () { var user = []; ... i need create property 'user' available 2 methods (filters, filters_main). can utilize shared variable (user). how possible write? you have understand prototype-based inheritance here. var manager = function() { this.user = []; } var manager = new manager(); these lines define manager constructor function , create new object. when phone call new manager() , happens is: a new, empty, object created: {} . the code within constructor run new, empty, object beingness value of this . so, set user property of new object ( {} ) empty array. the __proto__ property of new object set value of manager.prototype. so, happens without seei...

Compiling Unity3d for IOS error -

Compiling Unity3d for IOS error - i utilize mono. compiling android works well. ios returns error. total error text: cross compilation job assembly-csharp.dll failed. unityengine.unityexception: failed aot cross compiler: /applications/unity/unity.app/contents/playbackengines/iossupport/tools/osx/mono-xcompiler --aot=full,asmonly,nodebug,static,outfile="assembly-csharp.dll.s" "assembly-csharp.dll" current dir : /users/hexgrim/documents/bottlerepository/bottle_unity_ipad/temp/stagingarea/data/managed env: apple_pubsub_socket_render = '/tmp/launch-czpxth/render' logname = 'hexgrim' __checkfix1436934 = '1' mono_path = '/users/hexgrim/documents/bottlerepository/bottle_unity_ipad/temp/stagingarea/data/managed' tmpdir = '/var/folders/fw/3hkfvy7j49xgk_tfq7kxx3ym0000gn/t/' pwd = '/users/hexgrim/documents/bottlerepository/bottle_unity' ssh_auth_sock = '/tmp/launch-okpdg6/listeners' _ =...

java error while parsing xml file from url -

java error while parsing xml file from url - this question has reply here: unable extract xml info website using java 1 reply i trying parse xml file in java facing problem. code showing error in parsing process if getting json file. how can solve issue ? url url2 = new url("https://api.eancdn.com/ean-services/rs/hotel/v3/list?cid=55505&minorrev=99&apikey=cbrzfta369qwyrm9t5b8y8kf&locale=en_us&currencycode=usd&longitude=0.1275&latitude=51.5072&xml=%3chotellistrequest%3e%0a%20%20%20%20%3ccity%3eseattle%3c%2fcity%3e%0a%20%20%20%20%3cstateprovincecode%3ewa%3c%2fstateprovincecode%3e%0a%20%20%20%20%3ccountrycode%3eus%3c%2fcountrycode%3e%0a%20%20%20%20%3carrivaldate%3e11%2f25%2f2014%3c%2farrivaldate%3e%0a%20%20%20%20%3cdeparturedate%3e11%2f27%2f2014%3c%2fdeparturedate%3e%0a%20%20%20%20%3croomgroup%3e%0a%20%20%20%20%20%20%20%20%3croom%3e%0...

c# - DataTable to CSV date format -

c# - DataTable to CSV date format - i'm trying export datatable csv, number of columns. date_time column exported csv while retaining database date_time format (yyy-mm-dd hh:mm:ss), or that. this code: private void datatabletocsv(string path, datatable dt) { file.delete(path); stringbuilder sb = new stringbuilder(); string[] columnnames = dt.columns.cast<datacolumn>(). select(column => column.columnname). toarray(); sb.appendline(string.join(",", columnnames)); foreach (datarow row in dt.rows) { string[] fields = row.itemarray.select(field => field.tostring()). toarray(); sb.appendline(string.join(",", fields)); } file.writealltext(path, sb.tostring()); } ...

javascript - Execute Ruby files from a HTML page in non IE -

javascript - Execute Ruby files from a HTML page in non IE - i have bunch of code written in ruby. want develop web page can run these scripts. there way execute ruby files web page? if want execute ruby scripts in browser - can utilize ruby compiled https://github.com/kripken/emscripten - scripts executed in page limitations no filesystem access or no threading, highest version of ruby 1.8.7 (for example, here http://codechat.net/) if want run scrpts from browser via http - can utilize cgi (or similar technologies) illustration http://www.tutorialspoint.com/ruby/ruby_web_applications.htm need wrapper add together valid http headers script output javascript ruby ajax html5

jdbc - ColdFusion 11 and Azure Database -

jdbc - ColdFusion 11 and Azure Database - i cant coldfusion connect azure database. have old coldfusion based admin routine requires datasource , moving aws azure. after reading online, seems wont work unless utilize other datasource , jdbc driver , settings. in coldfusion 11, wont validate , tells me connection verification failed info source: mydata com.microsoft.sqlserver.jdbc.sqlserverexception: connection string contains badly formed name or value. root cause that: com.microsoft.sqlserver.jdbc.sqlserverexception: connection string contains badly formed name or value. ive tried lots of combinations , cant work. has got working , have illustration connection string. i worked out. examples found online wrong. below settings need. need download latest jdbc drivers microsoft , set jar files lib directory of coldfusion installation (or in cf classpath) , restart cf server first. datasource type: other jdbc url: jdbc:sqlserver://yourservername.database.w...

javascript - How to properly use button toggle function -

javascript - How to properly use button toggle function - button1toggle() function doesn't seem work. text in button doesn't change. can't find bug. class="snippet-code-js lang-js prettyprint-override"> function button1toggle() { if (document.myform.button1.value == "mute") { document.myform.button1.value = "unmute"; } else { document.myform.button1.value = "mute"; } } class="snippet-code-html lang-html prettyprint-override"> <div>tablet</div><br> <form name ="myform"> <input type="button" name="button1" id="button1" value="mute" onclick="button1toggle()"> </form> maybe have button same id? try - function button1toggle(btn) { if (btn.value == "mute") { btn.value = "unmute"; } else { btn.value...

javascript - Smarty - pass variable -

javascript - Smarty - pass variable - i've asked question on how pass variable in smarty: smarty - include template , update existing variable it's working fine me, need little more advanced see. in 1 template attach gallery slider template variable: {$gallery_slider} in gallery template (which general file other pages, don't want alter it) there's jquery slider options. alter number of visible slides. looks this: visible : {$partial.visible|default:5}, if alter default 3 in template, works, level of template calls gallery - above {$gallery_slider}. how do that? i've tried: {assign var="partial.visible" value="3"} and {assign var="partial.visible|default:3"} and other combinations, none of them works. i'd appreciate suggestions. i don't know how used variable (probably fetch method) should rather utilize include in case: {include file="gallery.tpl" items=5} {inclu...

sql server - TSQL Replicate row n times based on data -

sql server - TSQL Replicate row n times based on data - given table fields id, qty, code , row in table info id qty code 1 3 a,b,c i alter in database be id qty code 1 1 2 1 b 3 1 c is there easy tsql this? create split function create function [dbo].[split] ( @delimited nvarchar(max), @delimiter nvarchar(100) ) returns @t table (id int identity(1,1), val nvarchar(max)) begin declare @xml xml set @xml = n'<t>' + replace(@delimited,@delimiter,'</t><t>') + '</t>' insert @t(val) select r.value('.','varchar(max)') item @xml.nodes('/t') records(r) homecoming end test data declare @table table (id int, qty int, code varchar(100)) insert @table values (1, 3 , 'a,b,c'), (2, 4 , 'e,f,g,h,h') query select t.id ,count(*) qty ,c.val code @table t cross apply ...

c++ - Why does this not tell me how long the vector of strings is? -

c++ - Why does this not tell me how long the vector of strings is? - #include <iostream> #include <vector> using namespace std; int main () { vector<string> ss; ss.push_back("the number 10"); cout << ss.size(); homecoming 0; } when run this, output 1. why not length of string? it tell how long vector of strings is. length of vector means number of items in tt, in case 1 . to length of first item in vector, write cout << ss[0].size(); . c++ vector

c# - What is a NullReferenceException and how do I fix it? -

c# - What is a NullReferenceException and how do I fix it? - i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can it? what cause? bottom line you trying utilize null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers create can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying utilize reference. reference not initialized (or was initialized, no longer initialized). this means reference null , , cannot access members through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ sec line, because can't phone call instance method...

javascript - If condition is true print text in input field with specific ID -

javascript - If condition is true print text in input field with specific ID - noob in need of input here. i've spent hours trying work, both php , javascript , i'm @ now. i want input field show specific text based on condition. if digit in input field 'ebctotal' within range 1-4, show text "very pale" in input field 'hue'. code: function gethue() { var ebc = document.getelementbyid("ebctotal").value; if (ebc >= 1 && ebc <= 4) { // insert text "very pale" element id 'hue' document.getelementbyid('hue').value; } } html: // print text in field <input class="input" type="text" id="hue" size="7" maxlength="20"> // based on value of field <input class="input" type="text" id="ebctotal" size="7" maxlength="20"> am on right track? cheers if want check whether length...

How do I get switch() to loop multiple times in C? -

How do I get switch() to loop multiple times in C? - i have created fruit machine game. loop output several times before printing final output scored. simulate moving nature of real slot machine. when seek , loop switch() statements no output produced. how go doing this? #include <stdio.h> #include <unistd.h> int main () { int firstreel, secondreel, thirdreel, loop; // generating 3 random numbers srand(time(null)); int rndone = rand () %4; int rndtwo = rand () %4; int rndthree = rand () %4; // assigning random numbers clearer var names firstreel = rndone; secondreel = rndtwo; thirdreel = rndthree; // switch statements each reel switch(firstreel){ case 0: printf("bell "); break; case 1: printf("cherry "); break; case 2: printf("orange "); break; case 3: printf("horseshoe "); break; } switch(secondreel){ case 0: printf(...

javascript - Date regex of format mm/yyyy is not working -

javascript - Date regex of format mm/yyyy is not working - i new regex. using regex '^((0?[1-9]|1[012])[- /.](20)?[0-9]{2})$' validate credit card expiry date in mm/yyyy format. this javascript function checks regex , give me response in true or false. function isvalidthrudate(valid_till){ var regex = new regexp('^((0?[1-9]|1[012])[- /.](20)?[0-9]{2})$'); homecoming regex.test(valid_till); } but whenever pass date, gives me false in return. unable figure out problem. function isvalidthrudate(valid_till){ homecoming /^((0?[1-9]|1[012])\s*(?:[-/.]\s*)?(20)?[0-9]{2})$/.test(valid_till); } javascript regex date

c# - Can I get WebApi to work with IoC Aspects/Interceptor -

c# - Can I get WebApi to work with IoC Aspects/Interceptor - i'm wcf background used ioc aspects/interceptors abstract functions such authentication , logging. add together required interfaces aspects constructor same way typical ioc setup. i'm trying apply same sort of process webapi, controllers inherit apicontroller , not implement interface. i'm assuming there different way of applying aspects maybe? public class mycontroller: apicontroller { private readonly iunitofwork _unitofwork; private readonly iloginservice _loginservice; private readonly ilog _log; public logincontroller(iloginservice loginservice, iunitofwork unitofwork, ilog log) { this._loginservice = loginservice; this._unitofwork = unitofwork; this._log = log; } // want intercept method using usertokenauthenticationinterceptor public httpresponsemessage get(guid id) { _log.log(log something); // code thats gets info ...

Infinispan with File Store with Replication enabled -

Infinispan with File Store with Replication enabled - can have filestore configuration , cluster (replication) enabled in infini span cache? give sample configuration. yes, can. same content persisted on nodes. when restarting node, however, should set cache store purged, otherwise removed entries loaded cache. infinispan

unity3d - Using C# IComparer in Unity game engine -

unity3d - Using C# IComparer in Unity game engine - i writing border class graph a* implementation. want later create list of edges , sort them based on border weights using icomparer interface. below implementation of border class within unity 4.5f using unityengine; using system.collections; public class border : icomparer { node destination; int weight; public edge(node destinationnode, int cost) { destination = destinationnode; weight = cost; } public node getdestination() { homecoming destination; } public int getcost() { homecoming weight; } int icomparer.compare(system.object a, system.object b) { if (((edge)a).getcost() == ((edge)b).getcost()) homecoming 0; else if (((edge)a).getcost() > ((edge)b).getcost()) homecoming 1; else homecoming -1; } } but unity throws below error argumentexception: not implement right interface system....

android - Why is my timer Observable never called? -

android - Why is my timer Observable never called? - on android, have written observable should called 1 time after 2000 msec, never called. observable.timer(2000, timeunit.milliseconds) // wait 2000 msec .subscribeon(schedulers.newthread()).observeon(androidschedulers.mainthread()) .flatmap(new func1<long, observable<?>>() { @override public observable<?> call(long along) { continueplayback(); // line never called homecoming null; } }); i want observable wait off main thread, phone call "continueplayback()" on main thread. context help allowed me place subscribeon/observeon between timer , flatmap. correct? happening here , did wrong? what happens observable after call. remain live or need explicitly tear downwards somehow, e.g. phone call oncompleted()? most obsersables passive default , emit items if subscribed to. in code illustration you're not su...

bash - Json Parsing using shell script -

bash - Json Parsing using shell script - this question has reply here: parsing json unix tools 33 answers after doing curl query getting output in format shown below: {"result":[]} {"result":[{"alternative":[{"transcript":"good morning how feeling today"}, {"transcript":"good morning go how feeling today"}, {"transcript":"good morning 2 go how feeling today"}, {"transcript":"good morning how feeling"}, {"transcript":"good morning how today"}],"final":true}], "result_index":0} i want retrieve "good morning how feeling today" first transcript. please tell me how it? thanks! piping curl next e...

go - Custom xml decoder issue -

go - Custom xml decoder issue - i have multiple test cases pass, 1 fails. missing here causing decoder read content of target keys incorrectly? const respgenericfault1 = `<?xml version='1.0' encoding='utf-8'?> <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/xmlschema-instance" xmlns:xsd="http://www.w3.org/1999/xmlschema"> <soap-env:body> <soap-env:fault> <faultcode xsi:type="xsd:string">soap-env:client</faultcode> <faultstring xsi:type="xsd:string">failed validate</faultstring> </soap-env:fault> </soap-env:body> </soap-env:envelope>` type fault struct { faultcode, faultstring string } func (f fault) error() string { homecoming "fault code: '" + f.faultcode + "' faultstring: '" + f.faultstring + "...

php - Pass method from controller as callback to another -

php - Pass method from controller as callback to another - i have this: public function generateaudio(){ $sourceprocessor = new sourceprocessor($_session['input_file']); $sourceprocessor->extractaudio(); } public function checkprogress($percent){ //do percents } and in sourceprocessor have this: public function extractaudio($callback=null, $folder=null){ if(is_callable($callback)){ $callback($percentage); } } i tried pass method $sourceprocessor->extractaudio(array($this,'checkprogress'); $sourceprocessor->extractaudio(array($this->checkprogress()); but nil seems work. have thought how this? call method this: $sourceprocessor->extractaudio(array($this,'checkprogress')); and phone call callback extractaudio this: call_user_func($callback, $percent); see manual entry call_user_func , callable more information php yii

html - IE 11 not Showing 3D Transform -

html - IE 11 not Showing 3D Transform - i have next code. in ie10/11 can't render 3d box (take in chrome) note: tried utilize built in new code snippet feature clicking "insert code" never did anything. http://codepen.io/aherrick/pen/egbmg html: <div class="rack-container"> <div class="rack show-leftop"> <figure class="back"> <svg width="444" height="294"> </svg> </figure> <figure class="front"> <svg width="444" height="294"> </svg> </figure> <figure class="left"> <svg width="96" height="294"> <rect class="rack-left" width="96" height="294" shape-rendering="crispedges" fill="#fff" fill-opacity="1...

c++ - Is this reverse string code correct? -

c++ - Is this reverse string code correct? - this code works me when run on ide, doesn't work on website has exercise. segmentation fault. code correct? did create mistake? #include <iostream> #include <string> using namespace std; string firstreverse(string str) { (int = 0, = str.size()-1; != back; ++i, --back) { char c = str[back]; str[back] = str[i]; str[i] = c; } homecoming str; } int main() { cout << firstreverse("hello"); homecoming 0; } also, what's best way this? your index needs reach half of length, , way ensure swap between pair happens once: for (int = 0; < str.size() / 2 ; ++) { char c = str[str.size() - 1 - i]; str[str.size() - 1 - i] = str[i]; str[i] = c; } c++

jquery - DataTables extra column with button -

jquery - DataTables extra column with button - i using datatables. code <script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('#table').datatable( { "lengthmenu": [[10, 25, 50, -1], [10, 25, 50, "all"]], "serverside": true, "ajax": { "url": "../server_processing/orders.php", "type": "post" }, "order": [[ 0, "desc" ]], "processing": true, "aocolumndefs": [ { "atargets": [ 0 ], "mrender": function ( data, type, total ) { homecoming '<a href="order?id=' + full[0] + '">' + info + '</a>'; ...

java - Optional Joda DateTime type field with JSR 303 Validation and Spring converter -

java - Optional Joda DateTime type field with JSR 303 Validation and Spring converter - i have custom parameter converter & jackson mapper handle joda datetime on spring controllers input. the problem is, server gives 400 bad request if date given in bad format, because of illegalargumentexception thrown joda formatter during conversion. i create converter homecoming null on failing conversion (user typed bad date pattern), give me null in 2 situations: user left field blank (which ok in optional field) user provided date in wrong format (never ok) how differentiate scenerios "allow null (empty field), if not empty, check date format"? background: field represented in pojo datetime , received in @controller @requestbody @valid becaus ajax-posted. form pojo: class myform { @notempty private string name; private datetime expireon; // joda, optional won't bad-format null. // getters, setters } i think should utilize @scriptassert...

visual studio 2012 - Generate MTM report like it was an Ranorex .rxlog file -

visual studio 2012 - Generate MTM report like it was an Ranorex .rxlog file - on ranorex can generate study (.rxlog) contains info 1 project of visual studio after run simple cmd command line .exe path , arguments. can generate study on microsoft test manager looks same .rxlog file in way that? visual-studio-2012 report microsoft-test-manager ranorex

objective c - Use of undeclared identifier DISPATCH_PRIORITY_DEFAULT -

objective c - Use of undeclared identifier DISPATCH_PRIORITY_DEFAULT - dispatch_async(dispatch_get_global_queue(dispatch_priority_default), 0), ^{ [self showspinner]; }); shows error "use of undeclared identifier dispatch_priority_default" what need import? or else wrong? use dispatch_queue_priority_default instead of dispatch_priority_default no need import thing. objective-c iphone ipad

Getting the name of file download using selenium in python -

Getting the name of file download using selenium in python - so i'm downloading file using selenium , works fine need name of file. my variable path should name of downloaded prints out "none". driver = webdriver.firefox(firefox_profile=profile, firefox_binary=binary) driver.get("stuff") time.sleep(2) path = driver.find_element_by_xpath("//a[contains(text(), 'tgz')]").click() print path first link object, can stuff it: link = driver.find_element_by_xpath("//a[contains(text(), 'devcrt.sp1')]") then "href" attribute link object: path = link.get_attribute("href") #this homecoming 'www.booger.com/file.exe' then click on link object: link.click() python selenium

ios - Google Analytics not initialising in Swift -

ios - Google Analytics not initialising in Swift - my new swift app not initialise google analytics reason. created bridging header in project ganalytics files: #import "gai.h" #import "gaidictionarybuilder.h" #import "gaiecommercefields.h" #import "gaiecommerceproduct.h" #import "gaiecommerceproductaction.h" #import "gaiecommercepromotion.h" #import "gaifields.h" #import "gailogger.h" #import "gaitrackedviewcontroller.h" #import "gaitracker.h" and part of appdelegate.swift file: func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { // override point customization after application launch. if nsuserdefaults.standarduserdefaults().boolforkey("allowganalytics") { gai.sharedinstance().trackuncaughtexceptions = true gai.sharedinstance().dispatchinterval = 10 var tr...

c - Use GCC as the Default MEX Compiler for MATLAB 2014a on a 64 bit Windows 7 machine -

c - Use GCC as the Default MEX Compiler for MATLAB 2014a on a 64 bit Windows 7 machine - i looking simple way compile unix mex files on windows 7 computer. the mex files compile smoothly in matlab 2014a on mac os x 10.9 (using "xcode clang" compiler). of people work with, however, having problem compiling them in windows 7 using c compiler windows 7.1 sdk. i understand might able avoid these errors if utilize gcc compile mex files in matlab. wondering if knows how. happy download , edit whatever files necessary can a) compile mex files within matlab using "mex" command , b) guarantee "-i" , "-l" instructions passed mex compiler. note, issue similar to post 2+ years ago. said, have set new post since a) matlab/mingw/mex have had important updates since (not sure if mingw easiest way out of mess); b) there 64 bit thing (not sure if it's problem) , c) "-i" , "-l" options important. start downloading min...

string - Take an array of values and compare them to Enum values in java -

string - Take an array of values and compare them to Enum values in java - so trying in java take in set of values , compare values against same category of values in enum can find specific enum. in other words have bunch of enums public enum fruits{ apple("red", "round", "fruit", true), //about 20 or more constants orange("orange","sphere","citrus", true); private string color; private string shape; private string category; private boolean edible; private fruits(string color, string shape, string category, boolean edible){ this.color = color; this.shape = shape; this.category = category; this.edible = edible; } //getter methods each variable } now have array of strings string[] mystringarray = {"blue", "oblong", "berry"}; string[] mystringarraytwo = {"red", "round", "fruit"}; how compare st...

How to filter JSON object data in android using fragments and Navigation Drawer? -

How to filter JSON object data in android using fragments and Navigation Drawer? - i need help in filtering json object . when click on of alternative on navigation drawer , need open new fragment filtered data. have researched of previous similar questions not find solution problem. i posted portion of json file (i going above limit of characters allowed). if need whole json text please checkout string url_feed ( cannot post more 2 links). i want filter json info using alternative keyword: node_type the code , image below: ****mainactivity**** import java.io.unsupportedencodingexception; import java.util.arraylist; import java.util.iterator; import java.util.list; import org.json.jsonexception; import org.json.jsonobject; import android.annotation.suppresslint; import android.app.activity; import android.app.fragment; import android.app.fragmentmanager; import android.content.context; import android.content.res.configuration; import android.content.res.typeda...