Posts

Showing posts from March, 2014

javascript - Assigning method to variable and problems with this -

i have piece of code: function a(){ this.count = 0; } a.prototype.inc = function(){ this.count++; } var = new a(); a.inc(); var f = a.inc; f(); the last line deosn't work expected, because this object of type window . something, shouldn't - assign methods variables, in case make use of this ? when want use method argument, should omit fn(a.inc) , use regular function, , use insted following? fn(function(){ a.inc(); }); this famous "lost binding" of javascript. you have do: f = a.inc.bind(a); because if say f = a.inc; f(); then when f running, this not bound a . bound global object, window . the rule is, if a.fn() , inside of function, this bound a , if fn() or g() , when g === a.fn , inside of function, this bound global object, window . to bind this explicitly a when function invoked, have use a.inc.bind(a) if don't want use bind want use own function, that's fine too. do: function fn() { a.in

asp.net web api - Using Forms Authentication with WebAPI when the client is in a different domain? -

related question: authentication in .net web api using mvc formsauthentication i have client application lives outside of webapi solution's domain (right 2 different solutions on localhost - 1 on port x, other on port y). i'm attempting use forms authentication code this: if (websecurity.login(model.username, model.password, persistcookie: true)) { var response = request.createresponse(httpstatuscode.ok, "logged in successfully"); return response; } in postman works, using client / js application, cookie not saved, user never authenticated. see _requestverificationtoken, never .aspxauth token. a requirement of application use forms auth setting cookies using websecurity. possible when client , server on different domains? if there's else can provide make issue clearer, please let me know. assuming using cors. default, cookies not enabled cors. in jquery, need set xhrfields: {

PowerShell Setting up a folder to open in -

Image
my teacher gave me instruction : "to set-up default folder powershell open in, right click powershell icon in tool tray , select properties. in properties dialog box , in start in: text box enter path new directory “c:\users\administrator\myscripts”, click ok." however when go properties tab not see talking :( . this see: how i wants? your teacher asking change properties of executable . looking @ powershell console properties. as can partially see mine located: %systemroot%\system32\windowspowershell\v1.0\powershell.exe

unix - Checking if a returned number is an integer in GP/Pari? -

this first time using gp/pari , having trouble completing question. i asked print if return of function 'wq()' integer. there function can determine if number passed in integer? if not how go checking? find syntax difficult , can't find information online it. i have included have far, appreciated. wq(x) = { [(x-1)! + 1]/x } test(r,s) = { (i=r, s, if(isinteger(wq(i)), print("integer"), print("not interger"))); } if understand correctly want check if (x-1)! + 1 multiple of x . can modulo operation: test(r,s) = { (i=r, s, if(mod((i - 1)! + 1, i) == 0, print("integer"), print("not integer"))); }

javascript - Issue with click event in Reactjs -

this going simple. having hard time figuring out wrong how react component written. here component code. import react, { component, proptypes } 'react'; import styles './menu.css'; import submenu './submenu'; import classnames 'classnames/bind'; let cx = classnames.bind(styles); export default class menu extends component{ static proptypes ={ menudata:proptypes.array.isrequired }; constructor(props){ super(props); this.state = {menuopenedlabel:""}; }; menuclick(label){ this.state.menuopenedlabel = label; }; render(){ let menus = this.props.menudata.map(function(menuitem){ let handleclick = this.menuclick.bind(this,menuitem.label); return (<li key={menuitem.label}> <a onclick={handleclick}>{menuitem.label}</a> <submenu submenu={menuitem.submenu} isvisible={this.state.menuopenedlabel === menuitem.label}/> </li>); }); return (<nav> <ul classname={styles.menu}>{(menus)}&

python - Pygame 2d tile scrolling edges don't load -

Image
im trying make 2d game in pygame kinda works pokemon. ive gotten stuck on problem dont know how solve. when move character scroll map instead player stays centered. i've created "animation" offsetting distance 2 pixels @ time instead of moving full tile size smooth movemen. problem have when move, screen doesn't load new tiles in edges i'm moving towards edges end white space until i've completed full animation. i'll link code , can me :) tilesize = 32 map_width = 25 map_height = 25 class player(pygame.sprite.sprite): def __init__(self, color, width, height): # call parent class (sprite) constructor super().__init__() self.name = "player" self.width = width self.height = height self.image = pygame.surface([width, height]) self.image.fill(color) self.rect = self.image.get_rect() self.rect.x = int(tilesize * (map_width / 2)) - tilesize / 2 self.rect.y = in

How to locate the fonts being used by my Java Swing app on the system? -

Image
i noticed fonts different when run java swing app netbeans , when run jar file c: drive on windows 7. i told fonts used in jars apps come system, different fonts when run netbeans, keep app consistent ide , user perspective, how locate fonts being loaded app netbeans can copy them app , package them part of jar app, doable ? if after copy them app, how load them inside app ? here code , images : import java.awt.*; import java.awt.event.windowadapter; import java.awt.event.windowevent; import javax.swing.*; public class test_jpanel extends jpanel { public static final long serialversionuid=26362862l; static dimension screen_size=toolkit.getdefaulttoolkit().getscreensize(); thread empty_jpanel_thread; public test_jpanel() { setpreferredsize(new dimension(300,600)); string table="<html>\n"+ " <center><br>\n" +"test table<p>\n" +" <table border=

My switch statement is not running (It was working yesterday but IDK what happened) JAVA -

i dont know did hen run main program not going through switch statement. working last night , haven't changed in anyway added print statement debugging purposes. apart of pos system have class assignment. package multibuy; import static pos.pos_system.nongstvodka; import static pos.pos_system.price_format; import static pos.pos_system.vodka; import static pos.pos_system.btncancelprevious; import static pos.pos_system.npreviousprice; import static pos.pos_system.ntotal; import static pos.pos_system.strpreviousdrink; import static pos.pos_system.txtbill; import static pos.pos_system.spaces; public class multibuy { public static int clicked; public static double discountamt = 0.05; public static double discount_price_vodka = 0.385; public static double newvodkaprice; public static void multibuy(){ pos.pos_system.btnvodkapressed = true; system.out.println("no cases ran"); switch(c

node.js - Issue with re-join same room after reconnect SocketIO -

i'm trying understand why following code doesn't work reason. want same client able rejoin same room, somehow when print list of clients in room after client reconnect, client shows up, rests not there??? client var id=null, socket = null; var publickey = null; var first = math.random().tostring(36).substring(2,8); var last = math.random().tostring(36).substring(2,8); $('#bt1').click(function(){ socket = io(); socket.on('connect',function(){ addtext('connect server. first-last '+ first +' '+last); }); socket.on('disconnect',function(data){ addtext('disconnect server'); }); socket.on('verifyid_1',function(data){ id = data.id; socket.emit('verifyid_2',{id:id,publickey:publickey}) addtext('clientid '+id); }); socket.on('gamecreated',function(data){ publickey = data.publickey; addtext('publick

objective c - webViewDidFinishLoad not being called with loadHTMLString -

Image
so loads when app launches nsstring *youtubevideohtml = [nsstring stringwithformat:@"<html><head>" "<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 200\"/></head>" "<body style=\"background:#fffff;margin-top:0px;margin-left:0px\">" "<div><object width=\"320\" height=\"200\">" "<param name=\"wmode\" value=\"transparent\"></param>" "<embed src=\"http://www.youtube.com/v/%@&app=youtube_gdata\"" "type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"320\" height=\"200\"></embed>" "</object></div></body></html>", [[nsuserdefaults standarduserdefaults] objectforkey:@"detailvideourl"]]; [self.webview loadhtmlstring:youtubevideohtml bas

c - 'Empty tree' function causing program to crash -

i have empty_tree() function returns true value if tree empty , returns false if not. bool empty_tree(avl self) { if (self == null) { return true; } else { return false; } } it exists program easier understand without comments. now, works fine everywhere else in program. when try , use in insert function in place of working: if(self == null) my program crash. isn't big deal , using 'if (self==null) suffice, wondering if had ideas why cause program crash. said, it's not extremely important won't bother including more code, if had guesses, i'd appreciate hearing thoughts. edit: upon request, here's section works: if (self == null) { self = (avl)malloc(sizeof(struct avlnode)); self->student_id = id; self->left = self->right = null; } and here's code will, when changed this, crash program: if (!empty_tree(self)) { self = (avl)malloc(sizeof(struct avl

css - How to change the colour of the label of md-input-container label after a text is inserted -

how change colour of md-input-container label after contains input? don't want grey, because makes it's greyed out. example, want change colour of label "description" after/when input field contains input. have tried modifying md-input-container label in css using code doesn't work : md-input-container.md-default-theme label, md-input-container.md-default-theme .md-placeholder { color: #fdfe67 !important; } here html: <div ng-app="myapp" ng-controller="democtrl" layout="column" ng-cloak="" class="md-inline-form inputdemobasicusage"> <md-content layout-padding=""> <div> <form name="userform"> <md-input-container class="md-block"> <label>input-autofocus</label> <input ng-model="user.firstname" type="text" autofocus> </md-input-container>

foreach - Parallel query of SQLite database in R -

i have large database (~100gb) need pull every entry, perform comparisons on it, , store results of comparisons. have attempted run parallel queries within single r sessions without success. can run multiple r sessions @ once looking better approach. here attempted: library(rsqlite) library(data.table) library(foreach) library(domc) #--------- # setup #--------- #connect db db <- dbconnect(sqlite(), dbname="genes_drug_combos.sqlite") #--------- # query #--------- # 856086 combos = 1309 * 109 * 6 registerdomc(8) #i run 6 seperate r sessions (one each i) res_list <- foreach(i=1:6) %dopar% { <- i*109-108 b <- i*109 pb <- txtprogressbar(min=a, max=b, style=3) res <- list() (j in a:b) { #get preds drug combos statement <- paste("select * combo_tstats rowid between", (j*1309)-1308, "and", j*1309) combo_preds <- dbgetquery(db, statement) #here stuff result returned query combo_names <

python - Problems with Tkinter "autocomplete" Entry widget -

i have been looking way add autocompletion tkinter ttk.entry widget. stumbled website suggested this solution . reading robb's answer, able make work regardless of case. kind of usage looking (adding new item sqlite database while getting autocompletion previous records), there weird pressing key. first version of code tried (from this link , ian weisser) delete character everytime user pressed . , version on stackoverflow had stripped lines of code catched <backspace>, <left>, <right>, <up>, <down> keystrokes, think while typing, if user presses left, autocompletion should suspended, deleting selected text after cursor position. so, how can change code user may enter text , go few characters correct misspelling, without deleting text? i have edited code, based on 2 sources and, me, think works better: def handle_keyrelease(self, event): """event handler keyrelease event on widget""" if event

html - Having an issue with iPad display -

i having problem our site not displaying css while on ipads. here have done far: works fine on mobile. in addition when use browser console view ipad works fine , when use site view page ipad works fine however on physical ipad none of styling kicks in , cannot figure out why. appreciated. we using html include css scripts - issue? the site is: www.roburir.com/index.html (we working on getting rid of index.html displaying). you using html imports load content including header content, has very little browser support . use php include import stuff, or normal css links have worked fine decades. :)

android - Can I pass Surface between Activities? -

i researched , people saying cannot pass view between activities because of different context, i saw android source code of surface implements parcelable. mean can pass surface between activities? yes if activities in same process. why need manage surface yourself? surface activity has been set system, can not set surface again.

python: To display a youtube video in the mac terminal -

Image
i know how use ipython embed youtube video in notebook. from ipython.display import youtubevideo youtubevideo('1j_hxd4iln8') see live example here: http://nbviewer.ipython.org/github/ipython/ipython/blob/1.x/examples/notebooks/part%205%20-%20rich%20display%20system.ipynb#video but when i'm running code in mac terminal isn't displaying in terminal. please see image below. i want display video terminal or display in new window. thank time , consideration. ipython.display work inside ipython not using.

python - Creating a 2 x 2 matrix and finding its inverse -

class multidimensionalarray: def __init__(self, numrows, numcolumns): self.r = numrows self.c = numcolumns self.array = [[(x+3*y) x in range(self.r)] y in range(self.c)] self.inverse = [[]] def modifyitem(self, row, column, item): self.array[row][column] = item def getitem(self, row, column): print self.array[row][column] return self.array[row][column] def showarray(self): print self.array def changesize(self, rows, columns): self.r = rows self.c = columns self.array = [[(x+3*y) x in range(self.r)] y in range(self.c)] def getsize(self): print [self.r, self.c] return [self.r, self.c] def getinverse(self): if ((self.r == 2) , (self.c == 2)): = self.array[0][0] b = self.array[0][1] c = self.array[1][0] d = self.array[1][1] l in self.array: item in l: item = int(item) self.inverse[0][0] = d self.inverse[0][1] = b * (-1)

sql - CASE with Join | Query Optimization -

i need optmizing query, it's running on preview mode when import report, report gets failing select su4.user_value codice_skoff, case when (su1r.user_id = 'a' , su4.user_value = '9') 'testa' when (su1r.user_id = 'b' , su4.user_value = '10') 'testb' when (su1r.user_id = 'c' , su4.user_value = '11') 'testc' when (su1r.user_id = 'd' , su4.user_value = '12') 'testd' else 'none' end i think it's because of case , turns report slow , gets failing message after from have several left outer join thanks in advance

javascript - Customize website UI as a user -

i want create alternative ui awful website need use everyday, , eyes bleeding. so, first try create html document , embed site via iframe , use jquery css modify ui. <iframe src="site-to-modify"> but cannot access site dom security reasons. way without using plugins stylish ( https://addons.mozilla.org/es/firefox/addon/stylish/ ) using html+css+js, , frameworks based on those. possible? :d as user93 said, you're going face cors issues. if don't want use stylish or want more fine-grained control, best option (assuming there's no api can use) write server scrapes website information , serves json, or regular html.

lua - How can I remove all spawned objects from the screen? -

i'm trying make simple dodging game includes pickup falls top of screen: "wplaser" when player touches pickup, want of spawned projectiles ("default") on screen removed (is possible?) the issue want projectiles continue spawning after pickup has been picked-up here of code reference: local composer = require("composer") local widget = require("widget") local scene = composer.newscene() local physics = require( "physics" ) -- using physics collision detections physics.start() physics.setgravity( 0, 0 ) -- object group removal local objectgroup = display.newgroup() -- set variables _w = display.contentwidth; -- width of screen _h = display.contentheight; -- height of screen function scene:create( event ) local scenegroup = self.view here projectiles want removed when player touches pickup: -- projectiles local numberdefault = 1 --local variable; amount can changed local function cleardefault( thisdefau

swift - iOS button title color won't change -

i'm creating uibutton dynamically following code creates per specified style. let frame = cgrect(x: 10, y: 6, width: 60, height: 30 ) let button = uibutton(frame: frame) button.settitlecolor(uicolor.blackcolor(), forstate: uicontrolstate.normal) button.backgroundcolor = uicolor.whitecolor() button.addtarget(self, action: "filterbycategory:", forcontrolevents: uicontrolevents.touchupinside) self.categoryscrollview.addsubview(button) with button, want toggle style when tapped. following code changes background color not title color. idea why title color won't change? func filterbycategory(sender:uibutton) { if sender.backgroundcolor != uicolor.blackcolor() { sender.settitlecolor(uicolor.whitecolor(), forstate: uicontrolstate.selected) sender.backgroundcolor = uicolor.blackcolor() } else { sender.settitlecolor(uicolor.blackcolor(), forstate: uicontrolstate.normal) sender.backgroundcolor = uicolor.whitecolor() }

How to compare a array with another array stdclassobject and access it key in php codeigniter -

i using php codeigniter. when did print_r , got following: array ( [0] => stdclass object ( [username] => fun [usercode] => 6 [groupcode] => 1 [groupname] => master [menucode] => 0 [menuname] => [admin] => 0 ) [1] => stdclass object ( [username] => fun [usercode] => 6 [groupcode] => 1 [groupname] => master [menucode] => 1 [menuname] => item master [admin] => 0 ) ) in hands have set of array, array ( [0] => billing report [1] => waiterwise report [2] => admin [3] => user master [4] => user rights [5] => close session [6] => close day ) now want compare group name in above 2 array , want key result. try $result_array = array(); foreach($codeigniter_array $k=>$r) { foreach($r $k1=>$r1) { if(in_array($r1, $group_array)) {

javascript - Error handling over websockets a design dessision -

im building webapp has 2 clear use cases. traditional client request data server. client request stream server after wich server starts pushing data client. currently im implementing both 1 , 2 using json message passing on websocket. has proven hard since need handcode lots of error handling since client not waiting response. sends message hoping reply sometime. im using js , react on frontend , clojure on backend. i have 2 questions regarding this. given current design, alternatives there error handling on websocket? would smarter split 2 uc using rest uc1 , websockets uc2 use fetch on frontend rest calls. update. current problem not knowing how build async send function on websockets can match send messages , response messages. here's scheme doing request/response on socket.io. on plain websocket, you'd have build little more of infrastructure yourself. same library can used in client , server: function initrequestresponsesocket(socket, requ

Speeding up [select * into table] across linked servers -

i'm trying copy table size ~50 million rows database on link server. not have indexes (although wouldn't think should make difference). i've used following query: select * [db2].[schema].[table_name] openquery([linked_server_name], 'select * [db1].[schema].[table_name]') this took approximately 7 minutes. this seems suspiciously long intended simple copy , paste. missing something? i need run on regular basis , ideally keep automated possible (no manual copying tables across servers using siss ideal) any ideas highly appreciated! thanks bunch there lots of different reasons @ play here each having cumulative effect on 'slowness'. looking @ wait states first port of call. indexing ( @ least on select side ) isnt issue here , there no predicate used ( @ lesser extent using columns ) therefore how expect index helpful ?? i number of rows not helpful metric... how big in terms of mb / gb source data set ? use "include cl

java - Why does my for loop check only the first element? -

i have method checks username , password of user before login. loop checks first item, finds first condition, u.getrole().equalsignorecase("recruiter") not satisfied first item, instead of going , checking second item breaks , returns null. why happen? here method: public user check(string username, string password) throws adexception { try { begin(); query q = getsession().createquery("from user"); arraylist<user> list = (arraylist<user>) q.list(); system.out.println("recruiterlist is: " + list); (user u: list) { system.out.println("before if user is: " + u); if (u.getrole().equalsignorecase("recruiter")) { system.out.println("username 1 :" + u.getusername()); if (u.getusername().equalsignorecase(username) && u.getpassword().equalsignorecase(password)) system.out.println(&q

Split a text file in C and give it a name -

i created code split text files when finds word "new day" , save file specific name. first, used file_part1, file_part2 , on... however, want use first 15 characters of second line of file reading name of file saved. for example, second line written: tam 2000-03-07t14:53... want use tam 2000-03-07 the problem function sprintf worked "%d", "%c" not working "%s" , don't have idea why. i tried print variable before see sprintf should receiving , receiving want... here code: int tam_buffer = 75; int filecounter=1, linecounter=1; char fileoutputname[16]; int main(int argc, char *argv[]){ char buffer[tam_buffer]; char buffer2[15]; file *arquivo = fopen("entrada.txt", "r"); file *saida; sprintf(fileoutputname, "file_part%d.txt", filecounter); saida = fopen(fileoutputname, "w"); if(arquivo != null){ while(fgets(buffer, tam_buffer, arquivo)){ if(linecounter==2){ str

Mid-Stream Changing Configuration with Check-Pointed Spark Stream -

i have spark streaming / dstream app this : // function create , setup new streamingcontext def functiontocreatecontext(): streamingcontext = { val ssc = new streamingcontext(...) // new context val lines = ssc.sockettextstream(...) // create dstreams ... ssc.checkpoint(checkpointdirectory) // set checkpoint directory ssc } // streamingcontext checkpoint data or create new 1 val context = streamingcontext.getorcreate(checkpointdirectory, functiontocreatecontext _) // additional setup on context needs done, // irrespective of whether being started or restarted context. ... // start context context.start() context.awaittermination() where context uses configuration file can pull items methods appconf.getstring . use: val context = streamingcontext.getorcreate( appconf.getstring("spark.checkpointdirectory"), () => createstreamcontext(sparkconf, appconf)) where val sparkconf = new sparkconf()... . if stop app , change configuration in ap

sqldataadapter - Insert DataTable rows to DataBaseTables using DataAdapter: leave out one column in DataTable -

i have datatable named dtpurchaseproduct has columns dtcolpurchaseproduct_no dtcolninvoiceno dtcolnproductno dtcolnproductname dtcolnquantity dtcolnprice these bound datagridview except dtcolnproductno because product names required seen and have databasetable named purchaseproduct has columns purchaseproduct_no invoiceno productno quantity price now after allowing user add/update/delete datatable rows through textboxes want insert these rows databasetable dataadapter is possible that? don't have select command , columns not same don't have database column dtlcolnproductname string qry = "select * purchaseproduct 0 = 1"; sa = new sqldataadapter(qry, conn); dataset = new dataset(); sa.fill(dataset); dataset.tables[0].columns.add("dtcolnpurchaseproductproductname",typeof(string));

spring data - int-jpa:retrieving-outbound-gateway and caching the result -

is possible cache result of jap retriving oubound gateway(int-jpa:retrieving-outbound-gateway). every time query not executed if result available in cache? the solution existing code base may like: <transformer input-channel="input" ref="testbean" method="uppercase" output-channel="output"> <request-handler-advice-chain> <cache:advice> <cache:caching cache="foo"> <cache:cacheable method="handle*message" key="#a0.payload"/> </cache:caching> </cache:advice> </request-handler-advice-chain> </transformer> it <transformer> here, same applied jpa gateway well. pay attention method="handle*message" aop path. plus key expression based on message a0 cacheable advice argument. that's may why still don't support out-of-the box component in spring integration. pr

Call a web service through php -

this question has answer here: helping using json api 3 answers i new php. trying call web service (written in java) in following format url: http://geoserver.com/track?uid='user'&sdate='sdatetime'&edate='edate' 'etime' it returning json data in following format: [{"lat":"1","lng":"2","time":"2013-06-23 14:00:42"}, {"lat":"3","lng":"4","time":"2013-06-23 14:10:10"}, {"lat":"5","lng":"6","time":"2013-06-23 14:21:00"}] how can call url through php? there couple of ways call using php. 1 method using curl , method using file_get_contents if using file_get_contents $json = file_get_contents("http://geoserver.com/track?uid='us

ruby - How to get classes interact with one another -

i have classes person, dogs, cats, , fishes, , need them interact. more specifically, need person class buy instance of dog class, or name instance of cat class, etc. how do that? variables class variables, out of scope use in class. not sure start. let's have person.rb: class person ....... end and have dog.rb: class dog ........ end if want access dog class inside person have include it. means dog.rb be: require 'dog' class person def my_method dog = dog.new() end end require 'name_of_file_with_class' this pure example how make accessible, furthermore depends on want. cheers.

javascript - Extract svg path with regex -

i want extract svg path using regex , javascript, doesn't work. my svg file : <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" viewbox="0 0 100 100"> <path d="m0.675,11.333h98.849v21.182h0.675v11.333z m0.675,39.576h98.849v21.183h0.675v39.576z m0.675,67.818h98.849v21.184h0.675 v67.818z"/> </svg> my regex : /^<path(.*)\/>$/gm i'd : <path d="m0.675,11.333h98.849v21.182h0.675v11.333z m0.675,39.576h98.849v21.183h0.675v39.576z m0.675,67.818h98.849v21.184h0.675 v67.818z"/> and no results... dot in js regex won't match line breaks. var s = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" viewbox="0 0 100 100">\n<path d="m0.675,11.333h98.849v21.182h0.67

PHP JSON foreach Array Issue -

i'm trying use php display json data api. need use foreach return results nested within them array. array "highlights" has "description" , "content" , both. need foreach within foreach or along lines try returns "array". here's json... https://api.data.gov/gsa/fbopen/v0/opps?q=lte+test+bed+system&data_source=fbo&limit=100&show_closed=true&api_key=ctrs3pcyimtdr4wkn50ai1gcuxyl9m4s1fybbser here's php... $json_returned = file_get_contents("json_url"); $decoded_results = json_decode($json_returned, true); echo "number found:".$decoded_results['numfound']."</br> "; echo "start:".$decoded_results['start']."</br>"; echo "max score:".$decoded_results['maxscore']."</br>"; foreach($decoded_results['docs'] $results){ echo "parent link t:".$results['parent_link_t']."</br>

javascript - Print one array element into another array -

i trying print 1 list of array element array element following code: <html> <body> <p id="demo"></p> <p id="demo1"></p> <script> var juice = []; var fruits = [2, 5, 7, 10,15, 25,28,34,38,45,49,52,55,57,59]; for(int =0;i < fruits.length;i++){ juice[i] = fruits[i]; } document.getelementbyid("demo").innerhtml = juice.length; document.getelementbyid("demo1").innerhtml = juice; </script> </body> </html> i not getting output above code. this work you. <body> <p id="demo"></p> <p id="demo1"></p> <script> var juice = []; var fruits = [2, 5, 7, 10,15, 25,28,34,38,45,49,52,55,57,59]; for(var =0;i < fruits.length;i++){ juice[i] = fruits[i]; } document.getelementbyid("demo").innerhtml = juice.length; document.getelementbyid("demo1").innerhtml = juice; <

math - matrix laws and syntax matlab -

what happening in code? don't understand why getting 2 different different matrices when a^-1 * b^-1 = (a*b)^-1 have tried writing in language keep getting same inequality. input: a = [3 5 2; 2 1 -1; 1 2 2]; b = [6 -2 4; 6 4 -12; 12 2 8]; inversea = a^(-1); inverseb = b^(-1); inversemult = inversea * inverseb; inversematmult = (a*b)^(-1); equalitycheck = inversemult == inversematmult; disp(inversemult) disp(inversematmult) disp(equalitycheck) output: -0.4038 -0.0863 0.1974 0.3224 0.0923 -0.1478 -0.1518 -0.0804 0.0804 -0.0317 0.0615 0.0694 0.1190 -0.2619 -0.1667 -0.0357 -0.0089 0.0625 0 0 0 0 0 0 0 0 0 you assuming incorrect identity - should be: (a*b)^-1 = b^-1 * a^-1 (see useful list of invertible matrix identities here .) so if change line: inversematmult = (a*b)^(-1); to: inversematmult = (b*a)^(-1); then should expected result. (note equality check may

android - SHM replacement based on ASHMEM -

i'm working on library port *nix android, , library uses shared memory or shm . android not have system v shm . instead uses ashmem . is aware of shim library map shm calls ashmem ? google has not been helpful. this how worked me while working similar problem of porting: instead of using shmfd = open(shm_path, o_rdwr) creating , getting file descriptor replaced with int fd = ashmem_create_region("sharedregionname", size); and used file descriptor base address: int base_address = mmap(null, size, prot_read | prot_write, map_shared, fd, 0); you can pass base_address java code native code using native function returns descriptor. android has wrapper class ashmem named memoryfile. can have in that. the following links helped me create own wrapper: http://notjustburritos.tumblr.com/post/21442138796/an-introduction-to-android-shared-memory http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/android/os/

umbraco macro XSLT not working -

i image folder parameter (folder present in media section) macro in umbraco , loop through images. first thing check folder not empty , during loop further try check if image name equal "marhall_spadayhpbanner_jul131%20(4).jpg" need put different link anchor. have tried following xslt code reason not working expected , second condition (when image equal 'media/42595/marhall_spadayhpbanner_jul131%20(4).jpg' ) never true. any ideas thanks <xsl:for-each select="$imagefoldercontents/node [@nodetypealias='image']"> <xsl:if test="string(current()/data [@alias='umbracofile']) != ''"> <a href="www.somelink.com"> <img alt="{current()/@nodename}"> <xsl:attribute name="src"><xsl:value-of select="current()/data [@alias='umbracofile']"/></xsl:attribute> </img> </a>

php - How to access one variable across the page in ruby? -

now new in ruby language. learning ruby. expert coder in php. working in cakephp. cakephp , ruby directory structure approximately same. confusing little bit in ruby code. in cakephp while define variable in bootstrap.php getting variable across site. suppose have variable name $gallery_path = 'files/gallery/'; if echo $gallery_path in controller, model , view. getting gallery path. but here in ruby unable define variable php bootstrap.php please suggest me. for things change enough need edit them , then, infrequently enough you're not changing it, simple module works here. you can start this: module siteconfiguration mattr_accessor :site_name mattr_accessor :payment_provider end then can configure in config/environment.rb : siteconfiguration.site_name = 'the site' siteconfiguration.payment_provider = 'paypal' these accessible everywhere in app.

mysql - Running mysqldump throws error 2013 -

i'm using mysql workbench 6.3.6 build 511 ce (64 bits) mysql 5.6.25 on windows 10 bundled xampp 5.6.11. it used work fine month in configuration. don't recall changing settings, when want export db throws error mysqldump: got error: 2013: lost connection mysql server @ 'reading authorization packet', system error: 2 when trying connect operation failed exitcode 2 the error appears when try calling mysqldump myself cmd. the command workbench used this 14:23:26 dumping invento (all tables) running: mysqldump.exe --defaults-file="c:\users\rog\appdata\local\temp\tmp0apjw4.cnf" --host=127.0.0.1 --insert-ignore=true --protocol=tcp --user=root --force=true --port=3306 --default-character-set=utf8 --routines --events "invento" i should add error doesn't appear exit code 2 indicates there permissions problem. usual suspect lack of permissions lock tables command on given database or table(s) trying dump. make sure

c++ - Expression must be an lvalue -

there lot of such questions, going through them didn't solve problem in case. the pssetshaderresources 3rd parameter wants id3dshaderresourceview* const* . so cannot make way (because getting lvalue error): // std::unique_ptr<texture> mtexture; // id3d11shaderresourceview* texture::gettexture() const { // return mtexture; // } devicecontext->pssetshaderresources( 0u, 1u, &mtexture->gettexture() ); that's why found way around make way: auto tex = mtexture->gettexture(); devicecontext->pssetshaderresources( 0u, 1u, &tex ); however, i'd rid of auto tex = ... line. is there possibility change gettexture() method (or without changing it) write in first case? okay, have solved changing gettexture() method to: id3d11shaderresourceview* const* texture::gettexture() const { return &mtexture.p; // ccomptr<id3dshaderresourceview> mtexture; }

calculator - Assembly multiplication and addition -

i can't seem output integer in assembly greater 128.. works fine until add/multiply numbers resulting integer > 128. returns garbage character. help! how can output integers. here complete code. title .model small .stack 64 .data msga db 13,10,"input equation: ","$" msgb db 13,10,"the sum ","$" msgc db 13,10,"the difference ","$" msgd db 13,10,"the product ","$" msge db 13,10,"the quotient ","$" msgf db 13,10,"the difference -","$" msgg db 13,10,"the remainder ","$" op1a db ? op1b db ? oprnd db ? op2a db ? op2b db ? result db ? num1 db ? num2 db ? ;for 3 digit outputs first db ? second db ? third db ? .code main proc near mov ax, @data mov ds, ax @strt: lea dx, msga mov ah, 09h int 21h ;get tens digit of first number mov ah, 01h int 21h sub al, '0' mov op1a, al ;get ones digit of first number mov ah, 01h int 21h sub a

How to create and update a file in a Github repository with PHP and Github API? -

Image
i trying build php functions create , update files within github repository, using php through github api. the php files being run standard shared hosting account. therefore using frameworks depend on installing composer or other libraries not option me. example, https://github.com/knplabs/php-github-api not option. so far i have managed access , list files using php, using info given here: github api list repositories , repo's content i used combination of 2nd , 6th answer (2nd starts here nice way curl. flesheater , 6th answer when "display repo , contents" ivan zuzak). both list code , steps needed list files , contents (thank @flesheater , @ivan zuzak) i searched or solutions this. far have not found example, working or otherwise, using php. git api documentation git data api info ( https://developer.github.com/v3/git/ ) says this: as example, if wanted commit change file in repository, would: get current commit object retrieve tree p

php - Symfony - user gets logged out even on a name change -

i facing weird situation user role_admin gets logged out change name , if dont change , press save button gets logged out. if change user's role directly in database role_user same code works fine , user not logged out. following controller takes care of profile update /** * @route("/profile", name="profile") */ public function profileaction(request $request) { $em = $this->getdoctrine()->getmanager(); $userinfo = $this->getuser(); //create form object $profileform = $this->createform(usertype::class, $userinfo); $profileform->handlerequest($request); //check data validity if($profileform->isvalid()){ $em->persist($userinfo); $em->flush(); $this->get('session')->getflashbag()->add( 'success', 'your profile information has been updated'