Posts

Showing posts from January, 2013

objective c - How to make my keyboard loads with out network access iOS -

objective c - How to make my keyboard loads with out network access iOS - i've developed custom keyboard ios 8 , submitted review in app store 7 days ago. but today rejected app , said that's because app not work without network access , against guideline 25.5 but i've tried every other keyboard available on app store, , non of them loads out granting "allow total access". i've done every thing can imagine, non of them made keyboard (or other keyboard available on app store) loads out granting "allow total access". i created new project, , add together keyboard extension , tried run it, again, simple project (which did not add together line of code) did not load keyboard out granting "allow total access". so if 1 had similar problem, should do, create app loads keyboard out granting "allow total access". ios objective-c xcode swift keyboard

javascript - How can I toggle show/hide all images instead of just hiding? -

javascript - How can I toggle show/hide all images instead of just hiding? - i have button set hide images (under class user_upload) hides instead of toggling hide , show. how can alter code toggles? function hidei(id) { $('.user_upload').hide(); thanks! :-) try this: function hidei(id) { $('.user_upload').toggle(); javascript jquery html css hide

haskell - Why does foldr use a helper function? -

haskell - Why does foldr use a helper function? - in explaining foldr haskell newbies, canonical definition is foldr :: (a -> b -> b) -> b -> [a] -> b foldr _ z [] = z foldr f z (x:xs) = f x (foldr f z xs) but in ghc.base, foldr defined as foldr k z = go go [] = z go (y:ys) = y `k` go ys it seems definition optimization speed, don't see why using helper function go create faster. source comments (see here) mention inlining, don't see how definition improve inlining. i can add together of import details ghc's optimization system. the naive definition of foldr passes around function. there's inherent overhead in calling function - when function isn't known @ compile time. it'd nice able inline definition of function if it's known @ compile time. there tricks available perform inlining in ghc - , illustration of them. first, foldr needs inlined (i...

javascript - How to change z-index only this id elements? -

javascript - How to change z-index only this id elements? - how alter z-index id elements ? when utilize code ,all id in page alter z-index. i want alter z-index id = link-box , love-box , love-box_inner how can ? document.getelementbyid("link-box").style.zindex="99999"; document.getelementbyid("love-box").style.zindex="99999"; document.getelementbyid("love-box_inner").style.zindex="999999"; my guess 3 elements, #link-box , #love-box , love-box_inner have default position of static , , result, z-index , though set, has no effect. in addition, need set position: relative on 3 relevant elements. javascript jquery css

ios - Black screen on the simulator when do back in navigation bar after using search Bar -

ios - Black screen on the simulator when do back in navigation bar after using search Bar - let's have 2 uiviewcontrollers: home , detail. home tableviewcontroller searchbar @ top. when search, , accede detail viewcontroller, works fine. but, when in navigation bar homecoming home viewcontroller, black screen showed. (neither initial table nor table resulted search !). any adea how resolve ? in advance ! i found ! to detail view, asked segue twice ! removed wrong 1 , works ! ios uitableview uisearchbar

javascript - jquery and ajax file uploader won't work -

javascript - jquery and ajax file uploader won't work - i seek follow sample code of jquery , ajax file uploader i've got error. cannot figure out error because when press submit button, nil happens. please help me error. the controller: <?php class upload extends ci_controller { public function __construct() { parent::__construct(); $this->load->model('files_model'); $this->load->database(); $this->load->helper('url'); } public function index() { $this->load->view('upload'); } public function upload_file() { $status = ""; $msg = ""; $file_element_name = 'userfile'; if (empty($_post['title'])) { $status = "error"; $msg = "please come in title"; } if ($status != "error") { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png|doc|txt'; $config['max_size'] = 1024 * 8; $config['...

html - Add number from divs with jQuery -

html - Add number from divs with jQuery - i have these divs. <div class="prices">11.99</div> <div class="prices">1.99</div> <div id="price">99</div> how can add together numbers divs? the final result must 11.99+1.99+99=112.98 thank you. you can this. class="snippet-code-js lang-js prettyprint-override"> var controls = $("div"); var sum = 0; (var = 0; < controls.length; i++) { var ct = parsefloat($(controls[i]).text()); sum += ct; } alert(sum); class="snippet-code-html lang-html prettyprint-override"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="prices">11.99</div> <div class="prices">1.99</div> <div id="price">99</div> jquery html add

how to access an array of objects in jade, passed through the jade command line -

how to access an array of objects in jade, passed through the jade command line - i can pass array of object through jade command line jade.js -p --obj "[{\"field1\":2,\"field2\":\"valstring/obj2\"},{\"field1\":3,\"field2\":\"valstri 3\"}]" inventaire-all.jade how can access 2 object jade template file ? thanks help if object, utilize file (say input.json) object in json format , give filename input. jade

java - Getting NullPointerException on setting google MAP in Android -

java - Getting NullPointerException on setting google MAP in Android - i'm trying set google map on android have set things on, when seek fragment contain map error log display nullpointerexception error. error due it's not recognize map my xml layout : <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.unchainedappli.spotfragement"> <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.supportmapfragment" android:layout_width="match_parent" android:layout_height="match_parent" /> </framelayout> the oncreate method @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // handle map fragment g...

xaml - EventToCommand missing on MVVM Light -

xaml - EventToCommand missing on MVVM Light - this helpful class seems gone latest mvvm lite build, thought why or how work around it? i'm using mvvmlightlibs.5.0.1.0, there on mvvmlightlibs.4.1.27.0. question not related 1 eventtocommand missing windows phone app environment: vs2013, wp8.0 eventually, found eventtocommand class on galasoft.mvvmlight.platform. guess assembly alter makes sense beingness multi-platform framework. xmlns:command="clr-namespace:galasoft.mvvmlight.command;assembly=galasoft.mvvmlight.platform" <i:interaction.triggers> <i:eventtrigger eventname="tap" > <command:eventtocommand command="{binding path=myvm.mycommand, source={staticresource locator}}" passeventargstocommand="false" commandparameter="{binding}"/> </i:eventtrigger> </...

sql - Using EXCEPT operator on MySql 5.1 version -

sql - Using EXCEPT operator on MySql 5.1 version - i have 5.1 mysql version on server. trying perform query: select file_name words_db word_name=" . $element . " except select file_name files_db display=0 i getting error: error: have error in sql syntax; check manual corresponds mysql server version right syntax utilize near 'except select file_name files_db display=0' @ line 4 can tell me how can perform query in alternative form? thank you, max. as far know mysql not back upwards the except operator. seek instead: select file_name words_db word_name=" . $element . " , file_name not in ( select file_name files_db display=0 ) you utilize either correlated not exists or a left join . don't utilize mysql much can't performs best. mysql sql

elasticsearch - Why am I not able to query by geolocation in elastic search? -

elasticsearch - Why am I not able to query by geolocation in elastic search? - so experimenting elasticsearch , did. 1) added geo_point mapping on index called "test" curl -xpost localhost:9200/test -d '{ "mappings" : { "type1" : { "_source" : { "enabled" : false }, "properties" : { "location" : { "type" : "geo_point", "index" : "not_analyzed" } } } } }' 2) indexed document under test: curl -xput 'localhost:9200/test/type1/1?pretty' -d '{ "location" : { "lat" : 74, "lon" : 90 } }' 3) wrote query geolocation filter this: curl -xpost 'localhost:9200/test2/_search?pretty' -d '{ "filtered" : { "query...

android - inflating layout -

android - inflating layout - i'd accomplish such layout, user got 2 command panels. able switch first sec pressing button , vice versa. already have tried utilize layoutinflater, however, without success :/ the main reason, why doing 2 different layouts is, buttons on same position, i'd prevent mess in 1 layout , create 2 separate command panel layouts. here layouts: main.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <imageview android:layout_width="matc...

jquery - Why doesn't this Javascript code execute sequentially? -

jquery - Why doesn't this Javascript code execute sequentially? - using jquery i'm doing phone call server returns json. have callback defined using .done create callback, doesn't seem behave sequentially. i've got div in html ( <div id="properties"></div> ), , seek fill div table of results: request.done(function(data){ if (data['result'].length == 0) { $("#properties").html("<h3>no results found..</h3>"); } else { $("#properties").html("<table><thead><tr><th>status</th><th>title</th></tr></thead><tbody>"); data['result'].foreach(function(prop){ $("#properties").append("<tr>"); $("#properties").append("<td>prop.status</td>"); $("#properties").append("<td>prop.title...

java - Runtime Error in Async Task -

java - Runtime Error in Async Task - i'm trying build simple programme using asycn task on clicking button loads google home page in webview. have no errors showing in code when click button crashes next error: an error occured while executing doinbackground() java.lang.runtimeexception:java.lang.throwable:a webview method called on thread 'asynctask #1'.all webview methods must called on same thread this mainactivity.java package com.example.asyncts2; import android.app.activity; import android.os.asynctask; import android.os.bundle; import android.view.view; import android.webkit.webview; import android.widget.button; import android.widget.toast; public class mainactivity extends activity { button button1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button1 = (button) findviewbyid(r.id.button1); button1.setonclicklistener(new view.o...

Microsoft Speech API speech segmentation and audio -

Microsoft Speech API speech segmentation and audio - i'm using microsoft speech api speech recognition, , have found straightforward. in add-on the transcribed/recognized text, need capture sound segment correspond text, e.g. if user "i do", need maintain sound record of - there standard way of doing it? found in api illustration - verify.. http://msdn.microsoft.com/en-us/library/system.speech.recognition.recognitionresult.getaudioforwordrange%28v=vs.110%29.aspx speech-recognition speech

Using LIKE in Multi-Value Parameter in Crystal Reports 2011 -

Using LIKE in Multi-Value Parameter in Crystal Reports 2011 - i developing study in crystal reports 2011 has 3 sub-reports pulling info 3 different databases. have multi-value parameter (string) in main study passes input values 3 sub-reports have same multi-value string parameter. sample input values are: p000000030, p000000930, p000001730 the user not want input leading alpha character , preceeding zeroes. want input following: 30, 930, 1730 the sub-report pulls of records if user puts entire string value in next record selection criteria, not work partial strings input: {command.puchase order} in {?pm-?reference} can advise syntax needed pull info in subreport substrings inputs? thanks in advance! thank input guys!! took bit , came next solution: create column in datasource trimmed out desired value --> ltrim(regexp_replace(a."po_num",'p',''),'0') "puchase order2" modified record selecti...

jquery - Dismiss blockUI Via Button -

jquery - Dismiss blockUI Via Button - i trying dismiss modal, generated via blockui. having problem catching click event dismiss method never fires. maybe has run before? here pertinent code presented fiddle function blockuidisplaymessage(title, message) { var msg = '<div id="block-ui-dialog"><img src="/path/to/img.png"/><h2>' + title + '</h2><p>' + message + '</p><p> <input type="button" value="ok" class="btn blue" id="block-ui-dialog-btn"></p></div>'; $.blockui({ message: msg, css: { wdth: '431px', border: '1px solid #000000', padding: '30px' } }); } function blockuidismissmessage() { $.unblockui(); } $('#block-ui-dialog-btn').click(function() { $.unblockui(); }); well, #block-ui-dialog-btn element not exists when seek bind click event. can utilize onclick evenet lik...

c++ - Why does sizeof a reference type give you the sizeof the type? -

c++ - Why does sizeof a reference type give you the sizeof the type? - according standard, in [expr.sizeof] (5.3.3.2) get: when applied reference or reference type, result size of referenced type. this seems go along fact references unspecified [dcl.ref] (8.3.2.4): it unspecified whether or not reference requires storage but seems pretty unusual me have kind of inconsistency within language. regardless of whether or not reference requires storage, wouldn't of import able determine how much size reference uses? seeing these results seems wrong: sizeof(vector<int>) == 24 sizeof(vector<int>*) == 8 sizeof(vector<int>&) == 24 sizeof(reference_wrapper<vector<int>>) == 8 what reasoning behind wanting sizeof(t&) == sizeof(t) definition? the selection arbitrary, , trying justify either alternative lead circular metaphysical arguments. the intent of reference (an alias for) object itself; under reasoning makes sen...

javascript - WebResource with invalid resources -

javascript - WebResource with invalid resources - in our intranet environment, website works well, without problems. same address, accessed outside, have next result @ end of webresource.axd return: /* start */ /* skipped loading 15 invalid resources. */ /* end */ the webresource.axd have content (scripts). error shown @ end. noticed included script microsoftajax.js, no other script loaded. therefore, webresource.axd much smaller supposed and, of course, website not working (many javascript functions not working). works when accessed internally. same server, same webresource request (url). any ideas? thank you! i using telerik radscriptmanager. looks there bug, , reported them. had alter regular asp scriptmanager. alternatively, can utilize enablescriptcombining = false in radscriptmanager. javascript asp.net asp.net-ajax webresource.axd webresource

salesforce - How to get downloadable link for attachment? -

salesforce - How to get downloadable link for attachment? - i uploaded jpeg image account. jpeg image file id 069i0000001dkl8 , can't access via, https://c.na15.content.force.com/servlet/servlet.filedownload?file=069i0000001dkl8 but can acces via, https://c.na15.content.force.com/sfc/servlet.shepherd/version/download/068i0000001hwpn?aspdf=false&operationcontext=chatter is there way can downloadable url attachment in salesforce (using api calls)? or there way can build downloadable url processing fields in api object (sobject)? thanks. technically speaking, dealing contentdocument (069 key prefix) , contentversion (068 key prefix) records rather attachment (00p key prefix). have @ info model content objects: you can utilize soql create query right contentversion contentdocument. resulting id can used create download url. alternatively, binary contents of attachment contentversion straight via api. incidentally, salesforce stackexchange site great...

common table expression - SQL: How to Remove record from CTE if another result set had record for that id -

common table expression - SQL: How to Remove record from CTE if another result set had record for that id - a part can used in service entry , if used service entry part table have record of that. in next part never used in service entry display applicable part scheme default config. when study run, servicedate between 10/1/2014 - 10/2/2014 instrument part number part description revision number date xnumber icq ia ep5 152970 rsh-load platform-arm (spring), 100 icq ia ep6 152970 rsh-load platform-arm (spring), 100 icq ia ep7 152970 rsh-load platform-arm (spring), 100 in next 10/1/2014 - 10/6/2014 part used in service entry scheme 6 , 7 there service date/time include revision number service entry part table , since on scheme 5 not used display default config part table. instrument part number part description revision number date xnumber icq ia ep5 152970 rsh-load platform-arm (sp...

c - Clock replacement algorithm to be replaced with LRU in postgres 8.2.19 .Any ideas? -

c - Clock replacement algorithm to be replaced with LRU in postgres 8.2.19 .Any ideas? - in postgres code, code related alter nowadays in these places ~/src/backend/storage/buffer/buf_init.c ~/src/backend/storage/buffer/bufmgr.c ~/src/backend/storage/buffer/freelist.c i tried alter code in freelist.c has actual clock replacement algorithm logic. can 1 please help me of how proceed replacing clock replacement algorithm logic lru logic. related ideas welcomed! in advance. here part of code of freelist.c volatile bufferdesc * strategygetbuffer(void) { volatile bufferdesc *buf; int trycounter; lwlockacquire(buffreelistlock, lw_exclusive); /* * seek buffer freelist. note freenext fields * considered protected buffreelistlock not * individual buffer spinlocks, it's ok manipulate them without * holding spinlock. */ while (strategycontrol->firstfreebuffer >= 0) { buf = &bufferdescriptors[strategycon...

Chrome Developer Tools CSS lines and stylesheet name not displaying -

Chrome Developer Tools CSS lines and stylesheet name not displaying - in developer tools in google chrome when inspect element in page locally hosted on pc , in styles window stylesheet:line-number not showing. illustration style.css:127 ... what's problem? thanks :) i discovered problem well. folder name on local server contained space. when renamed folder (used hyphen instead of space) stylesheet filename , line numbers came developer tools again. google-chrome

sql server - SSIS package bottleneck inserting records -

sql server - SSIS package bottleneck inserting records - i creating ssis bundle loads info source scheme info warehouse using lookups. here how process set up: load relevant tables staging tables (6 lookup tables , info fact table) for each lookup table utilize lookup component determine if record exists in info warehouse dimension table. if match id dimension, if not match derive match. load fact table ids dimensions , 2 or 3 other pieces of info flowed through source. not complex. lookup tables have anywhere 10 - 50 records. have limited source info 10,000 records in order bundle finish in reasonable amount of time. takes 20 minutes load 10,000 records. the time line in messages shows: 11:13:28 - bundle started 11:13:36 - lookups prepared , ready 11:32:33 - final commit info insertion in 'target - fact insert new record has ended' 11:32:34 - bundle ended where can see why took 19 minutes insert 10,000 records? suggestions on can dif...

javascript - webgl not using the entire canvas space -

javascript - webgl not using the entire canvas space - i have spinning 3d letter "f". reason, "f" not drawn in top 20% of canvas. see jsfiddle: http://jsfiddle.net/c948jos0/. the render function: var rx = 0; var ry = 0; gl.enable(gl.cull_face); gl.enable(gl.depth_test); gl.canvas.width = 400; gl.canvas.height = 200; gl.clearcolor(0.5,0.5,0.5,1.0); function render(){ rx += math.pi/64; ry += math.pi/128; var projection = make2dprojection(gl.canvas.clientwidth,gl.canvas.clientheight,400); var translation = maketranslation(200,50,0); var rotx = makexrotation(rx); var roty = makeyrotation(ry); var mat = matrixmultiply(rotx,roty); mat = matrixmultiply(mat,translation); mat = matrixmultiply(mat,projection); uniforms["u_matrix"](new float32array(mat)); gl.clear(gl.color_buffer_bit | gl.depth_buffer_bit); gl.drawarrays(gl.triangles,0, 16*6); settimeout(render,33); } render(); the matrices: f...

chrome extension auto-update strategy -

chrome extension auto-update strategy - i want update chrome extensions automatically or via command line. these archived using autoupdating, hosted extension. autoupdating not supported extension hosted in chrome web store. manual updating through web portal tiring. it possible utilize straight linking js file external web site, not work offline utilize case. add together appcache background page, work? an desperate approach store js files in indexeddb , inject it. is there improve solution? google-chrome-extension auto-update chrome-web-store

javascript - Overlapping markers/labels in Google Map API v3 -

javascript - Overlapping markers/labels in Google Map API v3 - i have google map several markers/labels placed very close eachother. close, if zoom-level @ level labels overlapping. in order able read labels when map loads , when zoom-level changes, want place marker offset of point line drawn it. i have tried implement "overlappingmarkerspiderfier" george mackerron, according author himself, can't done using code (due fact code tied "onclick" listener , can't executed during loading of map or alter of zoom-level) i hope above description understandable dispite fact english language not native language. javascript google-maps google-maps-api-3

Julia Array Concatenation dimension mismatch -

Julia Array Concatenation dimension mismatch - i have dimensional mismatch problem when using y =[x,a] concatenate 2 arrays: x = reshape(1:16, 4, 4) x = mean((x ./ mean(x,1)),2)' = zeros(3) println(x) y =[x,a] print (y) if seek combining them error: mismatch in dimension 2 both variables x , appear in same dimensions in console: println(x) [0.7307313376278893 0.9102437792092966 1.0897562207907034 1.2692686623721108] println(a) [0.0,0.0,0.0] but x in sec dimension. there way combine arrays can in dimension 1? y = [0.7307313376278893 0.9102437792092966 1.0897562207907034 1.2692686623721108, 0.0,0.0,0.0] the problem transposing x (putting ' @ end of line) end following: julia> size(x) (1,4) julia> size(a) (3,) so when seek y=[x,a] julia rightfully complains cannot concatenate them. there (at least) 2 solutions: 1) don't transpose x: x = reshape(1:16, 4, 4) x = mean((x ./ mean(x,1)),2) = zeros(3) println(x) ...

python - How to return List in a single line -

python - How to return List in a single line - i trying list of integers single line without spaces, able below code import sys l = [1, 2, 3] in list: b = sys.stdout.write(str(a)) homecoming int(b) but above code gives me out set of 1231 , want output 123 does 1 have thought on how this? if you're trying homecoming string of list items concatenated together, code should be: l = [1, 2, 3] homecoming ''.join([str(item) item in l]) no need importing sys or writing stdout. if output needs int, utilize return int(''.join([str(item) item in l])) i know looks little weird cast ints strings, ints, that's have if want concatenate everything. python python-3.x

vba - Multi Macro Communication -

vba - Multi Macro Communication - i attempting self-teach myself great world of macro coding in vba have come across stumbling block when trying process 3 macros ideally process 1 code seems far complicated me @ stage. what need convert info date format mm/dd/yyyy uk date format dd.mm.yyyy , changing / . @ same time ideally overwriting original data. this have in separate modules: sub fixformat() 'display message alternative if date formats 'included in info msgbox "us date formats included", vbquestion + vbyesno, "addresses" if response = yes msgbox "delimit process needed", vbokonly, "addresses" if response = no msgbox "end", vbokonly end end sub and sub fixdates() dim cell range dim lastrow long lastrow = range("a" & rows.count).end(xlup).row each cell in range("a1:a" & lastrow) if instr(cell.value, ".") <> 0 cell.value = regexreplace...

android - How to filter ACTION_SEND intent with only facebook and facebook messenger and whatsapp -

android - How to filter ACTION_SEND intent with only facebook and facebook messenger and whatsapp - how can filter out specific apps when using action_send intent? question has been asked in various ways, haven't been able gather solution based on answers given. can help. provide ability share within app. picture! http://i.imgur.com/6yeufgv.png as have no command on app available, need hardode dialog yourself, , depending on selection of user, launch action_send intent specifically. explanations website : http://clickclickclack.wordpress.com/2012/01/03/intercepting-androids-action_send-intents/ create activity "shareactivity" displaying layout listview. implement adapter follow : public class shareintentlistadapter extends arrayadapter { activity context; object[] items; boolean[] arrows; int layoutid; public shareintentlistadapter(activity context, int layoutid, object[] items) { super(context, layoutid, items); ...

Editing AJAX sourced data in the popup window (jquery-datatables-editable) -

Editing AJAX sourced data in the popup window (jquery-datatables-editable) - datatables editable plug-in has sample editing info in pop-up window. can't seem able working when info sourced ajax (using sajaxsource property). in demo edit link hard-coded in html, when info dynamically loaded cannot hard-code anything. can please explain how or give me pointer help? thanks! datatables jquery-datatables jquery-datatables-editor datatables-1.10

java - Unmarshalling in jaxb for enum type -

java - Unmarshalling in jaxb for enum type - i using jaxb marshalling & unmarshalling. xml want info unmarshalled java object having enum attribute 1 shown below constructor, getter & setter enum field. public enum myenum { p_e("p e") private string type; } i understand other stackoverflow questions jaxb not require setters setting value. in xml if give value "p_e" works well. there way utilize "p e" , set enum value in object?. without using setter, how jaxb work? you can utilize @xmlenumvalue annotation alter xml representation. java enums jaxb

c# - Passing session variable from one page to another -

c# - Passing session variable from one page to another - i've done php while back, , want c#. think might on right track going wrong along way. what have "create order" page, contains basket of items user purchase. on page, can search products name or sku, , grid view of results displayed if typed in valid. can navigate add/update page can either add together new product basket or edit/update 1 there. takes them basket page. on "create order" page, setting session variable cart id based on whether cart id found in url query string: protected void createsessionvariable() { string session = ""; if (request.querystring["cartid"] != "" & request.querystring["cartid"] != null) { session = request.querystring["cartid"]; session["cartvalue"] = session; } else session["cartvalue"] = ""; }...

Rails: Touch user column when saving separate db model -

Rails: Touch user column when saving separate db model - what i'd simple. like: # == schema info # # table name: tags # # id :integer not null, primary key # tagname :string(255) # user_id :integer class tag < activerecord::base belongs_to :user # when tag gets saved, update right user column on_save_do ->{ user.find(user_id).current_tag = user.find(user_id).current_tag || id } end # == schema info # # table name: users # # id :integer not null, primary key # current_tag :integer class user < activerecord::base has_many :tags, autosave: true, dependent: :destroy end so need create sure first time tag saved user saves current tag id users current_tag column tag_id. class tag < activerecord::base belongs_to :user after_save :update_user_tag private def update_user_tag user.current_tag = id user.save if ...

java - Send back to MainActivity after logged in to Facebook -

java - Send back to MainActivity after logged in to Facebook - i followed facebook tutorial create loginbutton app, , works login, have questions need help guys. i have 1 activity & 1 fragment. when start app, see png-image logo, plus 'login facebook' button. when press login button, sent facebook auth, , after log in send mainactivity again. now mainactivity have logo , facebook button says 'log out'. fine, question is: what best thing after logged in?? create new class sent after login, or send mainactivity? real programmer after auth? and if improve send mainactivity, how can remove logo png image after login? mean, nice have before login, after login, image should gone. same thing facebook logout button, how remove it, or atleast set somewhere else? though create actionbar logout button there. this core utilize activity & fragment. so, should new class send user after login, or should send user mack activity, , if yes, how remove logo/...

php - Avoiding SQL injection in delete API function -

php - Avoiding SQL injection in delete API function - i'm trying build android app, , part of app involves crud options on database need synced server. have cru bits sorted, trying deletes in such way avoid sql injection. i have used prepared statements other queries, wondering whether next method doesn't safe: i have defined list of tables on delete query valid, along list of primary keys on tables can nowadays in tablekey field. utilize prepared statement using value provided in tablekeyvalue field, along restricting operations acting on individual user's id. is methodology safe sql injection point of view, or should set specific api endpoints each of tables deleted from, , pass through id value used in traditional prepared statement? ($i = 0; $i < count($deletearray); $i++) { if (in_array($deletearray[$i]['tablename'], $this->table_array) && in_array($deletearray[$i]['tablekey'], $this->key_array)) { ...

c# - DapperExtensions produces "Invalid object name" on insert operation -

c# - DapperExtensions produces "Invalid object name" on insert operation - i'm next simple insert operation illustration @ https://github.com/tmsmith/dapper-extensions#simple-insert-operation public class org { public int id { get; set; } public string name { get; set; } } sqlconnection conn = new sqlconnection("..."); conn.open(); org org = new org() { name = "just testing" }; int id = conn.insert(org); conn.close(); this gives me system.data.sqlclient.sqlexception: invalid object name 'org'. what doing wrong here? table exists , generated ef code first standard dbcontext subclass containing public dbset<org> orgs { get; set; } c# sql-server entity-framework dapper dapper-extensions

Multidimensional arrays From C to Swift -

Multidimensional arrays From C to Swift - in c have next multidimensional array: unsigned wins[8][3] = {{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}}; to access elements utilize next code: int i; for(i = 0; < 8; ++i) { unsigned *positions; positions = wins[i]; unsigned pos0 = positions[0]; unsigned pos1 = positions[1]; unsigned pos2 = positions[2]; if(arraypassedin[pos0] != 0 && arraypassedin[pos0] == arraypassedin[pos1] && arraypassedin[pos0] == arraypassedin[pos2]) { // here } i know in swift can like: var array = array<array<int>>() but i'm not sure if produces same result accessing elements. you can create multi-dimentsional array in pretty similar manner c code: var wins = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]] the swift code utilize same way c code pretty similar; main difference using for-in loop instead of stand...

mysql triggers syntax error -

mysql triggers syntax error - i having problem creating mysql trigger. trigger uses replace, when row replaced, reads row , saves info in table. if new row inserted tracking table, info not saved in other table, row didn't exist. need save tracking row if exists. drop trigger if exists savetracking; create trigger savetracking before replace on 'orderstest.tracking' each row begin declare orderid integer; if new.invno != '' set orderid = (select orderid order_header invno = new.invno); insert comments (id, date_time, type, comments) values (orderid, sysdate(), \"o\", \"previous tracking: usps - old.trackno\"); endif; end; this error get: #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax utilize near 'replace on 'orderstest.tracking' each row begin declare orderid integer' @ line 1 i using phpmyadmin seek , add together trigger. mysql vers...

c++ - Why does this compile without errors? (Returning a type that doesn't subclass the stated returned type) -

c++ - Why does this compile without errors? (Returning a type that doesn't subclass the stated returned type) - i've inherited std::list allow 'psuedo random access' [] operator. #include <list> template <typename t> class rlist : public std::list<t> { t& operator[](int index){ typename std::list<t>::iterator iterator; int pos; (iterator = this->begin(), pos = 0; iterator != this->end(); iterator++, pos++) if (pos == index) homecoming *iterator; homecoming inexistent_element(); } class inexistent_element { }; }; inexistent_element not yet inherit t , shouldn't compile. compiles. i'm pretty sure c++ shouldn't allow me pass non-const reference object created inline. i'm using code::blocks ide mingw gcc compiler. i'd know why compiles. the fellow member function operator[] never instantiated you. how know that? it...

mysql - codeigniter join with same columns -

mysql - codeigniter join with same columns - i working on educational project came across simple logic. have 2 table month , semester_type. bellow schema , data; month table month_id month_name month_value lupdate 1 jan 1 2 feb 2 3 march 3 4 apr 4 5 may 5 6 june 6 7 july 7 8 august 8 9 september 9 10 oct 10 11 nov 11 12 dec 12 here semester_type table; semester_type_id semester_type_name start_month end_month 1 fall 8 12 2 summer 1 4 and here output want; semester name start month end month fall august dec summer jan apr i confused inner joining month_id start_month , end_month columns in both tables. can help me codeigniter qu...

Akka actors/scala - single onSuccess for multiple asks -

Akka actors/scala - single onSuccess for multiple asks - i have chain of akka actors a --> b --> c actor 'asks' actor b in turn 'asks' actor c. actor needs wait till actor c has finished processing. b lean layer , nil more passing(asking) message c , returns future a. b { case msgfroma => sender ! c ? msgfroma } hence getting future[any]. the way handling request using nested maps actorreffactory.actorof(props[a]) ? msga map { resp => // type cast future , utilize map finish processing. resp.asinstanceof[future[_]] map { case success => // finish processing case failure(exc) => // log error this works(i.e final processing happens when actor c has finished processing ) needless looks horrible. tried using flatmaps not create work. ideas create :) thanks a more proper way: in a : val f: future[mytype] = (b ? msg).mapto[...

Using dc.js with node.js -

Using dc.js with node.js - is possible utilize dc.js node.js, , if how? provide example, it's hard see how start on this, , no working examples seem available online. in short, yes. have implemented total fledged app using nodejs , dc while document store mongo. nodejs server used fetching info mongo db , serving api. dc.js uses info rendering charts. i write blog post , post in couple of days. in meantime allow me know if have more queries. updated: here link blog post.do share if find useful. https://anmolkoul.wordpress.com/2015/06/05/interactive-data-visualization-using-d3-js-dc-js-nodejs-and-mongodb/ node.js dc.js

Out of index C/C++ -

Out of index C/C++ - a typical declaration array in c/c++ is: type name [elements]; where type valid type (such int, float...), name valid identifier , elements field (which enclosed in square brackets []), specifies length of array in terms of number of elements. so declare array of int have 2 elements int a[2]; a[3] =4; why not throw exception? out of bounds checking used higher level language java. in c/c++ not done default. gives little performance nail check bounds of array , hence c rationale have manually in case need offer best possible performance. c++ stl containers vector back upwards at() operation perform bound-checking , since can overload []-operator can enable bound-checks array-style access. if array raw pointer statement array[i] comes downwards in c/c++: *(array + i) which simple add-on of address + offset. next statements equivalent: *(array + i), *(i + array), array[i], i[array] what happens internally take address...

c - Linux UDP sendto "Bad address" error in local -

c - Linux UDP sendto "Bad address" error in local - i trying code udp 2 thread. first init udp sockets int fdpipe[2]; //for sockets if ((fdpipe[0] = socket(af_inet, sock_dgram, 0)) < 0) { perror("cannot create socket"); assert(null); } struct sockaddr_in readaddr; memset((char *)&readaddr, 0, sizeof(readaddr)); readaddr.sin_family = af_inet; readaddr.sin_addr.s_addr = htonl(inaddr_any); readaddr.sin_port = htons(10000); if (bind(fdpipe[0], (struct sockaddr *)&readaddr, sizeof(readaddr)) < 0) { perror("bind failed"); assert(null); } if ((fdpipe[1] = socket(af_inet, sock_dgram, 0)) < 0) { perror("cannot create socket"); assert(null); } struct sockaddr_in writeaddr; memset((char *)&writeaddr, 0, sizeof(writeaddr)); writeaddr.sin_family = af_inet; writeaddr.sin_addr.s_addr = htonl(inaddr_any); writeaddr.sin_port = htons(10101); if (bind(fdpipe[1], (struct sockaddr *)&writeaddr, sizeo...

c++ - Neopixel arduino fading from colour to colour using a Sparkcore -

c++ - Neopixel arduino fading from colour to colour using a Sparkcore - this question follow question asked here answered. i have next function: moticolor startcolor; moticolor endcolor; void setup() { // begin strip. strip.begin(); // initialize pixels 'off'. strip.show(); serial1.begin(9600); startcolor = moticolor(0, 0, 0); endcolor = moticolor(0, 0, 0); } void loop () { } int tinkersetcolour(string command) { strip.show(); int commaindex = command.indexof(','); int secondcommaindex = command.indexof(',', commaindex+1); int lastcommaindex = command.lastindexof(','); string reddish = command.substring(0, commaindex); string grn = command.substring(commaindex+1, secondcommaindex); string blu = command.substring(lastcommaindex+1); startcolor = moticolor(red.toint(), grn.toint(), blu.toint()); int16_t reddiff = endcolor.getr() - startcolor.getr(); int16_t greendiff =...

excel - Find 'NaN' characters in a cell array in MATLAB -

excel - Find 'NaN' characters in a cell array in MATLAB - i'm searching nan 's in cell array imported excel file . after importing excel file cell array , when double click on nan , in files have char , in other imported excel files have double cells storing nan . double version don't have problem, utilize function : out = (cellfun(@(x) any(isnan(x)),cell_array)) but if utilize function char nan s, can't find nan . out values zero. what problem , how can solve it? excel matlab nan cell-array

javascript - zoom a Highcharts chart programatically -

javascript - zoom a Highcharts chart programatically - in this jsfiddle demo have 2 highcharts line charts. when 1 of charts zoomed, other chart should zoom in on same area. code is xaxis: { events: { aftersetextremes: function (event) { var index = document.getelementbyid('container2').dataset.highchartschart; var chartpartner = highcharts.charts[index]; chartpartner.xaxis[0].setextremes(event.min, event.max); chartpartner.showresetzoom(); } }, }, wherein container2 id of dom element other chart rendered to. behaviour working, there couple of little problems: after zooming-in, grayness shading area used select area zoom doesn't disappear in firefox (i haven't tested other browsers) the "reset zoom" button doesn't appear in other chart despite fact phone call chartpartner.showresetzoom(); your problem called setextremes in infinite loop, because told "aft...

Preventing axis from updating on camera move - mayavi python -

Preventing axis from updating on camera move - mayavi python - i found flag command set allowed me prevent axes of scene updating on photographic camera move. can't find again. i've been digging through documentation not having luck. to farther explain, don't want axes update positioning shown in these 2 images: before move: after move: not sure understand need maybe can try: axes.axes.fly_mode = 'none' for example: from mayavi import mlab myfig = mlab.figure() myplot = mlab.plot3d([0,1,2],[0,1,2],[0,1,1]) myaxes = mlab.axes() myaxes.axes.fly_mode = 'none' mlab.show() python axis-labels mayavi mlab

r - verify the central limit theorem of chi sq distribution -

r - verify the central limit theorem of chi sq distribution - hi have question on verifying central limit theorem using r. the question utilize info generated different statistical distribution n see if sample means follow normal distribution . i using code x <- replicate(20, rchisq(20,20)) x_bar <- colmeans(x) hist(x_bar) and increasing number of samples 5 in each interval. ie. 20, 25, 30, 25, ... using ks test shapiro test available in r test normality. question should first define population of 1000 first take different samples of size 20 , running tests or possible using codes have written above? because read defnition clt takes different combination of sample size n population create population of means. any help appreciated! give thanks ! anyone?!!??? update: saw video on utube verify clt uses rnorm n not rchisq. pop_size<-1000 sample_size<-15 repeated_sample<-100 x<-rchisq(20,20) par(mfrow=c(2,2)) (i in 1:repeated_sample){ temp_...

opengl - Linking GLFW in CodeBlocks -

opengl - Linking GLFW in CodeBlocks - codeblocks' glfw project outdated , works glfw 2.7. using latest version, 3.0.4, , trying link in codeblocks statically (i hope using right terminology). happy if told me how step step. create empty project if possible , manually. this code trying run: #include <glfw/glfw3.h> int main(void) { glfwwindow* window; /* initialize library */ if (!glfwinit()) homecoming -1; /* create windowed mode window , opengl context */ window = glfwcreatewindow(640, 480, "hello world", null, null); if (!window) { glfwterminate(); homecoming -1; } /* create window's context current */ glfwmakecontextcurrent(window); /* loop until user closes window */ while (!glfwwindowshouldclose(window)) { /* render here */ /* swap front end , buffers */ glfwswapbuffers(window); /* poll , process events */ glfwpollevents()...