Posts

Showing posts from August, 2015

javascript - How do I parse a JSON multidimensional array in jQuery? -

here json need parse: {"opcode":"groupdetails", "status":"success", "data":[{"group id":5,"group name":"data structure","group subject":"computer science","role type":"teacher"},{"group id":4,"group name":"information technology","group subject":"computer science","role type":"student"},{"group id":6,"group name":"data mining","group subject":"computer science","role type":"parent"},{"group id":7,"group name":"dccn","group subject":"computer science","role type":"teacher"}]} i have tried , implemented solution provided here , implementation of js defined in there solution, which parses json array for (var = 0; < data.data.length; i++) { var...

parsing - Canonical mutual exclusive data structure -

note: unrelated concurrency problem of mutual exclusion, couldn't think of better way of describing problem. i have problem have case want let user select flags, flags mutually exclusive. want describe flags mutually exclusive using data structure, i've thought of has been clunky. basically, want able specify how flags used so: [ -fa | -e | -d ] [ -c ] [ -g | -h ] this should semantically mean, can have 1 of -fa, -e, -d, not 2 or more (however, f can used a, , don't need use both). can either have -c or not, , can have either -g or -h, not both. here's "best" solution. map[flag, mutexgroup] (and inverse, map[mutexgroup, list[flag]]) map[mutexgroup, list[mutexgroup]] what example be map("f" -> 1, "a" -> 1, "e" -> 2, "d" -> 3, "c" -> 4, "g" -> 5, "h" -> 6) map(1 -> list(2, 3), 2 -> list(1, 3), 3 -> list(1, 2), 4 -> list.empty, 5 -> lis...

html - Right header links not clickable when adding top drop down menu -

my site uses wordpress. have right header seen here http://www.gigster.me , top centered drop down menu plugin buddypress links. renders links on top right un-clickable. tried changing z-index properties of center tab it's still not working. drop down menu causing usable area right , left of actual tab/menu visible unusable. i'm not coder appreciate amateurs me. thank you ziad a few options: set login section display: relative; , push rest of page down. decrease it's z-index , when loads, set display: none; .header_right decrease login screen's z-index, increase when it's dropped down.

asp.net mvc 3 - Configuring Virtual Directory for Multiproject Areas in MVC3 -

i using technique described in answer: https://stackoverflow.com/a/7167198/22399 set multi-project areas in mvc3. issue, though, seems in configuring iis express, not in technique itself. i doing wrong in step 7 (using iis express.) keep getting error saying cannot find views (my test area called "sample") here error: the view 'index' or master not found or no view engine supports searched locations. following locations searched: ~/areas/sample/views/index/index.aspx<br /> ~/areas/sample/views/index/index.ascx<br /> ~/areas/sample/views/shared/index.aspx<br /> ~/areas/sample/views/shared/index.ascx<br /> ~/views/index/index.aspx<br /> ~/views/index/index.ascx<br /> ~/views/shared/index.aspx<br /> ~/views/shared/index.ascx<br /> ~/areas/sample/views/index/index.cshtml<br /> ~/areas/sample/views/index/index.vbhtml<br /> ~/areas/sample/views/shared/index.cshtml<br /> ~/areas/sample/views/shared/i...

jquery - Using c# code in javascript -

i trying use c# in javascript using in mvc razor view using @ sign , like suppose array name list passed view can access in view like: view length of array : <input type="text" value="@model.list.length" /> or can iterate list array like: @for(int i=0; i< model.list.length; i++) { console.log(model.list[i]); } but question how can iterate or use array in javascript code , similar : js for(var i=0; i<@model.list.length; i++) { $("body").append("<h1></h1>").html(@model.list[i]); } thanks ! as posted in comment, bit tricky. however, can try construct javascript object c#. something (i don't know how works exactly...): var array = [ @for(var = 0; < model.list.length-1; i++){ @model.list[i] , } @model.list[length] ] which should result in: var array = [ val1,...

windows phone 7 - Create folder with Skydrive API -

in windows phone 7(.5) application using skydrive , want create folder. how (or can find api to) create folder? far found examples scan , download files. i'm using liveconnectclient. direct link creating folders (example provided in several languages [c# windows phone apps]: http://msdn.microsoft.com/en-us/library/live/hh826531#creating_folders skydrive api: http://msdn.microsoft.com/en-us/library/live/hh826521

Equivalent method in java (numpy.random.normal(mean,var)) -

is there method in java equivalent numpy.random.normal(mean,variance) . you can use java.util.random class: random r = new random(); double randomvalue = mean + r.nextgaussian()*variance; note if need multiple random values, can use r multiple times. can supply constructor specific seed random r = new random(1234); .

sharepoint - conditional URL re-writes using IIS 7.5 -

we have bilingual sharepoint website , ensure french content funnelled through our french domain, lets call _frenchdomain.com. languages variations in sharepoint separated folder structure, in our case can go _http://englishdomain.com/en english content , _http://englishdomain.com/fr french content. my question how can iis recognize any instance of _http://englishdomain.com/fr/* , instead rewrite _http://frenchdomain.com/fr/* <rule name="fr"> <match url="fr/.*"/> <conditions> <add input="{http_host}" pattern="^frenchdomain.com$" negate="true" /> </conditions> <action type="redirect" url="http://frenchdomain.com/{r:0}" redirecttype="permanent"/> </rule>

javascript - Image Preview with jQuery, change the Hover image size -

this should simple question: i trying use easiest tooltip , image preview using jquery trying use example it working fine me, my question how can change hover image size (the 1 displayed in tooltip once hovering small one) image big , want set size 200px x 200px how can that? this current style: <style> #preview{ position:absolute; border:1px solid #ccc; background:#333; padding:5px; display:none; color:#fff; } </style> this javascript: this.imagepreview = function(){ /* config */ xoffset = 10; yoffset = 30; // these 2 variable determine popup's distance cursor // might want adjust right result /* end config */ $("a.preview").hover(function(e){ this.t = this.title; this.title = ""; var c = (this.t != "") ? "<br/>" + this.t : ""; $("body").append("<p id='preview...

osx - Git completions for alias functions -

this question has answer here: how bash completion work aliases? 9 answers i have few aliased functions such gb git branch , gco git checkout in .zshrc. works great when remember full branch name i'm creating, deleting, checking out, etc. however, noticed completions no longer seem work. previously, $ git checkout m<tab> and autocomplete master if name of branch. now, however, following error when use: $ gco m<tab> _git:15: parse error: condition expected: 1 i'm not sure why occurring. appears there's possibly missing argument, i'm not sure why. edit: i'm setting alias git branch , git checkout in .zshrc file this: alias gco='git checkout' alias gb='git branch' after little more digging around found solution same problem bash looks work zsh. after defining 2 functions __define_git_completion...

How to time how long a Python program takes to run? -

is there simple way time python program's execution? clarification: entire programs use timeit : this module provides simple way time small bits of python code. has both command line callable interfaces. avoids number of common traps measuring execution times. you'll need python statement in string; if have main function in code, use this: >>> timeit import timer >>> timer = timer('main()', 'from yourmodule import main') >>> print timer.timeit() the second string provides setup, environment first statement timed in. second part not being timed, , intended setting stage were. first string run through it's paces; default million times, accurate timings. if need more detail things slow, use 1 of python profilers : a profiler program describes run time performance of program, providing variety of statistics. the easiest way run using cprofile module command line: $ python -m cprofile yourprogram....

ios - Variable has incomplete type 'QPrinter' -

i trying use qt in ios. #include <qtgui/qprinter.h> qprinter print; above code gives "variable has incomplete type 'qprinter'" error. though qtgui/qprinter.h has complete definition qprinter. ideas how resolve problem? the qprinter.h file has preprocessor condition before definition of qprinter : #ifndef qt_no_printer // class qprinter { // ... // } #endif maybe on ios qt_no_printer defined, perhaps because not supported? can't find official documentation says much, easy enough test if macro defined in build.

ruby on rails - How do I write an Rspec controller test that makes sure an e-mail is sent? -

currently in controller spec have: require 'spec_helper' describe customerticketscontroller login_user describe "post /create (#create)" # include emailspec::helpers # include emailspec::matchers "should deliver sales alert email" # expect customer_ticket_attributes = factorygirl.attributes_for(:customer_ticket) customer_mailer = mock(customermailer) customer_mailer.should_receive(:deliver). with(customerticket.new(customer_ticket_attributes)) # when post :create, :customer_ticket => customer_ticket_attributes end end end in controller have: # post /customer_tickets # post /customer_tickets.xml def create respond_to |format| if @customer_ticket.save customermailer.sales_alert(@customer_ticket).deliver format.html { redirect_to @customer_ticket, notice: 'customer ticket created.' } format.xml { render xml: @customer_ticket, status: ...

asp.net - Read last Inserted row in Sql according to its Time stamp -

sql has table called emp. emp(emp_id int identity primary key, employeename varchar(50),.......) i want insert record above table. here code in asp.net. dbconnection dbcon = new dbconnection(); string query = "insert emp values('" + textbox_empname.text + "','" + ....); int no1 = dbcon.insertquery(query); i have table called emp-relation emp-relation(emp_id int primary key, count int, ....) -- foreign key (emp_id)references emp(emp_id) my problem when inserting emp row ,i dont know emp_id since created auto. , when going insert emp-relation , want emp-id since foreign key. how can this? there way read last insert row in sql according time stamp or thing? believe records not sorted according inserted timestamp in nature. please me. there's bascally 2 ways. first way return new id first insert query: insert emp values(...) select scope_identity() newid the second way lookup first row when insert relation table...

google play - Android Licensing (LVL) keeps returning Retry (code 291) after publishing app -

i made update existing (paid) app have had published on google play while. while working on new version, thought i'd implement google licensing verification library. followed instructions google @ http://developer.android.com/guide/market/licensing/adding-licensing.html . had things working pretty @ point - when changed test response in google play developer console got different result in app. great! then published new version. i installed signed apk (it's paid app didn't want download google play) on phone (had been testing on same device along). things didn't work @ all. got "retry" result licensing service time. mean hours. went , fiddled source code, changed kinds of things, nothing worked. licensing library timed out (got "check timed out." in library in logcat). i searched everywhere answer, wasn't until ran across discussion ( http://forum.xda-developers.com/showthread.php?t=1566770 ) , read it's final post found solution....

analytics - which heatmap library/software can be used on ajax rich site ? -

i developing ajax heavy site, of content loaded dynamically. technique have benefits - enhanced ux, caching. however, can not find open source heat map (to chart clicks) solution fits such site ? these days, lots of sites being made ajax-rich or hijax based - wondering options use analytics - more heatmaps.

sql - One-to-One Relationship between tables that can't share primary key -

scenario: each "user" has 0 or 1 "bankaccount". each "company" has 0 or 1 "bankaccount". "bankaccount" records can not shared. how setup database model this? tried this: "companybankaccount" table "bankaccountid" (primary key) foreign key "bankaccount" table , column "companyid" foreign key "company" table. "company" table nullable "bankaccountid" column foreign key "companybankaccount" table. followed same pattern user tables. while works (enforces rule no company or user can have more 1 bank account , no bank account can shared user or company), creation of new company or user bank account cumbersome (i must first insert company/user null bankaccountid, insert new bankaccount record, insert new [company/user]bankaccountrecord, update "bankaccountid" field on company/user record inserted). seems there should easier way. have ...

android - Imports just on API level > 15 -

i have app created on api 8. want make work ics , need additional imports not available in api 8. want add following imports: import android.provider.calendarcontract; import android.provider.calendarcontract.calendars; import android.provider.calendarcontract.events; so have make diffenent app api > 15? name of app should not change. or maybe possible place 2 app versions , make minsdkversion , maxsdkversion according api level google play? how handle that? i have app created on api 8. great! now want make work ics , need additional imports not available in api 8. no problem! since import statements applied @ compile time, long set project's build target (e.g., project > properties > android) api level 14 or higher, code compile fine. so have make diffenent app api > 15? no. use version guard blocks ensure not try using newer code on older devices: if (build.version.sdk_int>=build.version_codes.ice_cream_sandwich) { /...

structure - How to tidy up urls -

do have tips on how create more readable links pages? i not know correct term is, wordpress have feature called permalink, tidy url more readable (eg. http://example.com/2012/post-name/). what looking not have same technique 1 wordpress use. or simple solution old directory structure? thank you! http://codex.wordpress.org/using_permalinks you've got use mod_rewrite . if using paid hosting service, chances have enabled in apache. if not, there lots of tutorials on building it. now plan how want urls like. example, want turn http://yoursite.com/tutorials.php?req=tutorial&id=3&page=0 http://yoursite.com/tutorials/3/0.php open or create .htaccess file , add like rewriteengine on rewriterule ^tutorials/(.*)/(.*).php /tutorials.php?req=tutorial&tut_id=$1&page=$2 note pattern: (.*) variables, such $1 placed, in order. source , more information: http://www.devshed.com

c++ - Gtkmm: Adding Window at later time -

because i´m writting "generic" application behaving different when facing other configurations, i´m forced show gtk windows if dont yet know them @ startup. there might requirement multiple windows need visisble (not modal dialogs standalone windows) @ same time. but, great if 1 can start 1 gtk event loop @ startup. is somehow possible add windows loop after has been started? while found gtk::application class seems support indented behaviour i´m restricted use gtk::main class. there's single gtk::main object allowed. widgets should created in same thread main event loop being run in. work around limitation need develop way pass window creation commands gtk thread. the simplest way use glib::dispatcher struct windowbuilder { /**/ glib::dispatcher* signal_create; void create_window() { //from main thread... signal_create->emit(); } } void create_mainwnd() { new ui::mainwnd(); } //from gtk thread... builder-...

asp.net membership - SQL Azure SPLIT ON UNIQUEIDENTIFIER GUID -

let's there application generating random guids corresponding number of normalized records in few tables. these records guid "tenant_id" need split multiple federated members in sql azure. when split @ command issued, ordering mechanism used split members @ specific point (tenant_id)? similar order guid_field asc/desc resultset? since guids generated randomly, best way create ranges future splits? thank you guids ranges split according sort order in sql server - same used order , indexes. see blog post more details on this: http://sqlblog.com/blogs/alberto_ferrari/archive/2007/08/31/how-are-guids-sorted-by-sql-server.aspx if generating guids randomly , need split, should use ordering definition guids pick point somewhere in middle of set of guids in member splitting (assuming want split in middle). if want more control tenants go where, generate own, "custom" guids, of course lose global uniqueness property guids have, unless ensure globally u...

google analytics - big difference in "visitor" count -

i try pull out (unique) visitor count directory using 3 different methods: * profile * using dynamic advanced segment * using custom report filter on smaller site 3 methods give same result. on large site (> 5m visits/month) big discrepancy between profile on 1 hand , advanced segment , filter on other. might because of sampling - difference smaller when comes pageviews. estimation of visitors worse , discrepancy bigger when using sampled data? when extracting data api (using filters or profiles) still different data if ga doesn't indicate data sampled - ie i'm looking @ unsampled data. another strange thing pageviews higher in profile filter, while visitor count higher filter vs profile. applied filter @ profile force use sample data - , again quite similar results filter , segment-data. profile filter segment filter@profile unique 25550 37778 36433 37971 pageviews 202761 184130 n/a 202761 what trying achieve find way acc...

QML: ListView item doesn't update -

i have created download manager using listview(to display progress) , downloads running in separate threads implemented in qt. the problem i'm having if add new download list, last added item of listview continues have progress updated. the rest freeze @ point were, although downloads on threads continue normally. all functions called correctly, variables set correct values, problem listview doesn't updated.

c# - Call a string method from one class to another -

i have assignment based on coin , card games simplified. given complete , incomplete files. trying invoke method (which string) 1 class (card.cs) in (hand.cs). here string method card.cs: public string tostring(bool shortformat, bool displaysuit) { string returnstring; // describe facevalue. facevalue facevalue = getfacevalue(); string facevalueasstring = facevalue.tostring(); if (shortformat) { if (facevalue <= facevalue.ten) { facevalueasstring = (facevalue - facevalue.two + 2).tostring(); } else { facevalueasstring = facevalueasstring.substring(0, 1); } } returnstring = facevalueasstring; // describe suit. if (displaysuit) { string suit = getsuit().tostring(); if (shortformat) { suit = suit.substring(0, 1); returnstring += suit; } else { returns...

listview - Delete an item in a list permanently by accessing JSON file -

i trying delete item list when user taps on delete button. i delete item store , item deleted list , however, when re-run application items present . in order delete items permanently tend think must delete item in json file , how can obtain json string of list , modify it. i using following code deleting item : var store = ext.getstore('mylist'); store.removeat(index); this.getlist().refresh(); if you're working localstorage, need store.sync() propagate changes store.

java - how to make android beep in only one ear? -

i still new android , working on project, have guide person using audio signals. want beep @ frequency in 1 ear tell person either turn left or turn right. when directing straight both ears beeping. i found number of examples here on how generate beep sound on android. here example of how generate arbitrary beep sound: playing arbitrary tone android all want play in 1 ear , shift between playback in either ears. has idea of how can done? you make 3 different stereo soundclips have sound in left, right , both channels , play them soundpool

python - Alternatives to scipy.interpolate.griddata that don't hang on aligned points -

Image
i have point dataset i'm trying interpolate on grid. these points aligned in grid fashion points missing see below: to complicate it, it's possible other input pointsets may not align on grid, i'm trying use scipy.interpolate.griddata interpolate these values onto regular grid. however, underlying grid aligns sampling rate of input point dataset , griddata hangs. according this question scipy.interpolate.griddata operates poorly if sample occurs across 3 points aligned happens me. is there high performance alternative interpolation of point data onto regular grid in python? my solution has been stochastically perturb x , y coordinates of each input point random factor between 1e-6 * grid_cell_size . choose 1e-6 rule of thumb of several orders of magnitude greater minimum delta difference in 32 bit float, yet small enough error introduced still shadowed error introduced interpolation scheme. i'm still open other ideas, way can use stock interp...

android - AAR Record in NFC: Where's The Payload? -

according this answer , , validated testing, when use android beam push on nfc message containing aar record, receiving device start main / launcher activity app specified in aar. that main / launcher intent not contain nfcadapter.extra_ndef_messages extra. hence, data went through trouble beam on appears lost if use aar. is there way nfc messages triggered app started in scenario? and if answer "no", use case of aar? can see might helpful when desired app not exist on receiving device (brings play store), once app installed, aar foils attempt deliver data 1 device other, kinda point behind nfc. thanks! at risk of answering own question, 1 recipe getting work (apparently) is: have beam sender use nfc message 2 nfc records, first containing unique mime type, second being aar have beam recipient have <intent-filter> on activity responds first nfc record, such via: <intent-filter> <action android:name="android.nfc.a...

html - How can I evenly space out the elements of my navigation bar using the width attribute? -

here's simulation: http://jsfiddle.net/lq9dp/ and here's html , relevant css sections respectively: html: <div id="footer"> <div class="nav_wrapper"> <ul id="list_orientation"> <li><a href="http://www.facebook.com">facebook</a></li> <li id = "portfolio_text"><a href="http://www.google.com">portfolio</a></li> <li><a href="http://www.google.com">email</a></li> </ul> </div> </div> css: #heading{ font-family:'chunkfiveromanregular'; position: absolute; font-size:80px; top: 10%; left: 0px; width: 100%; height: 1px; text-align:center; } .border{ border-top: 5px dashed #000000; border-bottom:5px dashed #000000; padding:20px; } body{ background:...

javascript - event listener for numeric string in any input or textarea? -

trying make greasemonkey script/chrome extension when enter first 4 numbers of credit card, opens new tab porn in distract me instead. me save money. totally serious way - can done? here's started: $(function() { $("html").on("keyup", "input", function() { if(/^\d{4}$/.test(this.value)) { // } }); }); it binds keyup listener input fields (including dynamically-created fields) checks field values 4 digits.

ios - NSPredicate - Core Data - Compare two properties to each other -

i have thought easy thing / find on google-verse have been totally baffled. have single object 2 date properties setup in core data. want grab list of objects 2 dates not same. how can using core data? [nspredicate predicatewithformat:@"datemodified != datecreated"]; does not work.

objective c - Simple NSButton Hiding Another NSButton -

i have 2 nsbuttons, both ibactions. when click 1 of buttons, want other button hidden. can make them hide themselves, can't figure out how hide other one. actual implementation have 'start' button, hidden until user finished doing tasks, shows again other objects being hidden. thanks help! @interface label : nsobject { iboutlet nstextfield *mytextfield; } -(ibaction)btntest1:(id)sender; -(ibaction)btntest2:(id)sender; -(ibaction)btntest1:(id)sender { mytextfield.stringvalue = @"you selected 1st button"; nsbutton *tempbutton = sender; [tempbutton sethidden:yes]; } -(ibaction)btntest2:(id)sender { mytextfield.stringvalue = @"you selected 2nd button"; nsbutton *tempbutton = sender; [tempbutton sethidden:yes]; } @interface label : nsobject { iboutlet nstextfield *mytextfield; iboutlet nsbutton *btn1; iboutlet nsbutton *btn2; } in method : [btn1 sethidden: yes] btn2 same.

sql - Possible index corruption? -

Image
in above image can see have table, when query max value of field it, different results based on clause rest of queries seem rule out irrelevant. back end msde 2000, front end application written in vb.net 2008, verification performed using ssms 2008r2 attached msde instance on vpn. it closed system application development, if correct whatever causing believe both db , application resume operation. the problem is causing when requests max([record_index]) + 1 [station_id] = 10, value coming record exists in table, , insert failing because of unique constraint. reindex of pk index solved problem , makes above queries max([record_index]) return same number max([record_index]) where... return same numbers, should. @ point index corruption logical answer. db engine 12 years old, , time has ever happened us, guess have accept it

python - QueryFrame very slow on Windows -

i have build simple webcam recorder on linux works quite well. ~25fps video , audio. i porting recorder on windows (win7) , while works, unusable . queryframe function takes more 350ms, i.e 2.5fps. the code in python problem seems lib call. i tested on same machine same webcam (a logitech e2500). on windows, installed opencv v2.2. cannot check right version might bit higher on ubuntu. any idea problem ? edit : i've installed opencv2.4 , have same slow speed. if problem on queryframe suspect following might happening: windows' driver camera retrieves frames in format not natively supported opencv, opencv forced convert frames format understands. operation consumes cpu , notice performance loss if size of frames big. for testing purposes, can: 1) set smaller size frames , see if improves performance: cvsetcaptureproperty( capture, cv_cap_prop_frame_width, 320); cvsetcaptureproperty( capture, cv_cap_prop_frame_height, 240); 2) use camera , see if...

How can I do a PCA plot in R skipping the first few principal components? -

i have data want pca plot on. however, first 2 principal components entirely due 3 outlier samples (out of 32), , i'd skip these , plot principal components starting 3rd. possible, or have calculations subtract first 2 principal components data , plot remainders? if outliers dominating pca, , don't want highly recommend removing them before performing pca.

webkit - Jquery Droppable Draggable Not Working in Chrome/Safari and IE 9 -

Image
the following jquery drag/drop not work in: internet explorer: 9 safari: 5+ chrome: 19+ in chrome , safari, drop not working. when drop draggable, reverts should, reappears on cursor. must click droppable hit register. in ie 9, drag not working. not move. what need have inventory on right. inventory slider (which have removed sake of simplicity). when drag item inventory, reverts , place image source on drop's image placeholder. $(document).ready(function() { $('.circles').draggable({//the drag not fire in ie9 revert: "invalid", helper: "clone" }); $('.circletargetcontainer').droppable({ accept: '.circles', activeclass: 'ui-state-active', drop: function( event, ui ) { alert("hit");//the hit not register in chrome , ie var popimage = $(ui.draggable).find('img').attr("src"); //set placeholde...

mongoid - How do I query for a specific MongoDB collection field inside Rails Console? -

i have rails 3 app using mongodb, mongoid orm. i'd query specific field within collection. to query records of particular collection use user.all.to_a , equivalent user.all in activerecord. now i'd query records within collection, output particular field. in case i'd see user names. how do this? i'm sure i've stared right @ in mongoid documentation , missing something... i couldn't locate in new documentation mongoid, here quick link only pointing old 2.x.x documentation. basically need do: user.all.only(:name).to_a

java - GSON generics serialization -

possible duplicate: deserializing generics gson so need do: type fluenttype = new typetoken<bruteforcefluentimpl<gtldigestor.data>>() {}.gettype(); instead of type fluenttype = new typetoken<fluent<t>>() {}.gettype(); // <-- want able this. string json = gson.tojson(fluent, fluenttype); this means every time have specify different type parameter fluent class, need change code in order specify it. right now, type parameter gtldigestor.data . how do this? (the second line of code won't work) you need tell gson actual parameterized type (e.g. bruteforcefluentimpl<gtldigestor.data> , including actual runtime raw type , actual type parameter value) @ runtime, because gson needs save information. using typetoken easiest way type , use must hard-code exact type in source (no type parameters t ). if put code in method re-used different types, perhaps method should accept type parameter, caller needs pass in. type can...

database - Storing data in text files instead of SQL Server -

i'm intending use both of sql server , simple text files save data. information users data going stored in sql server, rss fedd each user going stored in folder user id title , inside folder can put files going store data in, each file can take 20 lines, if there more 20 make new file. when need reed data call last file in user's folder. i need know advantages , disadvantages of using method? thanx

uniqueidentifier - how to generate unique and [pseudo] sequential GUIDs across multiple servers? -

we looking solutions generating ids per title of question. for clarification: we using several different sql servers , application servers, of generating id we not want use central id-generating service/machine we not want use datetimes bitwise-converted guids because many machines there possibility of collision. one possible solution assign each machine start position, skip, , offset, answer: https://stackoverflow.com/a/7916720/175127 this our solution, i'm hoping among might have more elegant solution better addresses of following issues: one machine might end assigning lot more ids , skip far ahead of others. might resync machines have new start position every day keep them on pace each other, result in large amount of empty, unused ids. wish minimize this. we wish see if it's possible decrease external dependency of each machine. @ start each have find out how many machines there are, start point is, , have decide on unique offsets. think having for...

php - MySQL LIMIT 1 but query 15 rows? -

basically i'm trying compare id's of rows against 15 results in mysql, eliminating 1 (using not in ) , pull result. now fine itself, order of 15 rows i'm doing sql query changing based on ranking, there possibility between time ranking updates, , ajax request (which submit id's not in ) more 1 id has changed, of course bring more 1 row not want. so in short, there way in can query 15 rows, return one? without having run 2 separate queries. appreciated, thank you. example: say have 7 items in database, , i'm displaying 5 on page user. these being displayed user: apple orange kiwi banana grape but in database have peach blackberry now want if user deletes item list, add item (based on ranking have) now issue is, in order know have on list @ moment send remaining items database (say deleted kiwi, send apple, orange, banana, , grape) so select highest ranked 5 items remaining 6 items, make sure not ones displayed on page, , add new 1 list (eith...

backgroundworker - How to have multiple singleton instance when user regenerate the data structure in application? -

i have application uses ground worker(bw) , tasks. i have 1 singleton instance in app..which contains of common info instance of application. have different agents listed in app..and if switch different agent, i have build entire data structure (models/viewmodels/dtos) lets say, agent "a" 1 of bw spawned...and uses above mentioned singleton instance... soon switch agent "b"...so in app, create new data structure aganet "b". uses same singleton instance. if change property in singleton instance...there chance new value used bw spawned agent "a". can me overcome situation? can have different singleton instance different agents ? any appreciated. thanks edit : different approach if can tell me great. a singleton, definition, can exist once. if want different settings each user, need use different architecture. see http://sourcemaking.com/design_patterns/singleton more information singletons.

Python/Tkinter force wait on button click -

back after 30 minute search , either failure comprehend results or unable find results... i want force application wait button click before continuing, , have following code snippet example: ... def crack(self, filenamelist, forceclick): forceclick += 1 self.crackbutton.configure(state='active') if forceclick != 2: self.crackbutton.bind('<buttonrelease-1>', self.crack(filenamelist, forceclick)) self.outputbox.insert(end, '\n' + 'parsing answer numerator...' + '\n') ... i want load function crack(), increment 1 forceclick (which set 0 beforehand), change 'crack button' active state, , bind button while waiting user provoke bind. after bind provoked, function reloads, increments 1 forceclick, , skips if statement. however, when run program through, binds key crack button , automatically reloads function bypass if statement... tried while loop before, did not end well... ...

silverlight - WPF/SL Animation Time Scaling -

i looked particular thing, because thought it's quite important , puzzling thing, didn't find on matter. i'm thinking time scaling in wpf , silverlight animations. suppose have doubleanimation lasts 4s , animates property 0 100. it's autoreversed, or there's complementing animation reverses effects, that's not important. let's event triggering animation simple mouseover. here's problem: hover cursor on element. property gets 0 100 in 4s. move cursor away 1s, property gets 100 75, , hover back. property gets form 75 100 in 4s. it's obvious user, animation runs 4 times slower. there way scale time of animation? if want animation run 75 100 in 1s, how that? myself thinking maybe of converter take 4 parameters (absolute beginning , end, actual beginning, , timespan whole interval) , spit out proper time. there more elegant way? i noticed it's not problem when animations fast. human not observe difference in speed when animation runs in 0.2s...

javascript - Passing in Params to JS.ERB file from controller? [Rails 3] -

i trying allow users "import" saved missions syllabus post. syllabus has many missions, , syllabus form nested form user can 'add missions,' append new missions textbox. when "import" missions, want javascript to 1. click "add missions" link (which adds nested form) 2. input values of "imported missions" ckeditor textbox. _import_form.html.erb <%= form_tag(import_missions_path, :method => :post, :id => "import-js" ) |f| %> <ul> <% current_user.folders.find_by_order(1).missions.each |mission| %> <li> <%= check_box_tag "mission_ids[]", mission.id %> <%= mission.id.to_s + ". " + mission.title %> </li> <% end %> </ul> <%= submit_tag "import ", :class => 'btn btn-primary' %> <% end %> this goes syllabuses#import def import @missions_hash = [] #loop through each mission id :missions_id pa...

javascript - Consume Google Feed API with Phantomjs -

i trying translate this example of google feeds api work phantomjs. following example phantomjs have following: var page = require('webpage').create(); page.onconsolemessage = function(msg) { console.log(msg); }; // our callback function, when feed loaded. function feedloaded(result) { if (!result.error) { // loop through feeds, putting titles onto page. // check out result object list of properties returned in each entry. // http://code.google.com/apis/ajaxfeeds/documentation/reference.html#json (var = 0; < result.feed.entries.length; i++) { var entry = result.feed.entries[i]; console.log(entry.title); } } } page.includejs("http://www.google.com/jsapi?key=aizasya5m1nc8ws2bbmprwku5gfradvd_hgq6g0", function() { google.load("feeds", "1"); var feed = new google.feeds.feed("http://www.digg.com/rss/index.xml"); feed.includehistoricalentries(); // tell api want have old entries ...

android - How can I get a static SQLite database to show up in my listView -

i'll start off listing code have far... this main activity class: public class sqlitedatabasemain extends activity { listview list; databasehelper helper; sqlitedatabase db; databaseadapter adapter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); init(); } public void init() { helper = new databasehelper(this); list = (listview) findviewbyid(r.id.listview1); db = helper.getwritabledatabase(); helper.populategrocery(db); } } this databasehelper class: public class databasehelper extends sqliteopenhelper { private static final string database_name = "grocerystoretest.db"; private static final string database_table = "grocerystoreitems"; private static final string grocery_key_name = "name"; private static final string grocery_key_type = "type"; pr...

java game bug, should be simple -

im trying make clone of game "lumines" in java. have couple of months of experience in simple java, , tried hard possible not bring problems internet, have been working on bug hours no prevail. if you're not familiar lumines, watch video: lumines video . in video, see when row of block falls on top of laid block, outer row continues falling. bug is. have got outer column continue falling in positions, if spin 1 block once , drop floor, , spin block once , drop right outer column supposed continue falling, doesn't fall. since there alot of source code/images, , bad it's embarrassing (i getting around making more efficient, wanted major parts down first ), upload files download here: source/images when run it, press arrow once , wait block fall. when next block appears @ top, press arrow once , right arrow once. wait block fall , see bug. (dont laugh @ 1337 c0d3z )

iphone - Increasing tabBarItem image size -

okay programatically adding images tabbaritems so self.button1.image = [uiimage imagenamed:@"156-controlpad.png"]; i wondering if there way increase size of images 30x30 "what are" larger 45x45.. or required bigger image? any appreciated. you have add image strip on app window.

android - Google play is not displaying my app for tablets? -

i display app tablets well,what necessary steps needed followed app listed tablet well.already app been listed mobile phones.am missing here,please provide help.thanks. write below code androidmanifest.xml file <supports-screens android:anydensity="true" android:largescreens="true" android:normalscreens="true" android:smallscreens="true" />

Parse strings from Excel file for translating an Android app -

to translate android app have excel file of english, spanish, french , many more languages each hundreds of strings app. what best way separate string names , strings in xml file create new translated strings.xml documents each language excel file? there service or tool that can automate process?

ios5 - RestKit and iCloud directory backup policies -

i working on ios 5.0+ project uses latest restkit download, map , persist core data. looking definitive answer on apple's icloud storage guidelines restkit. need take steps make sure data downloaded use in app not automatically backed icloud account.do need alter default location directories used. in advance. if core data store not saved in ubiquity container (see: urlforubiquitycontaineridentifier: ) never synced. also in using icloud in conjunction core data section of documentation state: setting core data store handle icloud requires little effort on part. steps must follow depend on whether using single core data store central library app or whether creating separate stores individual documents. you have explicit changes synchronization. if read documents further, mention keys nspersistentstoreubiquitouscontentnamekey . if search in restkit source, not find - because restkit not sync icloud automatically (and can not because icloud app level sy...

Is it possible to use mysql database without installation? -

i have installed eclipse java/j2ee. learning purposes, want database available in system. don;t have admin rights. without installation want use database. possible use mysql in case? it's not same mysql, may able set sqlite database. sqlite allow create , maintain local database, housed in single file, without needing special sql permissions.

extjs - How to change the font size and color of list items in sencha touch -

i have sample application binding store data list using itemtpl, have little confusion on how change color , size of first 2 list items when dynamically binding data list store. this sample code : ext.define('sample.view.searchresultview', { extend: 'ext.panel', requires: [ 'ext.list', 'ext.form.fieldset', 'ext.field.text', 'ext.toolbar', 'ext.titlebar' ], alias: "widget.searchresultpage", config: { scrollable: true, items: [ { xtype: 'list', layout:'fit', height:500, title: 'search results', store: 'mysearchstore', itemtpl: '<table><td><tr height=10%>{blockno}</tr><tr height=90%><p>{shortdescription}</p></tr></td></table>...

java - Android app force closes while going on another activity -

i making android app using android 2.2 , eclipse. there 2 workflows of app: wf1: coverpageapp -> loginactivity -> dashboard. wf2: coverpageapp -> registeractivity -> dashboard. but click on start button in coverpageapp go on activity, i.e loginactivity, app force closes. have included logcat shows error of null exception , in loginactivity java file points on line 51: btnlinktoregistrscrn = (button) findviewbyid(r.id.linktoregisterscreen); androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.app.android" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:targetsdkversion="15" android:minsdkversion="8" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name=...

algorithm - Checksum for an integer array? -

i have array of size 4,9,16 or 25 (according input) , numbers in array same less 1 (if array size 9 biggest element in array 8) the numbers start 0 , algorithm generate sort of checksum array can compare 2 arrays equal without looping through whole array , checking each element 1 one. where can sort of information? need simple possible. thank you. edit: clear on want: -all numbers in array distinct, [0,1,1,2] not valid because there repeated element (1) -the position of numbers matter, [0,1,2,3] not same [3,2,1,0] -the array contain number 0, should taken consideration. edit: okay tried implement fletcher's algorithm here: http://en.wikipedia.org/wiki/fletcher%27s_checksum#straightforward int fletcher(int array[], int size){ int i; int sum1=0; int sum2=0; for(i=0;i<size;i++){ sum1=(sum1+array[i])%255; sum2=(sum2+sum1)%255; } return (sum2 << 8) | sum1; } to honest have no idea return line unfortunately, algorithm not work. arrays ...

php - Getting BLOB from mysql database to android -

i have mysql database following schema (int id, int sys_id, blob data) there can multiple data same sys_id, i.e. (1,1, blobdata1), (2,1, blobdata2) etc. valid entries. blob data compressed audio. when rows particular sys_id combined valid compressed audio data produced. i want send blob data android device. have tried following php code send data not received expected @ client side. $conn = mysql_connect("localhost","root",""); mysql_select_db("mydb", $conn); global $blobid; $blobid = $_get['id']; $result = mysql_query("select data table sys_id=$blobid"); if( mysql_num_rows($result) == 0 ) die("no rows returned"); while($row = mysql_fetch_array($result) ) { // correct way of concatenating binary data $temp .= $row['data']; } // problem: should sent echo $temp; i don't mind if rows can received @ client end , can concatenated or operated upon locally there. at client side, follo...

css - jquery draggable li with image inside -

i'm dynamically creating li draggable elements. works ok want dynamically insert image inside li's , able o still drag , drop them. here working code: for( = 1; <= num; i++) { $("#sortable").append("<li class='ui-state-default' id=" + + ">" + "no" + + "</li>"); } how can this? maybe inline css , background-image style? yes dynamically assign class background-image li. have know size of images. but why not add image? $('li#idofyourli').html('<img src="pathtoyourimg" />')

datetime - Understanding java.util.Calendar WEEK_OF_YEAR -

i'm trying understand how java.util.calendar.get(java.util.calendar.week_of_year) works, seems i'm missing points. string time = "1998-12-31"; // year month day java.util.calendar date = java.util.calendar.getinstance(); date.settime((new java.text.simpledateformat("yyyy-mm-dd")).parse(time)); system.err.println("week of year = " + date.get(java.util.calendar.week_of_year)); // week of year = 1 why ??? why date.get(java.util.calendar.week_of_year) returns 1 last week of year? moreover, week_of_year "1998-01-01" 1 , "1998-12-23" 52. have explanation behavior? from java.util.calendar javadoc : first week calendar defines locale-specific 7 day week using 2 parameters: first day of week , minimal days in first week (from 1 7). these numbers taken locale resource data when calendar constructed. may specified explicitly through methods setting values. when setting or getting week_of_mo...