Posts

Showing posts from August, 2014

html - How can make 2 columns with table in angular -

i have code in angular template makes header on left , data on right top bottom. <div class="panel-body"> <table class="table table-striped"> <tr ng-repeat="f in fields"> <th>{{ f }}</th> <td>{{ data[f] }}</td> </tr> </table> </div> but instead of 1 field in 1 row want have 2 fields in 1 row , 3rd field , 4th field in second row , on. so have 2 columns layout <tr><th>{{ f }}</th> <td>{{ data[f] }}</td> <th>{{ f }}</th> <td>{{ data[f] }}</td> </tr> field = ['id', 'name', 'username', 'email', 'age'] data = [{id:1, name: 'john', username: 'john', age: 20, email: 'test'}] the result want is <tr><td>id:</td><td>1</td><td>name:</td><td&

ios - Method Delay In NSURLSession Block -

when call block: nsurlsession *session = [nsurlsession sharedsession]; [[session datataskwithurl:url completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) { _data = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:nil]; _label.text = [nsstring stringwithformat:@"%@°",([[[self.data objectforkey:@"main"] objectforkey:@"temp"] floatvalue]) - 273.15)]; nslog(@"%@",self.data); }] resume]; the code inside block takes long time execute, though nslog gets called - what's going on? i've tried sorts of solutions, nothing working. always perform ui update related task on main thread otherwise take time perform ui. like, updating label text. set image on imageview. timer related operation. so use below code dispatch_async(dispatch_get_main_

gdb pass raw result of evaluation to custom python function -

amd64, register $rdi pointer "/home/il/gammu-git/src/gammu/libgammu/tls/x86_64/libpthread.so.0" seen here example: define foo py print gdb.execute("output $arg0", to_string=true).strip('"') end expected: (gdb) foo (char*)$rdi /home/il/gammu-git/src/gammu/libgammu/tls/x86_64/libpthread.so.0 however, output command prints address of string: (gdb) foo (char*)$rdi 0x7fffffffe180 "/home/il/gammu-git/src/gammu/libgammu/tls/x86_64/libpthread.so.0 you can solve doing in python, i.e. py print gdb.execute("output $arg0", to_string=true).strip('"').split()[1] or (and that's i'd prefer) customizing output call. gdb has comprehensive online typing in help output , following leads there: (gdb) output "print" don't put in value history , don't print newline. useful in user-defined commands. (gdb) print print value of expression exp. variables accessible of lexical environment of

function - Swift func - Does not conform to protocol "Boolean Type" -

yes it's man vs compiler time , compiler winning yet again! in func getrecordnumber returning bool , dictionary func getrecordnumber(recordnumber: int32) -> (isgot: bool, dictlocations: dictionary <string, double>) ... return (isgot, dictlocations) however after have called func , question boolean isgot return error message (isgot: bool, dictlocations: dictionary <string, double>) not conform protocol "boolean type" any ideas have left out? you don't need add parameters return (isgot: bool, dictlocations: dictionary <string, double>) . need tell compiler type function return. here correct way achieve that: func getrecordnumber(recordnumber: int32) -> (bool, dictionary <string, double>) { let isgot = bool() let dictlocations = [string: double]() return (isgot, dictlocations) }

return default ToString() for a class instance c# -

i have class named person public class person { string name; int age; sampleobject(string name, int age) { this.name = name; this.age = age; } public override string tostring() { string s = age.tostring(); return "person: " + name + " " + s; } } i have overridden tostring() return name of person. i using class in class: public class myclass { public int id {get;set;} public person person {get;set;} } now, want access class as myclass = new myclass(); i want when execute my.person , should return tostring() value of person class without explicitly calling my.person.tostring() is possible , if possible, how can make happen. thanks i don't understand question well. 1 of solutions question use implicit cast . public class person { string name; int age; public person(string name, int age) { thi

java - Unsafe, reflection access vs toCharArray (performance) -

jdk9 team puts effort helping removing non-public dependencies (using jdeps ). using unsafe class faster access string s inner char array - without creating new char array. if want drop dependency on unsafe class, need load dynamically , call unsafe.getobject , other methods using reflection. now wonder performances: when use reflection unsafe , how matches string.tochararray performances? make sense keep using unsafe ? i assume jdk >= 7. edit yes, totally know can write these tests using eg jmh; takes lot of time measure different inputs , different vm versions (7,8). wonder if did this; many libraries using unsafe . there chance there no backing char[] array @ in java 9 version of string , see jep 254 . is, tochararray() option. generally should never use unsafe apis unless absolutely sure neccessary. since asking question, guess not. on laptop, tochararray() completes in 25 nanoseconds 100-chars string, i.e. call 40 million times second! have such

java - HttpURLConnection 403 response after 200 -

ok i'm working on app 2 activities. let's call 1st 1 loginactivity appears on top of mainactivity. also, have class senderreceiver extends asynctask takes care of connection https server. the 1st time call senderreceiver loginactivity, works fine & 200 response & i'm able use json retrieved. after that, loginactivity finishes & returns result mainactivity. when know i'm logged in & can proceed. now whenever execute senderreceiver other information, 403 response java.io.filenotfoundexception: https://url_of_my_server . if call login again, works. below senderreceiver code snippet connects server. i'm connecting same server on ios version of app & never have issues subsequent calls after login. now 1st time using https connections & such, i'm not sure how works on android must missing or doing wrong. @override protected boolean doinbackground(object... params) { frag = (fragment)params[0]; // later addedparams = (l

javascript - Hide blinking cursor from Jquery UI modal dailog -

Image
this view. <div class="login-card"> <h1>log-in</h1> <br> <input type="text" id="txtuser" placeholder="username" autofocus value="adm"> <input type="password" id="txtpass" placeholder="password" value="adm"> <input type="button" name="btnlogin" class="login login-submit" value="login" onclick="btnloginclick($('#txtuser').val(), $('#txtpass').val())"> </div> @globalhelper.createdivformodaldialog("divloginerror", "error", "login failed ! try again") this script. $(document).ready(function () { $('#divloginerror').hide(); }) function btnloginclick(username, password) { $.ajax({ url: "/home/validatelogin", data: { username: username, password: password }, datatype: "json&quo

dataframe - How to count and calculate percentages for two columns in an R data.frame? -

in r, have data.frame this: df1 <- data.frame( grade = rep(letters[1:5], 4), sex = c(rep("male", 5), rep("female", 5), rep("male", 4), rep("female", 6)), class = c(rep(1, 10), rep(2, 10)) ) df1 grade sex class 1 male 1 2 b male 1 3 c male 1 4 d male 1 5 e male 1 6 female 1 7 b female 1 8 c female 1 9 d female 1 10 e female 1 11 male 2 12 b male 2 13 c male 2 14 d male 2 15 e female 2 16 female 2 17 b female 2 18 c female 2 19 d female 2 20 e female 2 i want count percentage of sex in each class , make data.frame like: class male_percent female_percentage 1 50% 50% 2 40% 60% can teach me how it? question might have been asked before, don't know what's keyword question. sorry if ask same question aga

javascript - Why isn't this function working on greasemonkey -

why isn't function working in greasemonkey. function arre(){ var index; var fruits = ["banana", "orange", "apple", "mango"]; (index = 0; index < fruits.length; index++) { window.alert(fruits[index]); } } you declared function did not call it. add end: arre();

asp.net - Custom route for specified errors in web.config -

i'm having custom error config in web.config : <customerrors mode="on" defaultredirect="/common/errorpage.html?webconfig"> </customerrors > now i'm having need redirect different error page special pages remain "/common/errorpage.html?webconfig"> default. possible ? if special pages can in specific asp.net mvc area, 1 way of doing can using different location based custom error paths. (from this ) <system.web> <customerrors mode="on" defaultredirect="error" /> </system.web> . . . <location path="areaname"> <system.web> <customerrors mode="on" defaultredirect="/areaname/error" /> </system.web> </location>

excel - Filter PivotTable on Top 10 records -

Image
i have spreadsheet columns var1 , var2 and var3 aggregated (total) column @ end. need pivottable, based on top 10 highest totals. is possible? when try filter table, can see individual records filter criteria, not usual excel filtering options. yes, facility available within pivottable filtering rows (the funnel next var1 ), value filters, top 10..., top 10 items sum of total :

IOS File Creation Accessible To All Apps -

i need create html , pdf file within app , save in documents directory. file contains user transaction details particular period. able save file in documents directory. but how make accessible other apps.i able create .pdf files when tried view same using adobe reader, file not listing. please share ideas can view files saving app accessed outside app also. i created html file in app's documents directory. within app, listing files saved user. nsstring *docsfolder = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes)[0]; nsstring *filename = [docsfolder stringbyappendingpathcomponent:[nsstring stringwithformat:@"statement_%@_%@_to_%@.html",[selectedacct substringfromindex:max((int)[selectedacct length]-5, 0)],strfromdate,strtodate]]; nserror *error; [html writetofile:filename atomically:no encoding:nsutf8stringencoding error:&error]; if(error != nil){ uialert ---> "error message" } else

node.js - How to find specified fields in mongodb in sails? -

in mysql, can retrieve specified columns using: user.find({select:['email']})..... now moving mongodb, tried: user.find({select:['email']})..... user.find({},{email:1})..... user.find({},{fields: {email:1}}).... but none of them works. how in mongodb ? btw: using official mongodb driver bellowed, it's quite simple , match api document, rethinking should use official driver( i don't want waste time in asking & solving problem this ), don't want lose capacity , flexibility of waterline well. suggestion or advice mush appreciated. db.collection('user').find({},{email:1}) db.user.find({},{"_id":0,"email":1}) this working me in mongodb 3.x

Use case for Neovim terminal mode inside tmux session -

now have terminal mode in neovim, wondering if there still use case tmux. let's need work on remote machine using ssh. in order keep persistent vim session, launch tmux session on remote machine, start neovim , create many terminal windows needed. don't need use windowing mechanism of tmux anymore. there use cases neovim terminal mode cannot satisfy? tmux provides session management. example, can create multiple sessions , detach/re-attach please. terminal emulation in neovim, shell killed when terminal buffer closed. so, there's still use-case it, however, primary use case regards vim + tmux has been eliminated terminal emulation.

python - How to get values from lists of lists and add them to smaller lists -

say have lists so: mylist1 = [1,2,3] mylist2 = [7,8,9] mylist3 = [13,14,15] and append them larger list: mybiglist = [] mybiglist.append(mylist1) mybiglist.append(mylist2) mybiglist.append(mylist3) and have smaller lists such: a = [] b = [] c = [] how iterate through 'mybiglist' list, , pull out first value of smaller lists , store values in a, second values of shorter lists, in b, , shorter of third in c? appreciate help. zip great. >>> mylist1 = [1,2,3] >>> mylist2 = [7,8,9] >>> mylist3 = [13,14,15] >>> mybiglist = [] >>> mybiglist.append(mylist1) >>> mybiglist.append(mylist2) >>> mybiglist.append(mylist3) >>> mybiglist [[1, 2, 3], [7, 8, 9], [13, 14, 15]] >>> a, b, c = zip(*mybiglist) >>> (1, 7, 13) >>> b (2, 8, 14) >>> c (3, 9, 15) are using mybiglist something? if want, can arrive @ a , b , , c without putting them mybiglist @ all.

jsf 2 - JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output -

i have facelets files below. webcontent |-- index.xhtml |-- register.xhtml |-- templates | |--userform.xhtml | `--banner.xhtml : both pages using templates /templates directory. /index.xhtml opens fine in browser. generated html output. have link in /index.xhtml file /register.xhtml file. however, /register.xhtml not getting parsed , returns plain xhtml / raw xml instead of generated html output. when rightclick page in browser , view page source , still see xhtml source code instead of generated html output. looks template not getting applied. however, when open /register.xhtml /faces/register.xhtml in browser's address bar, displays correctly. how caused , how can solve it? there 3 main causes. facesservlet not invoked. xml namespace uris missing or wrong. multiple jsf implemenations have been loaded. 1. make sure url matches facesservlet mapping the url of link (the url see in browser's address bar) has match <url-patte

css - Apply conditional class in a rails view inside map{} using haml -

i trying apply class conditionally names associated reminder. if there 3 persons associated reminder - jay, jonah , jamison... , jonah 1 acknowledged reminder, want name have class "acknowledge", though want display 3 names. %tbody -reminder.each |r| %tr %td =r.persons.each.map{|n| n.name{:class=> ("acknowledge" if r.completed_by.id == n.id)} }.join(',') i tried apply class inside map{} shown above error saying syntax error, unexpected =>, expecting '}' any appreciated. %tbody - reminder.each |r| %tr %td - r.persons.each |person| %span{class: "acknowledge" if person.completed_by.id == n.id}= person.name

c++ - Why can the new operator be with an initial value? -

as know new operator can used in following way: int *a = new int(10); , means there int pointer named points initial value equals 10. in http://www.cplusplus.com , couldn't find such direction , want know why new operator can used initial value? similar constructor calling? why new operator can used initial value? the initial value (10) goes object (int) *a points. is similar constructor calling? yes. also works auto vars int b (20); b initialized 20.

java - Find position of substring within string with conditions -

given string string foo = "if (bar = 10 ) { if (foobar == 1) { } }" i want find position of "if" not have "if" within opening , closing braces. example above, want know position of second "if" not first "if". i know have use form of regex new regex , not sure how go it. accept non regex answer. maybe pattern help (\bif\b)[^{}]*{[^{}]*} demo

java - Add images to JButton in Eclipse -

Image
i new programmer , have started using eclipse. previously, used jgrasp , when wanted add image button did create image folder within class's folder , write: seticon(newimageicon(this.getclass().getresource("/images/name.png"))); i tried same thing eclipse main:nullpointerexception error. read post , added source folder project named images nothing changed. following code segment have issue with: resetbutton.seticon(newimageicon(this.getclass().getresource("/images/helpicon.png"))); you on right way. had added resource folder. additional root resources. here, in folder (as root) have create /image folder , put files it:

php - json_decode returns null (special characters) WoW API -

i'm having issues json_decode . have form asks realm list , character name (which can have special letters such as: ö , à , é , etc): <form method="post"> <!--//<input name="realm" type="search" id="realm" value="<?php echo $_post['realm']; ?>"><br />--> <div class="styled-select"> <select name="realm" required> <option value="" <?php if ($selected_choice == "none") { print "selected='selected'"; }?>>select...</option> <option value="aegwynn" <?php if ($selected_choice == "aegwynn") { print "selected='selected'"; } ?>>aegwynn</option> <option value="area 52" <?php if ($selected_choice == "area 52") { print "selected='selected'"; } ?>>area 52</option> <optio

javascript - Fire multiple tweens simultaneously with GSAP and TweenMax -

i want move away jquery animation have been using gsap. trying figure out how fire multiple animations on element , children. want give #navicon "720 cork" effect working fine , fade/toggle icon children of #navicon container not working @ all. if using jquery only, have add multiple classes needed , use them trigger css3 transforms. however, gsap seems really fast . i have read gsap docs pretty thoroughly. , see how chain tweens "timeline" not sure how fire multiple tweens on different elements based on 1 event. here code far: var togglemobimenu = function() { $('#navicon').on('click touchstart', function() { tweenmax.to($(this), 0.5, { rotationy: 720, rotationx: -720 }) .to($(this).find('#open'), 0.5, { opacity: 0 }) .to($(this).find('#closed'), 0.5, { opacity: 1 }); }); } togglemobimenu(); and here fiddle of same. know how tween these 3 elements @ once? two problems

How to add like on instagram media using php -

i'm building small app instagram , need post on media $uurl='https://api.instagram.com/v1/media/'.$media_id.'/likes'; $inst_stream2 = callinstagram($uurl); $results2 = json_decode($inst_stream2, true); function callinstagram($url) { $ch = curl_init(); curl_setopt_array($ch, array( curlopt_url => $url, curlopt_returntransfer => true, curlopt_ssl_verifypeer => false, curlopt_ssl_verifyhost => 2 )); $result = curl_exec($ch); curl_close($ch); return $result; } but doesn't post !!

filab - How to programmatically authenticate to HDFS in fiware cosmos -

i'm writing .net application c# programmatically run rest apis against hdfs on fiware on http post operations fails 401 (access denied). works simple operations i'm not sure how authentication. spec seems spegna , delegated auth tokens 2 options how do programmatically? have user name , password go off of. i'm using restsharp library make rest interactions easier. this code works var client = new restclient("http://cosmos.lab.fi-ware.org:14000"); request = new restrequest("webhdfs/v1/user/<userid>"); request.addparameter("op", "liststatus"); request.addparameter("user.name", "<userid>"); irestresponse response = client.execute(request); var content = response.content; // raw content string this code fails http 401 var client = new restclient("http://cosmos.lab.fi-ware.org:14000"); var request = new restrequest("webhdfs/v1/user/<userid>/structured_data123.txt",method

bash - Assigning echo and cut command to a variable -

i'm trying string "boo" "upper/lower/boo.txt" , assign variable. trying name= $(echo $whole_thing | rev | cut -d "/" -f 1 | rev | cut -d "." -f 1) but comes out empty. doing wrong? don't way @ all. more efficient use built-in shell operations rather out-of-process tools such cut , rev . whole_thing=upper/lower/boo.txt name=${whole_thing##*/} name=${name%%.*} see bashfaq #100 general introduction best practices string manipulation in bash, or the bash-hackers page on parameter expansion more focused reference on techniques used here. now, in terms of why original code didn't work: var=$(command_goes_here) ...is correct syntax. contrast: var= $(command_goes_here) ...exports empty environment variable named var while running command_goes_here , , while running output of command_goes_here own command. to show yet variant, var = command_goes_here ...runs var command, = first argument, , comm

unity3d - How do you reference UI Event System from script? -

Image
i tried creating public variable , referencing eventsystem object inspector of gameobject script attached to, whenever try access variable eventsystems, i nullreference exception: object reference not set instance of object. i tried finding gameobject.find() apparently can't cast gameobject eventsystem.eventsystem in-built cast. i'm not sure do. want access eventsystem.currentselectedgameobject.name to find out ui object in canvas selected. here want, see documentation here . eventsystem.current

html - How to combine REST Api and xhtml page? -

i read several tutorial restful web services , understood main target of it. don't understand how combine rest , xhtml pages. usually, have pages <h:form> <p:tabview orientation="left" id="maintabid"> <p:tab title="user information"> <h:panelgrid columns="2" columnclasses="column" cellpadding="5" styleclass="datatablestyle" border="2" cellspacing="5"> <h:outputlabel value="first name:" /> <p:inputtext id="firstname" value="#{user.firstname}" validatormessage="length should 3 or more" required="true" requiredmessage="this field can not empty"> <p:ajax event="mouseout" update="firstnamemsg"></p:ajax> <f:validatelength minimum="3"></f:validatelength> </p:inputtext> <p:message id=

Ruby elasticsearch-model - configuring multiple mappings -

module spree product.class_eval include elasticsearch::model index_name spree::elasticsearchsettings.index document_type 'spree_product' mapping _all: {"index_analyzer" => "ngram_analyzer", "search_analyzer" => "whitespace_analyzer"} indexes :name, type: 'multi_field' indexes :name, type: 'string', analyzer:'ngram_analyzer', boost: 100 indexes :untouched, type: 'string', include_in_all: false, index: 'not_analyzed' end indexes :name_whole, type: 'multi_field' indexes :name, type: 'string', index_analyzer:'simple' end indexes :name_completion, type: 'multi_field' indexes :untouched, type: 'string', include_in_all: false, index: 'not_analyzed' end indexes :taxon_ids, type: 'multi_field' indexes :taxon_ids, type:'string', analyzer: 'simple'

jquery - Handling wordpress content into ajax modal popup -

i succeed implement jquery modal here http://wordpressthemescollection.com/ajax-wordpress-post-popup-with-simplemodal-and-jquery-488.html wordpress. however, when click on link displayed within modal, parent page changed. here way interact inside modal windows ? thank you, ken. your limitation here "modal" div not separate targettable browser window. so, need intercept click event within containing "modal" div, , load page content modal itself. the problem becomes more complex if want able things incorporate browser back/forward button navigation within modal, require intercept events , reference stored history of pages have been loaded modal.

How to make two classes for one image: .small-image { max-width: 100px; max-height: 100px; } also have the text aligned in middle using css and html -

think it's possible use 2 different classes series of thumbnail images must doing wrong. please suggest how so. css example: .small-image { max-width: 100px; max-height: 100px; } .textmiddle {vertical-align:middle;} only seem able put code in html 1 or other not both. thank you try in html element : class="small-image textmiddle"

Trouble trying to run Python 2.7 and 3.4 in Eclipse -

i've installed python 3.4 , using python 2.7 . want create project in python 3.4 , but, when go run-->run configurations , make new entry under python run , see c:\python34 doesn't show up. also, when try create new project, "grammar version" goes 3.0. don't know how resolve this. edit : because haven't installed python 3.4 correctly? thanks i'm assuming you're using pydev. don't know if there other alternatives that's use python in eclipse. right-click on project folder in package explorer view , select "properties". select "pydev - interpreter/grammar" select appropriate grammar version , interpreter, if options contain python version want. if not, click on "click here configure interpreter not listed." click "new" , provide interpreter name (e.g. python3.4) , path executable (c:\python34) once you've done that, should see option select python 3.4 interpreter under ru

android - Is Using Different Names for onClick methods for Different buttons a good coding style? -

rather using single onclick() method buttons in activity, , using switch statement determine button clicked, set different methods different buttons in android:onclick xml parameter. example, 1 button set onclick parameter onclickcalculatebutton , button set onclick xml parameter onclicknewfilebutton . is coding practice? there no real convention in case. i've seen programmers way or other, , i'm guessing people agree. for buttons not straight forward (not in activity/fragment) , cant used butterknife don't set click listener in xml rather implementing @ specific class (activity/fragment/whatever) switch-case , referring specific method. switch(view.getid()){ case r.id.button_one: clickonbuttonone(view); break; ... for buttons know lifecycle (in fragment/activity) use butterknife , use annotation ( @onclick(r.id.button)

C trouble with stat -

in program stat working current directory. can 1 please me this. even though passing parameter main working current directory. , source path printing correct path have passed main. dir *dr; struct dirent *cur; struct stat fi; long int total_size = 0; dr = opendir(source); char *name; printf("%s\n\n\n", source); if (!(dr)) { perror("opendir()"); return(1); } while (cur = readdir(dr)) { if(cur->d_name[0] != '.') { if(stat(cur->d_name, &fi) == -1) { printf("error \n\n"); } else { printf("%s ",cur->d_name); printf("%ld ",fi.st_blocks); total_size = total_size + fi.st_blocks; } } } printf("\n\ntotal_size = %ld \n", total_size); printf("\n\n\n"); return 0;

python - Reading input data to array(s) with multiple delimiters and headings -

i'm trying formulate parser in python read input file , assemble results several arrays. the data has following structure: some_numbers 1 5 6 some_vector [-0.99612937 -0.08789929 0. ] [-0.99612937 -0.08789929 0. ] [ -9.99999987e-01 1.61260621e-04 0.00000000e+00] some_data 1239 #int 671 471 851 s4rs #string 517 18 48 912 s4rs so far methods have tried are: text_file = 'c:\aa\aa.txt' lines = open(text_file).read().splitlines() numbers = [] vector = [] line in lines: line = line.strip() if line.startswith('some_numbers'): continue numbers.append(line) if line.startswith('some_vector'): continue vector.append(line) problems have encountered the: 1) having multiple delimiters 2) trying split data according relevant sections i have tried using np.genfromtxt along countless hours trawling internet. your comments , advice appreciated. i not sure in-built o

jquery - Scroll effect on website? -

i saw website online: http://manipal.edu/mu.html , have 1 question, difficult create scroll effect , what's name of it? , how activate him on scroll? there library or something? thanks in advance. the site referenced doing javascript/jquery listening multiple scroll , touch events. once know user has attempted scroll determine direction intended , navigate page appropriately. hijacking users scroll functionality frowned upon lot of developers , users though. can annoying when user trying navigate page (i've ready blog posts can't find atm use source). this effect made popular apple in both iphone 5 , mac pro sites. these sites built presentational. there library named one page scroll can used duplicate effect you're looking for.

javascript - Can anyone help me make the search bar work as I now have the JS prompt? -

i have created small program pulls youtube api allows search random video whatever title enter when prompted. goal have work search engine. make search bar input instead of alert prompt window. similarly, make "find" button act "ok" button on prompt alert window when run program javascript in jsbin. can point me in proper direction accomplish this? here jsbin . assuming can use sort of onclick function button, not totally sure how implement , call on. thank you! ps. i'm know this, in case... make sure run program in jsbin "run js." you can add onclick listener find button , trigger code when clicks. can value of search input instead of prompt: javascript: function search() { var api_key; api_key = "aizasydiuekwoldcb9qgrreosaiyu2nlj8u-03c"; var search_term = document.getelementbyid("searchterm").value; function onsuccess(data){ console.log(data); var obj = data.id; con

.htaccess - How do I redirect a URL with a parameter to a clean URL in htaccess? -

i attempting 301 redirect several urls parameters @ end clean urls. for example trying redirect: http://example.com/news/news.php?id=1234 http://example.com/posts/vanity-url.php here code: rewritecond %{query_string} id=1234 rewriterule ^news/news\.php$ /posts/vanity-url.php [l,r=301] i feel i'm close code redirects me to: http://example.com/posts/vanity-url.php?id=1234 , i'm not sure why happening. i appreciate help. thank you! add question sign after remove query string rewriterule ^news/news\.php$ /posts/vanity-url.php? [l,r=301]

How do you create a basic Wordpress admin pointer? -

i have been looking around quite awhile , have found tutorials 3-4 years ago explain how pointer tour. want add pointer pops when activates plugin can notify them of new menu option go view plugin settings. appreciated! what looking wordpress activation / deactivation hooks . example: register_activation_hook( __file__, 'pluginprefix_function_to_run' ); and on pluginprefix_function_to_run , display nice message let users know you've added menu using admin_notices : function my_admin_notice() { ?> <div class="updated"> <p><?php _e( 'your message goes here!', 'my-text-domain' ); ?></p> </div> <?php } function pluginprefix_function_to_run() { add_action( 'admin_notices', 'my_admin_notice' ); }

javascript - Use different library instead of jQuery Mobile for <select> -

i've looked on place try , find way somehow disable jquery mobile's selectmenu widget can use 3rd party library <select></select> . in case, want use chosen library. there way can this, while still retaining rest of jquery mobile styling on page? you can tell jqm ignore select adding data-role="none" <select id="myselect" data-role="none" placeholder="select option..." > <option value="">select option...</option> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> <option value="4">option 4</option> </select> here demo using selectize plugin select , other controls use jqm: demo

http status code 302 - How to find IP address of redirecting server in php -

i have 2 servers , b . user accesses page on server a , server a sends redirection (302 status code) , returns. client sends request server b . want way find ip address of server request, identity of server work, $_server['http_referer'] coming blank. ps: have control on server b not on a. if access page of server directly (which sending redirect server b) getting blank referer @ server b. thanks in advance you cannot ip of referrer (i.e. server initiated redirect server).

android - Issue with layout inside scroll view -

Image
i have layout: <scrollview android:layout_width="match_parent" android:layout_height="match_parent"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <edittext android:id="@+id/username_edittext" android:layout_width="match_parent" android:layout_height="55dp" android:background="@android:color/white" android:gravity="center" android:hint="@string/username" android:textcolor="@color/dark_grey" /> <edittext android:id="@+id/password_edittext" android:layout_width="match_parent" android:layout_height="55dp" android:layout_below="@id/username_edittext" android:background="@androi

php - Twig same as operator -

when comparing in php, advisable use === instead of == due intransitive nature , quirks "5 not number" == 5 . by guideline, mean same as operator should used instead of == in twig?: {# "wrong" #} {% if foo.bar == 3 %} {# better #} {% if foo.bar same as(3) %} and likewise is not same as versus != . it makes sense when treating php , twig 2 different tools. fabien potencier's main motive creating twig provide tool web designers, not web developers . (see blog post more insight ). web developers should know more explicit , use === possible. in realm of web design perhaps not vital, if needed, feature available same as() in twig.

Directory listing: 403 Forbidden nginx -

hello started using nginx, set nginx.conf project folder c: / projects. i used (autoindex: on) have list of directories, not work worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; server { listen 80; server_name localhost; root c:\project ; index index.html index.htm index.php; location / { autoindex on; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } if have 1 of index files present inside root directory (or subdirectory under c:\project matter), index page shown rather index of contents. you may want check permissions on content under root ; need readable user running nginx process. could number of different things; you'll need clarify questions in future you've tried , haven't tried.

angular - Examples of VS2015 + Cordova + Angular2 -

i'm trying find quick start tutorial visual studio 2015 apache cordova project using angular 2 + typescript . the latest examples out of date or don't apply cordova. https://github.com/microsoft/ngconf2015demo http://blogs.msdn.com/b/visualstudio/archive/2015/03/12/a-preview-of-angular-2-and-typescript-in-visual-studio.aspx this sample app posted github. https://github.com/dbiele/typescript-cordova-systemjs-angular2-beta i know written author of question, if comes here later should check out dean assembled.

arrays - Add new property based on a different objects property -

Image
i'm trying search through 1 column in each row of table. add value row based on number being search. this code produces table: $lunssummary = ($ny_luns) -split '\s+(?=logical unit number)' | foreach { $stringdata = $_.replace(':','=') new-object psobject -property $(convertfrom-stringdata $stringdata) } $lunssummary | select 'name','logical unit number','state','lun capacity(megabytes)','lu storage groups' | format-table -autosize then have code can search using "logical unit number" , produce desired output. in example -contains 1029 above screenshot. $data = $luns_in_pools | out-string $pools = $data -replace ': +','=' -split "`r`n`r`n" | % { new-object -type pscustomobject -property (convertfrom-stringdata $_) } | select -property *,@{n='luns';e={$_.luns -split ', '}} -exclude luns $pools | ? { $_.luns -contains 1029 } | select

Javascript create array from local file.txt -

i have text file in same directory javascript program: test.txt 1 2 3 4 5 i want load data in array. @ end have array variable follow: [1,2,3,4,5] you can use xmlhttprequest load text file, jquery does, can put this: var array = []; var xmlhttp; if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp = new xmlhttprequest(); } else { // code ie6, ie5 xmlhttp = new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { var text = xmlhttp.responsetext; // convert array using regex array = text.split(/\n|\r/g); } } xmlhttp.open("get", "test.txt", true); xmlhttp.send(); this way in array form, text test.txt file. i assuming test.txt in same folder script does

html - Input saved to a file and then submitted to the URL on submit -

i have form. right has 1 action , submits inputs url. modified when form completed inputs saved file , submitted url. <form class="snp-subscribeform snp_subscribeform" action="join.cgi" method="post"> <input name="page" type="hidden" value="1" /> <div> <input id="snp-firstname" class="snp-field snp-field-firstname " name="firstname" required="" type="text" value="" placeholder="enter first name" /> <input id="snp-lastname" class="snp-field snp-field-lastname " name="lastname" required="" type="text" value="" placeholder="enter last name" /> <input id="snp_email" class="snp-field snp-field-email" name="email" type="text" placeholder="enter email " /> <input

javascript - Where to format collections / objects -

from front end architectural point of view, common way store scripts perform transformations on collections of objects/models? in folder store it, , name file / function? currently have models, views, controllers, repositories, presenters, components , services. expect it? component (what name it?)? service? use services make connection between presenter , repository handle data interactions server. should call formatter? transformer? if there common way do, i'd know it. [...] models, views, controllers, repositories, presenters, components , services. expect it? services , mos def. interception service parsing data. should call formatter? transformer? well, trasformer (or data transformer ) quite imo. data interceptor comes mind, , data parser , obviously. if there common way do, i'd know it. yes, there is! override model's / collection's parse() function transform data fetched server preferred data structure. note should p

c++ - How to put the "camera" inside a cube in OpenGL -

i figure out how put "camera" inside cube i've created can move in fps-like style. tried use glulookat , gluperspective i'm missing steps. should before glulookat? here's code written far: int rotate_y; //used rotate cube y-axis int rotate_x; //used rotate cube x-axis //the display function draws scene , redraws void display(){ //clear screen , z-buffer glclear(gl_color_buffer_bit | gl_depth_buffer_bit); glloadidentity(); //resets transformations glrotatef(rotate_x, 1.0, 0.0, 0.0); glrotatef(rotate_y, 0.0, 1.0, 0.0); //front face of cube - vertex definition glbegin(gl_polygon); glcolor3f(0.0, 1.0, 0.0); glvertex3f(-0.5f, -0.5f, -0.5f); glvertex3f(-0.5f, 0.5f, -0.5f); glvertex3f(0.5f, 0.5f, -0.5f); glvertex3f(0.5f, -0.5f, -0.5f); glend(); //back face of cube - vertex definition glbegin(gl_polygon); glcolor3f(1.0, 0.0, 0.0); glvertex3f(-0.5f, -0.5f, 0.5f); glvertex3f(-0.5f, 0.5