Posts

Showing posts from June, 2014

android - How to set imageview fit to sreen? -

android - How to set imageview fit to sreen? - i have utilize android studio , set image view fit screen using relative background image give layout top margin , set image view fit screen below part android:layout_width="fill_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" android:background="@drawable/backgroud"> <imageview android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margintop="500dp" android:background="@drawable/blacksquare" android:alpha=".33" /> write next imageview tag in parent layout. <imageview android:layout_width="match_parent&qu

How to pass a row object to the backing bean using JSF 2 and RichFaces? -

How to pass a row object to the backing bean using JSF 2 and RichFaces? - i using richfaces's ordering list display table custom command objects user. user uses form create new commands added list. here orderinglist implementation: app.xhtml <rich:orderinglist id="olist" value="#{commandbean.newbatch}" var="com" listheight="300" listwidth="350" converter="commandconverter"> <f:facet name="header"> <h:outputtext value="new batch details" /> </f:facet> <rich:column width="180"> <f:facet name="header"> <h:outputtext value="command type" /> </f:facet> <h:outputtext value="#{com.commandtype}"></h:outputtext> </rich:column> <rich:column> <f:facet name="header"> <h:outputtext value="parameters" /> </f:facet>

ios - How to add these two values together in objective c -

ios - How to add these two values together in objective c - i'm stuck adding these values together. both come .plist. both numbers. want add together values , display result string in label. nsinteger calories = [[self.main objectforkey:@"calories"] integervalue]; nsinteger calories2 = [[self.apps objectforkey:@"calories"] integervalue]; i want go nsstring *totalcalories = calories + calories2; self.calorielabel.text = totalcalories; but not work. i'm new , sense i'm missing little , obvious. any insight? you’re there far add-on itself: nsinteger totalcalories = calories + calories2; now need convert number string, can this: nsstring *totalcaloriestext = [nsstring stringwithformat:@"%d", totalcalories]; the problem trying treat integer look ( calories + calories2 ) string. valid thing in programming languages, in objective-c have explicit such conversions. ios objective-c iphone

html - PHP mail form doesn't complete sending e-mail -

html - PHP mail form doesn't complete sending e-mail - <?php $name = $_post['name']; $email = $_post['email']; $message = $_post['message']; $from = 'from: yoursite.com'; $to = 'contact@yoursite.com'; $subject = 'customer inquiry'; $body = "from: $name\n e-mail: $email\n message:\n $message"; if ($_post['submit']) { if (mail ($to, $subject, $body, $from)) { echo '<p>your message has been sent!</p>'; } else { echo '<p>something went wrong, go , seek again!</p>'; } } ?> i've tried creating simple mail service form. form on index.html page, submits separate give thanks submission page thankyou.php above php code embedded. code submits perfectly, never sends email.. please help... there variety of reasons script appears not sending emails. it's hard diagnose t

c# - Method fails read all rows from .csv -

c# - Method fails read all rows from .csv - we have app utilize manage changes our voip system. uses upload of csv that's built custom export out of cisco scheme controls phones. failing, think, on bad row in .csv file there "-" character, removing character allowed file process way through. method reads file fed streamreader , staticconfig object entity store record each line in. method read rows of .csv: while ((linebuffer = sr.readline()) != null) { // loop through lines found in file string[] tmpstring = linebuffer.split(convert.tochar(",")); if (tmpstring[0] != "") { staticconfig staticentry = new staticconfig(); int extension; if (int32.tryparse(tmpstring[0].trim(), out extension)) { staticentry.directorynumber =

c - how to link against sse intrinsics when using icc on OS X -

c - how to link against sse intrinsics when using icc on OS X - not sure gcc, using clang can take address of sse intrinsic, without much trouble, unfortunately when seek same thing using icc on os x, fails, precise linker unable locate underlying function ... for example: sse.h: #include <immintrin.h> static __m128i (*load)(const __m128i *) = &_mm_load_si128; main.c: #include <stdio.h> #include "sse.h" int main(void) { char buffer[sizeof(__m128i)] __attribute__((aligned(sizeof(__m128i)))); __m128i b = load((void *)buffer); printf("%i\n", _mm_extract_epi16(b, 0)); homecoming 0; } to clear not want utilize macros, curious why this, main goal create dispatcher, preferably @ compile time, depending on how aggressive compiler optimizes, thats story. $ gcc main.c -o0 $ $ gcc --version configured with: --prefix=/applications/xcode.app/contents/developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 apple l

regex - Vim formula to leave only two first words in each line -

regex - Vim formula to leave only two first words in each line - how leave 2 first words (remove rest) in each line in vim? e.g. aa aa subst:pl:acc:m3+subst:pl:acc:n2 aa advertisement acta brev:npun into aa aa aa advertisement applied lines: :%s/\v^(\s*\s+\s+\s+).+/\1/ regex vim replace

websocket - Android Autobahn request.getHttpSession() = null -

websocket - Android Autobahn request.getHttpSession() = null - client side code: private void startpolling() { final string wsuri = mainasync.web_socket_host_ws+"/game"; seek { mconnection.connect(wsuri, new websockethandler() { @override public void onopen() { log.d(tag, "status: connected " + wsuri); int role = maccmeth.loadid(getapplicationcontext()); mconnection.sendtextmessage(string.valueof(role)); } @override public void ontextmessage(string payload) { log.d(tag, "got echo: " + payload); } @override public void onclose(int code, string reason) { log.d(tag, "connection lost."); } }); } grab (websocketexception e) { log.d(ta

html - How to use CSS Selector in Selenium Web Driver -

html - How to use CSS Selector in Selenium Web Driver - im trying element of table in project looks this: then css path this: #gridform > div > div:nth-child(2) > div > div > div.divtablerow > div > div.span11.leftalign my code this: webbrowser.current.findelement(by.cssselector("#gridform > div > div:nth-child(2) > div > div > div.divtablerow > div > div.span11.leftalign") but cant seem locate element. way tried using xpath still no luck. well depends.. class span11 unique? int case webbrowser.current.findelement(by.cssselector("div.span11"); should work. html css selenium xpath

arrays - How to read values in a text document and then make then parse them to ints in JAVA -

arrays - How to read values in a text document and then make then parse them to ints in JAVA - i'm trying read lines of text document , take average of numbers. plan first read info in text file. split string string array, parse each index int array. code point of reading document. my text doc: 3, 7, 24, 66, 10, 50, 20, 40, 100, 20, 69, 911, import java.io.bufferedreader; import java.io.file; import java.io.filenotfoundexception; import java.io.filereader; import java.io.ioexception; public class testing { public static void main(string[] args) throws ioexception { seek { string path; path = "testnumbers.txt"; file f = new file(path); filereader re = new filereader(f); bufferedreader in = new bufferedreader(re); string line = ""; string store = ""; while((line = in.readline()) != null) {

scala - Explanation of List[_] in pattern matching used in flatten function -

scala - Explanation of List[_] in pattern matching used in flatten function - i new scala , can not understand next function val l = list(list(1, 1), 2, list(3, list(5, 8))) def flatten(l: list[any]): list[any] = l flatmap { case ms:list[_] => flatten(ms) case l => list(l) } flatten(l) // res2: list[any] = list(1, 1, 2, 3, 5, 8) in particular not understand combination of flatmap , pattern matching , meaning of first case ms:list[_] can explain , maybe provide simpler illustration clarify concept? map , flatmap first of flatmap higher-order function. map higher order function convert list new list applying function on elements of list . illustration if have val l = list(1,2,3) you can map new list using val doubled = l.map(_ * 2) // list(2,4,6) so flatmap ? flatmap useful when function gets int returns list[int] . in case if pass function map li

java - Use count method and for each loop to count the number of element in the array -

java - Use count method and for each loop to count the number of element in the array - i know how count number of element in array without each loop, have utilize each loop this. i've got far. couldn't figure out how can utilize each loop count number of elements in array. outcome should 6. appreciate help. give thanks much. public class count{ public count(){ int a[] = {7, 8, 9, 9, 8, 7}; system.out.println(count(a)); } public int count(int count[]){ (int c : count) homecoming c; } } public int count(int count[]) { int = 0; (int c : count) { i++; } homecoming i; } this increment i 1 every element in array, , eventually, homecoming i , 6 (in case) java arrays methods foreach count

Scala list find and substraction -

Scala list find and substraction - my scala list below `enter code here list((192.168.11.3,a,1413876302036,-,-,up,,0.0,0.0,12,0,0,null0,up,0,0,4294967295,other), (192.168.11.3,a,1413876302036,-,-,up,,0.0,0.0,8,0,0,c,down,0,0,100000000,p), (192.168.1.1,a,1413876001775,-,-,up,,0.0,0.0,12,0,0,e,up,0,0,4294967295,other), (192.168.1.1,a,1413876001775,-,-,up,,0.0,0.0,8,0,0,f,down,0,0,100000000,e)) now want next operation, in list 3rd parameter changed in above 1413876302036 , 1413876001775. want subtracts below val sub = ((192.168.11.3,a,(1413876302036-1413876001775),-,-,up,,0.0,0.0,12,0,0,null0,up,0,0,4294967295,other),(192.168.1.1,a,(1413876001775-1413876001775),-,-,up,,0.0,0.0,12,0,0,e,up,0,0,4294967295,other)) how should calculate in scala after 15 minutes of reading question, think still don't understand it, if here answer: val list = list(("192.168.11.3",'a',1413876302036l,0,0,0), ("192.168.11.3",'a',1413876302

html - Making a pages content go full width in Drupal. -

html - Making a pages content go full width in Drupal. - i've removed blocks basic page has iframe embedded. how iframe spread total width of page instead of starting blocks ended? i have page running @ total width, believe editing stylesheet unnecessary. the problematic page found here the total width page link is: found here i need problematic page go total width. else created total width page, i'm unsure how created. thanks, sam #left { display: none; float: left; width: 212px; } #right { display: block; float: right; width: 100%; } this seemed work. html css iframe drupal drupal-7

java - On web scraping best practices -

java - On web scraping best practices - given: client side 1 - database 2 - coding language server side: 1 - website displaying own database results (a chronologically descending list of blog posts let's say, can alter if site/author updates post) each post having unique id not change. by , big have resources helped them understand how best approach problem? computationally type of work time consuming due nature of crawling website , waiting results (for me, @ least). my typical process (pseudo): for each page on url: each post on page: id = getid(post) data1...datan = getdata(post) phone call sql.execute("insert ... on duplicate key update") the sql part tedious , not efficient, , sense there must improve way accomplish doing in flow. the overall goal always: 1 - grab info care site (acknowledging here css/site can alter on average using xpath find data) , stop when have gotten point captured info (meaning: @ p

C++ query of JSON subObject error -

C++ query of JSON subObject error - my code compiles without error @ runtime next error -> testgetprice2.o: rapidjson/include/rapidjson/document.h:1125: rapidjson::sizetype rapidjson::genericvalue<encoding, allocator>::size() const [with encoding = rapidjson::utf8<>; allocator = rapidjson::memorypoolallocator<>; rapidjson::sizetype = unsigned int]: assertion `isarray()' failed. where failing in () loop std::cout << document[i]["lasttradeprice"]. i trying query subobject "lasttradeprice" accessing object incorrectly. how query subobject correctly/get rid of error? code -> #include "rapidjson/include/rapidjson/document.h" #include <iostream> #include <fstream> #include <stdio.h> #include <curl/curl.h> #include <unistd.h> #include <unordered_map> #include <string> using namespace rapidjson; struct mydata { std::fstream *file; std::string *str; };

R: create new variable, the new value are not correct -

R: create new variable, the new value are not correct - i creating new variable "hs" summarizing 4 variables "hs_a/b/c/d" in "data1" using: hs <- rep(5,length(data1)) attach(data1) hs[ hs_a == 2 & hs_b == 2 & hs_c==2 & hs_d==2 ] <- 0 hs[ hs_a == 1 & hs_b == 2 & hs_c==2 & hs_d==2 ] <- 1 hs[ hs_b == 1 & hs_a == 2 & hs_c==2 & hs_d==2 ] <- 2 hs[ hs_c == 1 & hs_a == 2 & hs_b==2 & hs_d==2 ] <- 3 hs[ hs_d == 1 & hs_a == 2 & hs_b==2 & hs_c==2 ] <- 4 hs1<-data.frame(hs_a,hs_b,hs_c,hs_d,hs) i want other values in hs 5 , if not 0/1/2/3/4, utilize rep 5. problem that, values in hs na , whereas think should 5 . there no na in data1 , , have checked rows hs of na using ( which(!!rowsums(is.na(hs))) ). #[1] 1545 1646 1687 1744 1784 1817 , " 1212na " " 1112na " " 1112na " " 1112na "" 1112na "" 1112na ". can h

email - Create and mail temporary pdf in php -

email - Create and mail temporary pdf in php - when clicking button pdf generated , opens pdf in web browser. pdf stored temporary in variable , included in mail service attachment when buttons clicked. i'm struggling how save , attach file. <a class="button" href="http://mydomian.com/pdf001.php">send pdf</a> <?php $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'from: webmaster@example.com' . "\r\n" . 'reply-to: webmaster@example.com' . "\r\n" . 'x-mailer: php/' . phpversion(); mail($to, $subject, $message, $headers); ?> like comment under original post say use phpmailer <?php require_once('../class.phpmailer.php'); $mail = new phpmailer(); // defaults using php "mail()" $mail->addreplyto("name@yourdomain.com","first last&qu

AngularJS ui-router, how to get the name of the targeted state in the resolve object of an abstract partent state? -

AngularJS ui-router, how to get the name of the targeted state in the resolve object of an abstract partent state? - i using ui-router , have kid states , abstract 1 - parent. now, want able user role management , want in single place, roots. the best way it, in parent's state resolve object.$stateprovider here, mange app width authentication data. the question is, how targeted state resolve function of abstract state? .state('section', { abstract: true, template: '<ui-view/>', resolve: { // auth & role management middleware. userdata: ['$q', '$stateparams', 'session', function ($q, $stateparams, session) { // how destination route here. $state.current.name - returns null $stateparams - empty object. // ideas? var userdata; userdata = session.getuserdata();

php - which one is better to run laravel? -

php - which one is better to run laravel? - i have installed laravel in cpanel , localhost, found 2 way execute/run laravel. access /public/ use php artisan serve if run in notebook/localhost can utilize php artisan serve , done routing , database, in cpanel cant utilize sec way, must utilize first way, not done routing , etc. so 1 improve , how create first way run well? normally, use php artisan serve on development environment only. on production servers, add together <virtualhost> or alias drective in apache configuration. <virtualhost *:80> serveradmin admin@localhost documentroot /path/to/your/laravel/public servername your.domain.com <directory /path/to/your/laravel/public> allowoverride none order allow,deny allow options followsymlinks rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d

perl - How to select the specific row that matched a specific variable in excel? -

perl - How to select the specific row that matched a specific variable in excel? - i got list of variables stored in array. know how select specific columns , rows want select specific row matched variables in array (assume variables unique, appear in excel once). possible , how can done? excel: name code age john 0123 18 ean 1234 19 my code now: use strict; utilize warnings; utilize spreadsheet::parsexlsx; @name = ("john", "tommy", "ming", "ean"); ##loop through array , search in excel## foreach $test (@name) { $parser = spreadsheet::parsexlsx->new(); $workbook = $parser->parse('c:\namelist.xlsx'); if ( !defined $workbook ) { die $parser->error(), ".\n"; } $worksheet ( $workbook->worksheets('name list') ) { ( $row_min, $row_max ) = $worksheet->row_range(); ( $col_min, $col_max ) = $worksheet->col_range(); $row ( $row_min .. $row_max ) {

android - Astuetz's PagerSlidingTabStrip library still doesn't slide the tabStrip -

android - Astuetz's PagerSlidingTabStrip library still doesn't slide the tabStrip - i've added pagerslidingtabstrip library project, next guide strip under tabs doesn't slide (i'm referring have can see in google play app). here mainactivity: mviewpager = (viewpager) findviewbyid(r.id.pager); mviewpager.setadapter(mcollectionpageradapter); pagerslidingtabstrip tabs = (pagerslidingtabstrip) findviewbyid(r.id.tabs); tabs.setviewpager(mviewpager); mviewpager.setonpagechangelistener(new viewpager.simpleonpagechangelistener() { @override public void onpageselected(int position) { actionbar.setselectednavigationitem(position); } }); (int = 0; < mcollectionpageradapter.getcount(); i++) { actionbar.addtab(actionbar.newtab() .settext(mcollectionpageradapter.getpagetitle(i)) .settablistener(this)); } edit: activity_main.xml: <relativelayout

python - Configuring Gunicorn: No application module specified -

python - Configuring Gunicorn: No application module specified - i'm trying deploy django project nginx , gunicorn. maintain getting 502 bad gateway. i've been working nonstop on past few days , can't seem deployed. i've gone through 3 tutorials on digital ocean, aren't correct, obviously. i maintain getting 502 bad gateway, or if seek utilize manage.py runserver, 400 bad request. i think problem gunicorn. when come in gunicorn -config, says usage: gunicorn [options] [app_module] gunicorn: error: no application module specified. every bit of documentation can find says type gunicorn wsgi:application, when do, says "workers failed boot." how set application module? assuming have nginx proxying port 8001, want this: gunicorn -b 127.0.0.1:8001 your_project_name.wsgi:application you need run project folder (where manage.py file is) python django nginx gunicorn digital-ocean

curl - CURLOPT_INTERFACE not working in php -

curl - CURLOPT_INTERFACE not working in php - i not able bind ip addresses set in network interface the next command works curl --interface 41.141.41.23 https://www.google.com but $toset[curlopt_interface] = "41.141.41.23 "; in php doesn't work , throw bind failed errno 22: invalid argument i sure $toset[curlopt_interface] = "41.141.41.23 "; right way utilize multiple address in application have confirm coder , many people using same way without issue my curl version : curl 7.19.7 "41.141.41.23 " => "41.141.41.23" there space; php curl

r - Error in : object of type 'closure' is not subsettable -

r - Error in <my code> : object of type 'closure' is not subsettable - i able work out code my scraping. seemed working fine , of sudden when ran again, got next error message: error in url[i] = paste("http://en.wikipedia.org/wiki/", gsub(" ", "_", : object of type 'closure' not subsettable i not sure why changed nil in code. please advise. library(xml) library(plyr) names <- c("george clooney", "kevin costner", "george bush", "amar shanghavi") for(i in 1:length(names)) { url[i] = paste('http://en.wikipedia.org/wiki/', gsub(" ","_", names[i]) , sep="") # parsing code } in general error message means have tried utilize indexing on function. can reproduce error message with, example mean[1] ## error in mean[1] : object of type 'closure' not subsettable mean[[1]] ## error in mean[[1]] : object of type 

sql server - T-SQL EXEC versus sp_exec -

sql server - T-SQL EXEC versus sp_exec - i tried following: declare @var2 nvarchar(30) declare @qsql nvarchar(100) set @var2 = n'iddelegat' exec ('select max('+ @var2 + ') idexec delegat'); set @qsql = 'select max(@varsp) idspexec delegat'; exec sp_executesql @qsql, n'@varsp nvarchar(30)', @var2; and result: idexec idspexec ----------------------- 500038 iddelegat i not understand why sp_executesql not homecoming same result execute . right returned values in execute statement. seems sp_executesql not evaluate string 'iddelegat' homecoming column. you cannot parameterize column names or table names when using sp_executesql . so, when plug in value iddelegat in exec() , getting column. when have parameter sp_executesql , getting 'iddelegat' -- string name of column. the issue of can parameterize not explained in sql documentation. if dig far enough, this: where can util

javascript - Disable Firefox OS keyboard autohiding when touching outside the keyboard -

javascript - Disable Firefox OS keyboard autohiding when touching outside the keyboard - when tap input field in firefox os, on screen keyboard comes up. developing messenger app , have toolbar borders on-screen keyboard "send" button. when tap send button, keyboard automatically closes not want (the user may have come in more messages). how prevent keyboard closing when outside touch detected? have searched on net , cannot find reply (though seems marketplace apps have behaviour). you can seek create hidden input receives focus 1 time visible input field loses it. class="snippet-code-js lang-js prettyprint-override"> var input = document.getelementbyid("text"); var trap = document.getelementbyid("trap"); input.addeventlistener("blur", function() { trap.focus(); }, false); class="snippet-code-css lang-css prettyprint-override"> #trap { position: absolute; width: 1px;

Is VBScript or JavaScript more handy for writing scripts for Enterprise Architect? -

Is VBScript or JavaScript more handy for writing scripts for Enterprise Architect? - i did complex info gathering in enterprise architect. want automatise writing script. since have start scratch can freely take scripting language use. ea best supports scripting in javascript , vbscript seems easiest take 1 of them. is either: microsoft vbscript or javascript / microsoft jscript a more handy selection writing new ea-script? like "are there more ea examples built on 1 of them?" or "is either improve supported ea script editor?" note: i not looking reply question "which 1 improve javascript or vbscript?" highly debatable. both languages indeed equal in offer. vbscript has slight advantage in that most of documentation in ea help file written examples in vb, resembles syntax used in vbscript. it easier create input dialog vbscript jscript according this post on sparx forum javascript vbscript automation jscript e

python - How to say something when a particular value you're looking for is not in a list -

python - How to say something when a particular value you're looking for is not in a list - i'm working on assignment school , got done i'm missing little crucial piece. so total assignment user come in in values grades pupil gets list, user must able see average of particular subject or printed out version of grades students got subject. my problem how set tell user there isn't values particular subject when selects see avg/all values subject. i'll show here got list has values in, there's no need go through whole process of putting them in cijfers = [ [ 12345, 'wiskunde', 8.9], [ 12345,'elnet', 4.0], [12345, 'python', 8.9], [98761, 'wiskunde', 6.5], [98761, 'elnet', 7], [98761, 'python', 4.5], [20945, 'wiskunde', 5],[20945, 'elnet', 6.9], [20945, 'python', 4.5], [65489, 'wiskunde', 3.4], [65489, 'elnet', 6.7], [65489, 'python', 10]] first 1 stand

apache commons lang - Convert any number string(int, float, double, long, etc) to appropriate numeric (int, float, double, long, etc) value in java -

apache commons lang - Convert any number string(int, float, double, long, etc) to appropriate numeric (int, float, double, long, etc) value in java - is there improve practice convert input number string (int, double, etc) it's respective wrapper object/primitive type in java? using valueof() or parsexxx() methods can achieved. should knowing underlying string format before selecting appropriate type. what doing parsing number string long, using numberutils commons-lang.jar follows: long longvalue= (long) numberutils.tolong(numberstring); but problem if numberstring has double value, fails parse number , homecoming 0.0 parsed value. next statement works fine double values : long longvalue = (long) numberutils.todouble(numberstring); is there generic way of doing this? don't care digits after decimal. thanks reading. update this looks elegant solution me, suggested @thomas : numberformat numberformat = numberformat.getnumberinstance(); long

asp.net - Dynamic Bootstrap Accordian loads in show -

asp.net - Dynamic Bootstrap Accordian loads in show - i have bootstrap accordion generated dynamically code behind. loaded during page_init. works except set open ('show') not closed ('hide'). if take generated markup , run it, works fine html ok. ideas? thanks ============== edit ============ this script resolves problem private sub sectionclose() seek dim sb new stringbuilder sb.append("$(document).ready(function(){") sb.append(" $('#accordion').accordion({ collapsible: true, active: false }); ") sb.append("$('.selector').accordion(); ") sb.append("}); ") scriptmanager.registerstartupscript(me, me.gettype(), "showcollapse", sb.tostring, true) grab ex exception dim verror new senderror verror.mailerror("214", pagename, ex) end seek end sub and works perfectly, throws object doesn't back upwar

javascript - After redirecting to another state using ui-router success/failure of old requests still launch -

javascript - After redirecting to another state using ui-router success/failure of old requests still launch - i have web page created using angular ui-router. works well, have 1 problem. i have 1 view makes lot of separate calls different web servers. if of web servers returns 401 want redirect user login page. servers have sso, user has login once. sample code requests follows: request.success(function(data) { //do }).error(function(data, status, headers, config) { errorservice.basicerrorhandler(request.url, data, status, headers, config); }); and basicerrorhandler that(only relevant part): if (status === 401 || status === 403) { $location.path('/login'); } now happens: user redirected /login 1 of request /secured-page user decides not log in, , goes part of page doesn't require authentication, /landing-page one of requests made /secured-page comes now, because 1 of servers slow in delivering result. gets 401, user gets redirect

c++ - int to void* - avoiding c-style cast? -

c++ - int to void* - avoiding c-style cast? - i need cast int (which specifies byte offset) const void* . solution works me c-style casts: int offset = 6*sizeof(glfloat); glvertexattribpointer(1,3,gl_float,gl_false,0,(void*)offset); i want rid of c-style cast, dont't find working solution. tried static_cast<void*>(&offset) and compiles, cannot right solution (whole output different approach). here right solution? link documentation of glvertexattribpointer : link considering it's hopeless case (see link provided derhass), best approach concentrate questionable code in 1 place, tack appropriately snide remark onto , @ to the lowest degree maintain remaining code clean: /** * overload/wrapper around opengl's glvertexattribipointer, avoids * code smell due shady pointer arithmetic @ place of call. * * see also: * https://www.opengl.org/registry/specs/arb/vertex_buffer_object.txt * https://www.opengl.org/sdk/docs/man/html/glvertex

javascript check if function parameter meets a condition -

javascript check if function parameter meets a condition - i'm trying write basic "quest" function , have run few issues. this i've done far js var clicks = 0; var coins = 10; var quests = function(type, required, reward, message) { this.type = type; this.required = required; this.reward = reward; this.message = message; this.quest = function() { if (this.type >= this.required) { coins += this.reward; homecoming this.message; } else { alert('you don\'t have plenty ' + required); } }; }; quest1 = new quests(clicks, 10, 50, 'you completed quest!'); quest2 = new quests(clicks, 5, 50, 'you completed quest!'); thequests = [quest1, quest2]; $(document).ready(function() { $('#click').click(function() { clicks += 1; $('#queststuff').text(clicks); }); $('#quest').click(function() { $('#q

Creating a method to modify elements in an array in Ruby with 2 arguments, one of them being the original array -

Creating a method to modify elements in an array in Ruby with 2 arguments, one of them being the original array - i create method, mod_method(array, n) , array array , n number. mod_method should take number n , add together internal numbers in array , homecoming new array. for example, using array = ["i", "have", 3, "to", 4, "hours"] , how find mod_method(array, 1) such mod_method(array,1) => ["i", "have", 4, "to", 5, "hours"] i'm noob , able using defined array , number (let's utilize 1), such: array = ["i", "have", 3, "to", 4, "hours"] =>[[0] "i", [1] "have", [2] 3, [3] "to", [4] 4, [5] "hours"] numbers = array.values_at(2, 4) => [ [0] 3, [1] 4 mod = numbers.map{|x| x + 1} => [ [0] 4, [1] 5] new_array = ["i", "have", mod[0], "to",

c - How to look for a change in a file without polling? -

c - How to look for a change in a file without polling? - i have beagle bone , want read gpio pin program. file either contains 1 or 0 @ given moment. in c programme have while loop runs forever sleep function maintain beingness cpu pig whenever pin low(0) , when high(1) runs the code. sense wasteful of resources. there way can see when file 1 , run code? don't polling, when beagle bone going battery powered. use notification mechanism, illustration utilizing libev. the basic thought is, callback called, if info available. if not work might need utilize other apis there, illustration inotify. example courtesy of libev docs: // single header file required #include <ev.h> #include <stdio.h> // puts // every watcher type has own typedef'd struct // name ev_type ev_io stdin_watcher; ev_timer timeout_watcher; // watcher callbacks have similar signature // callback called when info readable on stdin static void stdin_cb (ev_p_ ev_io *w

How precise control the total time of jssor slider? -

How precise control the total time of jssor slider? - i making slide, comprises plurality of pictures, total number of image changing, same length of time, illustration 10 seconds. utilize parameter $ slideduration , $duration , $autoplayinterval can not above results. picture number change, sliding effect change, total length of time constant, how configure? jssor

xml - How to deal with the symbol & in labels or strings in OpenERP? -

xml - How to deal with the symbol & in labels or strings in OpenERP? - i trying remove tab standard form of partners. tab want remove sales & purchases . removed each 1 of siblings without problem, cannot same one. , because symbol &. error of xml invalid architecture . i tried these 2 lines: <xpath expr="/form//notebook//page[@string='sales &amp; purchases']" position="replace"/> and: <xpath expr="/form//notebook//page[@string='sales & purchases']" position="replace"/> always same error. knows how this? try this, work generally, can utilize this, <page string="string name" position="replace"> <!-- here can define replace page --> </page> for sales &amp; purchases, per knowledge, should not replace sales & purchases tab because in tab, many field configurable. go replace problems occurs like: active, opt-out , r

php - Advanced Custom Fields: dirname( __FILE__) returning wrong URL on shared server for CSS and JS includes -

php - Advanced Custom Fields: dirname( __FILE__) returning wrong URL on shared server for CSS and JS includes - i'm adding advanced custom fields pro (v5) simple plugin i'm creating. i'm using tutorial on acf website: distributing acf in plugin/theme. tutorial calls using get_stylesheet_directory() , theme. replaced dirname(__file__) . in step 3, include_once works fine dirname(__file__) . steps 1 , 2 work including files, run issue when javascript , css files included acf. returns urls following: http://example.com/templates/wp-starter/nfs/c05/h03/mnt/70376/domains/example.com/html/templates/wp-starter/wp-content/plugins/simple/acf/css/global.css?ver=5.0.0 this get: http://example.com/templates/wp-starter/wp-content/plugins/simple/acf/css/global.css?ver=5.0.0. i using media temple's grid server (shared hosting). here relevant code plugins/simple/simple.php : // 1. customize acf path add_filter('acf/settings/path', 'my_acf_settings

mysql - Warning: PDO::__construct() expects at least 1 parameter, 0 given in C:\xampp\htdocs\Svetaine\functions.php on line 43 -

mysql - Warning: PDO::__construct() expects at least 1 parameter, 0 given in C:\xampp\htdocs\Svetaine\functions.php on line 43 - hello i'm new on pdo , have problem, can somoeone help me? public function counters() { $dbh = new pdo(); $sql = "select * news order id"; $dbh->query($sql); echo ' <div class="row2"> <h1>svarbios naujienos:</h1> <p></p>'; $count = $c->rowcount(); $s = 0; if($count > 0) { foreach ($dbh->query($sql) $row) { echo ' <p>'.$row['naujiena'].'</p>'; } } echo ' </div> <div class="row2img"> <img src="images/slide2.jpg" width="864" height="210"> </div> '; homecoming 1; } thanks helping error line $dbh->query($sql); try this, replace informations data

Login and registration form in Laravel 5 -

Login and registration form in Laravel 5 - i start larn new laravel , trying larn it, building little project, create starter site, have problem. create new project without plugin. have problem login , register form. set route file: get('user/login', 'auth\authcontroller@showloginform'); post('user/login', 'auth\authcontroller@postlogin'); get('user/register', 'auth\authcontroller@showregistrationform'); post('user/register', 'auth\authcontroller@register'); and create login , register form. shows me forms, can't submit , not know how insert database or how validate user credentials. can tell me how in new beta laravel framework? problem laravel shows me login , register form. when click submit didn't nothing, refresh page. set method="post" action="" forms. when alter public function register(registerrequest $request) into public function register() in app\http\

spring mvc - in jsp using angularjs $http the url is unreadable code -

spring mvc - in jsp using angularjs $http the url is unreadable code - here app.js: class="lang-js prettyprint-override"> var loginmodule = angular.module('loginmodule',[]); loginmodule.config(['$httpprovider', function ($httpprovider) { $httpprovider.defaults.headers.post['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'; }]); loginmodule.controller('loginctrl',function ($scope,$http,$parse){ $scope.signin_user = {name:"",password:""}; $scope.errors = []; $scope.submit = function(){ if($scope.login_form.$valid){ var info ="name="+$scope.signin_user.name+"&password="+$scope.signin_user.password; $http({ method:'post', url:'${ctx}/login', data:data }) .success(function(data,status){ console.log(data);

python - Printing utf-8 in windows cmd -

python - Printing utf-8 in windows cmd - i building battleships game in python , printing function (the user can print board) includes utf-8 character borders. the file: # -*- coding: utf-8 -*- __future__ import print_function import random import numpy import ascii_art row_len = 10 def print_board(board): print (ascii_art.game_on + '\n', end="") in range(0, row_len - 1): print (' _______', end="") print(' _______ \n', end="") x in range(0, row_len): y in range(0, row_len): print ('│ ', end="") if board[x][y] != 'e': print (board[x][y], end="") else: print (' ', end="") print(' ', end="") print('│\n', end="") j in range(0, row_len - 1): print(' ¯¯¯¯¯¯¯', end="")

How to call a variable from nested function in Jquery -

How to call a variable from nested function in Jquery - i wanted value of chkarray variable when called outside method. when called getvalues().total outside method getting error message cannot read property total of undefined. function getvalues(){ chkarray = new array() ; $("input[type=checkbox]:checked").each(function fire() { var total = chkarray.push($(this).val()); console.log(chkarray) }); }; kindly, help how phone call variable outside method class="snippet-code-js lang-js prettyprint-override"> function getvalues() { var total = new array(); $("input[type=checkbox]:checked").each(function() { total.push($(this).val()); }); homecoming total; }; function dosomething() { var k = getvalues(); console.log(k); } class="snippet-code-html lang-html prettyprint-override"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></scrip

android - AlertDialog inside Fragment is not closed when button is pressed -

android - AlertDialog inside Fragment is not closed when button is pressed - i have fragment within i'm using alertdialog. there no problem in closing of alertdialog in activity when used same code in fragment, alertdialog doesns't closes until press button minimum 3 times. also after press ok button, alertdialog freezes 2 sec toast msg displayed. dialog doesn't closes. i tried using dialog.dismiss() . problem remains same. here checkfragment class. public class checckfragment extends fragment implements onitemselectedlistener { private static alertdialog alertdialog; private context context @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); context = this.getactivity(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { //other codes.... view btncheck = (button) rootview.findviewby