Posts

Showing posts from May, 2011

Writing text to a file [PHP, HTML] -

i want write text bottom of existing text file don't have clue how it. i have tried code below don't work. text file location c:\inetpub\wwwroot\test.txt <?php if(isset($_post['submit'])){ $email = $_post['email']; $file = fopen("c:\inetpub\wwwroot\test.txt\\","a+"); fwrite($file,$email); fclose($file); print_r(error_get_last()); } ?> <form action= "" method="post" name="form"> <input type="text" name="email"> <br> <br> <input type="submit" name="submit" value="submit"><br> </form> what doing wrong? try file_put_contents("file_path", your_content, file_append); so in case... <?php if(isset($_post['submit'])) { $email = $_post['email']; file_put_contents("c:\inetpub\wwwroot\test.txt",

java - No resource found that matches the given name -

i know many others have experienced similar issue , found these questions similar issue: android support library v7: error retrieving parent item error: error retrieving parent item: no resource found matches given name 'widget.appcompat.actionbutton' the problem tried different solutions offered in answers such changing target sdk 14 or 15, , cleaning , rebuilding project. using intelij , havent been able make following errors disappear: error retrieving parent item: no resource found matches given name 'widget.appcompat.actionbutton' error retrieving parent item: no resource found matches given name 'widget.appcompat.light.actionbutton' are there other things can try attempt correct these errors? suggestions appreciated maybe not including support library project. also have @ question use appcompat library actionbar support

java - Method taking in 2 arguments (array of ints, and a single int) -

i've created method, that, given array of numbers , integer n, calculates longest occurrence of integer n. example 1 0 0 0 1 1 1 1 , given number 1, longest sequence 4. i'm using 0's , 1's @ moment keep simple, i'm stuck on implementing main method test function - i'm not sure how separate integer "n" , array of ints when reading command line, , i'm hoping given pointers/help. here's code: public class oneb { public static int longestseq(int[] nums, int n) { int max = 0; int curlength = 0; (int = 0; < nums.length; i++) { if (i == n) { curlength++; if (curlength > max) max = curlength; } else curlength = 0; } return max; } public static void main(string[] args) { int[] nums = new int[args.length-2]; int n = integer.parseint(args[args.length-1]); (int = 0; args.length-1 > i; i++) { nums[i] = integer.parseint(args[i]

android - ListView Removing Item is not working -

i have app wishlistactivity, reason, when click on remove button, removes 1 last on list. this wishlistactivity: public class wishlistactivity extends listactivity { static arraylist<string> list; arrayadapter<string> arrayadapter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // creates new arraylists , populates sharedpreferences prefs = wishlistactivity.this.getsharedpreferences("com.ben.sizeit", context.mode_private); arraylist<string> samplelist = new arraylist<string>(); samplelist.add("sample item 1"); samplelist.add("sample item 2"); set<string> sampleset = new hashset<string>(); sampleset.addall(samplelist); set<string> set = prefs.getstringset("wishlist", sampleset); list = new arraylist<string>(set); // create adapter passing arraylist 3rd parameter arrayadapter = new wishlistad

java - I am trying to compare strings, but it is not recognizing -

so trying check strings using if statement,i created test computer gives predetermined responses depending on input, inputs working happen hi or hello, strings spaces not seem work, why that? import java.util.scanner; public class computabot { public static void main(string[] args) { scanner scan = new scanner(system.in); string text; string computer = "computabot:"; string[] input = { "how you?", "hi", "hello", "what name", "do chicken?", "where from?", "do cheese?" }; do{ system.out.println("type talk!:"); text = scan.next(); if (text.equals(input[1]) || text.equals(input[2])) { system.out.println(computer + " " +"hello!"); }else if (text.equalsignorecase(input[0])) { system.out.println(computer + " " +"i'm fine, you?!"); }else if (text.eq

Why Error in colSums(x, na.rm = T) : invalid 'na.rm' argument in R -

i try calculate sum of each column data x. got error "error in colsums(x, na.rm = t) : invalid 'na.rm' argument" why na.rm argument not work in case?? confused... x <- cbind(x1 = 3, x2 = c(4:1, 2:5)) x[3, ] <- na; x[4, 2] <- na rowsums(x) colsums(x, na.rm=t) i able recreate bug overriding usual value of t equal na : > t=na > colsums(all,na.rm=t) error in colsums(all, na.rm = t) : invalid 'na.rm' argument so likely, (or funny co-worker?) have defined variable t somewhere in code equal na . undo it, type: t=true or better: rm(t) never forget r doesn't know t => shorthand defined convenience @ startup, nothing more.

javascript - How to change the URL when paging using UI Router? -

i have angular js project using angular ui-router going great trying implement ui bootstrap pagination directive , can't work out correct strategy. i have table of data shown 1 page @ time , have pagination directive in place showing correct number of page links. when click link gets new page number , makes restangular call api new records , binds them table. that's working well, when page through data url doesn't change user can't use browser back/forward buttons navigate history. ideally use following urls: /contacts /contacts/page-2 /contacts/page-3 i include sorting in url that's question. i achieve manually transitioning new state when 1 of pagination buttons clicked, reload controller , of it's contents, making additional ajax calls server , making ugly flashes of un-styled content recreated pagination control etc. ideally able change url , add history state without triggering actual state change , reloading/running controller view. i'm

actionscript 3 - TypeError: Error #2007: Parameter hitTestObject must be non-null. Platform flash game -

now i'm having problems flash game going level two. problem started when added container locked door , key. game in working condition sprites work, getting key in level 1 works , unlocking works. trying level 2 becomes pain. me please. typeerror: error #2007: parameter hittestobject must non-null. at flash.display::displayobject/_hittest() @ flash.display::displayobject/hittestobject() @ thehunterwithinv0_scene1_fla::maintimeline/loop() error comes when object removed stage, should check reference of object passing in hittestobject.

html - Posts on Tumblr page not working -

i'm working on tumblr theme , of post types showing up. if makes difference, ones work (titles, text posts, , photosets) first things written in code , rest doesn't show up. here's html posts looks like: {block:posts} <div class="posts"> {block:title}<div class="titles">{title}</div>{/block:title} {block:text}{body}{/block:text} {block:photo} {linkopentag} <a href="{permalink}"><img src="{photourl-500}" alt="{photoalt}" width="100%" /></a> {linkclosetag} <br>{block:caption}{caption}{/block:caption} {/block:photo} {block:panorama} {linkopentag} <a href="{permalink}"><img src="{photourl-panorama}" alt="{photoalt}"/></a> {linkclosetag} <br>{block:caption}{caption}{/block:caption} {/block:panorama} {block:photose

javascript - Gulp, Mocha, Watch Not Reloading My Source Files -

i attempting gulp working automate unit testing. have following gulp file. var gulp = require('gulp'), mocha = require('gulp-mocha'); gulp.task('unit', function() { return gulp.src('test/unit/**/*.js') .pipe(mocha({ reporter: 'spec' })) .on('error', handleerror); }); gulp.task('watch', function() { gulp.watch(['src/**/*.js', 'test/unit/**/*.js'], ['unit']); }); gulp.task('test', ['unit', 'watch']); when run 'gulp unit', tests run fine. when run 'gulp test', tests run, , appears 'watch' working. if make change 1 of test files, tests rerun correctly, taking account changes made in test file. if make changes source files, tests re-run, not run against updated version of source file. my thought somehow, source file being cached, cannot find others seem have had issue or find solution. thanks helping gulp/node/mocha ne

vb.net - Determine digits decimal point -

i working on simple vb.net application allows users enter decimal number (ex - 1.23) , program lists digits left , right of decimal , how many actual digits left , right of decimal. here code looks far. dim imput string imput = txtenternumber.text dim d integer d = txtenternumber.text.indexof(".") txtnumleft.text = imput.remove(d) txtnumright.text = imput.remove(0, d) txtdigitleft.text = cstr(imput.substring(0, d).length) txtdigitright.text = cstr(imput.substring(d).length) when run program includes decimal point digits right of decimal , how many digits right of decimal. why this? thanks! try this dim imput string imput = txtenternumber.text dim d integer d = txtenternumber.text.indexof(".") txtnumleft.text = imput.remove(d) txtnumright.text = imput.remove(0, d + 1) txtdigitleft.text = cstr(imput.substring(0, d).length) txtdigitright.text = cstr(imput.substring(d + 1).length)

math - Optimize mathematical library (libm) -

have tried compile glibc -march=corei7 see if there's performance improvement on version comes default linux x68_64 distribution? gcc compiled -march=i686 . think (not sure) mathematical library compiled same way. can confirm this? most linux distributions x86 compile using i686 instructions, asking scheduling them later processors. haven't followed later developments. a long while different versions of system libraries according processor lines common, performance differences deemed small cost. , machines got more uniform in performance meanwhile. one thing has remembered today's machines memory bound . i.e., today memory access takes few hundred times longer instruction, , gap growing. not mention machine (an oldish laptop, top-of-the-line 2 years back) has 4 cores (8 threads), battling data/instructions memory. making code run tiny bit faster, cpu can wait longer ram, isn't productive.

types - Go Initialization operator, package scoped variables - confused: -

the following code works correctly - output: you chose test 1 package main import ( "fmt" ) type tnamemap map[int]string var namemap tnamemap func init() { namemap = make(tnamemap) namemap[1] = "you chose test 1" namemap[2] = "you chose test 2" namemap[3] = "you chose test 3" } func main() { fmt.println(namemap[1]) } if comment out first line in init() i.e //namemap = make(tnamemap) , panic when main() runs, because namemap never initialized: panic: runtime error: assignment entry in nil map but - if in init() write namemap := make(tnamemap) instead of namemap = make(tnamemap) , no panic, no output - main() runs , process terminates. i understand if use initialization operator - namemap := make(tnamemap) - have declared new variable namemap scoped init() function , package level variable var namemap tnamemap in scope main() , resulting in no output, because package level var holds

c - Error in CloudPebble, "ld returned 1 exit status" -

so, i'm trying make pebble app generates random string when press button. i'm pretty sure have pebble code right, i'm not sure error: /sdk2/[long stuff here]/ in function `_sbrk_r': /home/[more long stuff]: undefined reference `_sbrk' collect2: error: ld returned 1 exit status waf: leaving directory `/tmp/tmpx94xy7/build' build failed and here's code: #include <pebble.h> #include <stdlib.h> #include <stdio.h> window *window; textlayer *text_layer; char* one[] = {"string1", "stringone", "stringuno"}; char* two[] = {"string2", "stringtwo", "stringdos"}; char* three[] = {"string3", "stringthree", "stringtres"}; char* four[] = {"string4", "stringfour", "stringcuatro"}; int length1 = sizeof(one)/sizeof(*one); int length2 = sizeof(two)/sizeof(*two); int length3 = sizeof(three)/sizeof(*three); int length4 = sizeof(f

How to Increase the size of a cell text in string grid of delphi? -

i using string grid has 5 column, want in crease text font size of 3 rd column how that? while not sqlquery.eof begin stringgrid1.cells[0,rowcount] := sqlquery.fieldbyname('elementname').asstring ; stringgrid1.cells[1,rowcount] := sqlquery.fieldbyname('elementtype').asstring ; stringgrid1.cells[2,rowcount] := sqlquery.fieldbyname('elementstring').asstring ; stringgrid1.cells[3,rowcount] := sqlquery.fieldbyname('blockname').asstring ; stringgrid1.cells[4,rowcount] := sqlquery.fieldbyname('attributes').asstring; rowcount := rowcount + 1; stringgrid1.rowcount := stringgrid1.rowcount + 1; sqlquery.next; end; this quite old example, suspect nothing has changed http://www.delphipages.com/forum/showthread.php?t=142691

php - Insert html to .docx -

Image
i use phpoffice/phpword work document templating, example can found here: https://github.com/phpoffice/phpword/blob/master/samples/old/template.php . the problem need insert formatted text html code generated wysiwyg editor. can't do: $document->setvalue('value1', '<span>sun</span>'); document generation error, guess because library can't parse html along openxml. need is, probably, convert html first openxml, tried get: i don't know. idea or suggestion how deal ? apreciated. thanks.

html - conditional css not working correctly? -

i have used condition css internet explorer show auto cursor in internet explore not working correctly have used following code link <!--[if ie]><link rel="stylesheet" href="newstyle_ie.css" media="screen" type="text/css" /><![endif]--> i have show default cursor in internet explore uses body{ cursor:auto !important;} and other browsers have used body{ cursor:url("some url");} any hint ??? your conditional comment ok, should check cursor url, , set fallback value(i.e. pointer, separated comma), in case first cursor isn't found. check path css file

ios - Afnetworking 2 with parameters -

i new ios developments..i want json response web service. when searched found afnetworking that. downloaded , did sample application. need pass parameters service . service takes 2 parameters [username , password]. url http://myweb.mobile.com/webservices/appointmentservice.asmx/getvaliduser can please give me code sample how pass parameters service json response ? i have tried code.. wont take parameters.. people telling afhttpclient.. im using afn 2.0.. there no class call afhttpclient here .. i'm conduced here....please me nsurl *url = [nsurl urlwithstring:@"https://maps.googleapis.com/maps/api/place/textsearch/json?query=restuarants+in+sydney&sensor=false&key=aizasydn9a-evj875ymxzeinmup7cwbo9yt1w2s"]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; // 2 afhttprequestoperation *operation = [[afhttprequestoperation alloc] initwithrequest:request]; operation.responseserializer = [afjsonresponseserializer serializer]; [operation setcomplet

php - How to disable process isolation in Symfony2 -

i have tested methods using phpunit, done , working fine, of methods not working , need disable process isolation, finding how disable this, not getting idea disable it, please tell me if have know how disable process isolation in symfony2? thanks look "processisolation" property in phpunit.xml.dist file , set it's value "false" the file located in symfony project's "app" folder.

html - Keep audio player loaded while changing pages, jQuery circle player -

i have jquery circle player want stick top of website. problem when user moves 1 page another, audio stops playing because being reloaded. possible keep audio player "stuck" , loaded when user moves page in site? want "fixed" div cross page without having open new page player in it. don't know if possible or how difficult be. here player: <div id="cp_container_1" class="cp-container" style="background:none;"> <img id="bg_image" class="bg_image1 cp-play" src="jquery.jplayer.2.2.0/v11/circle.skin/jplayer_bg_blue.png" /> <img id="bg_image" class="bg_image1_5 cp-pause" src="jquery.jplayer.2.2.0/v11/circle.skin/jplayer_bg_image_green.png" /> <img id="play_bg" src="jquery.jplayer.2.2.0/v11/circle.skin/jplayer_play_bg.png" height="57" width="56" /> <div class="cp-progress-holder&

postgresql - recompiling database.yml file with gemfile? ruby on rails -

i'm new ruby on rails , postgresql , had question. database.yml file compiled when run bundle install on gemfile? gemfile had sqlite3, changed pg , tried run bundle install again recompile database.yml file, file still says it's using sqlite. development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 i want adapter switched postgresql , believe other fields should switched when using pg, i'm unsure. can clarify me, thank you. no, database.yml not recompiled automatically. when change gem in gemfile , need change file: development: adapter: postgresql database: dbname username: user password: password encoding: unicode

How to get ID of listview item Clicked. [javascript / jquery / jquery mobile] -

i need advice on how detect <li> tap/click user, write 'id' of tap/clicked <li> localstorage, use saved localstorage retrieve data detail page. i'm new javascript/jquery, if can provide simple example code appreciated. i know how write localstorage, read localstorage, json data server api, generate loop listview unique id each <li> . what need is, how use js make <li> clickable (link detail page) , write localstorage @ same time. i have tried: $('.liclass').click(function() { //block of code write localstorage }; but <li> not clickable , no key/value written localstorage. not mention detect <li> clicked (this have no idea). please advice, thank you. code update: //show restaurant listing - note: not first page. link other page. $('#restaurantlist').on("pagebeforecreate", function() { $.getjson("http://mydomain.com/api/restaurant", function( data ) { function rstli

mysql - mysql_connect() error in php connection class -

am getting following error when trying access log in page: warning: mysql_connect() [function.mysql-connect]: mysql server has gone away in c:\wamp\www\members\connection.php on line 7 warning: mysql_connect() [function.mysql-connect]: error while reading greeting packet. pid=3688 in c:\wamp\www\members\connection.php on line 7 warning: mysql_connect() [function.mysql-connect]: mysql server has gone away in c:\wamp\www\members\connection.php on line 7 fatal error: maximum execution time of 60 seconds exceeded in c:\wamp\www\members\connection.php on line 7 the code connection class looks this: <?php $mysql_hostname = "localhost:8081"; $mysql_user = "root"; $mysql_password = ""; $mysql_database = "hospital"; $prefix = ""; $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("could not connect database"); mysql_select_db($mysql_database, $bd) or die("could not select database"); ?&g

postgresql - How to do ORM using reverse engineering in Hibernate in Intellij IDEA? -

i have 100 tables , of them have average 40-50 fields. table have 5-6 fields, can make it's object relational mapping db. but have many numbers of tables fields possible create orm using reverse engineering in intellij idea ? if yes how ? i have done mapping simple : @entity @sequencegenerator(name = "sequence", sequencename = "pat_id_seq") @table(name = "pat") public class patron extends baseentity { @column(name = "p_id") private string pid; @column(name = "user_password") private string userpassword; } i using postgresql db provider. so on fast ? help.. open persistence tool window, click generate persistence mapping. view > tool windows > persistence

Using Guid Ids with ServiceStack 4 and MySQL -

how change serialization method guids in ormlite.mysql servicestack 4? version 3 mysql stored guids text without dashes, , likewise didn't use dashes comparisons. after upgrading servicestack 4, ups return no data. in mysql log, queries sent ormlite include dashes , that's why there's no matches. need set previous behaviour. i have customized serialization settings follows. apply ormlite dtos? void customserializationsettings() { servicestack.text.jsconfig<guid>.serializefn = guid => guid.tostring(); servicestack.text.jsconfig<guid?>.serializefn = guid => guid.hasvalue ? guid.tostring() : string.empty; servicestack.text.jsconfig.includenullvalues = true; servicestack.text.jsconfig.datehandler = servicestack.text.datehandler.iso8601; servicestack.text.jsconfig<datetime>.serializefn = datetimeserialising.serialisedate; servicestack.text.jsconfig<datetime>.deserializefn = datetim

nosql - Cassandra rack concept and database structure -

i newbie in cassandra , want know cassandra racks. , confuse cassandra structure. suppose have around 70 column family in cassandra , 2 aws2 instance. 1.how many data center used. 2.how many nodes each rack have ? 3.is possible divide column family in multiple key space. the intent of making cassandra aware of logical racks , data centers provide additional levels of fault tolerance. idea ( as described in document , under "network topology strategy") application should still able function if 1 rack or data center goes dark. essentially, cassandra... places replicas in same data center walking ring clockwise until reaching first node in rack. networktopologystrategy attempts place replicas on distinct racks because nodes in same rack (or similar physical grouping) fail @ same time due power, cooling, or network issues. in way, can query data local_quorum, in quorum ((replication_factor / 2) + 1) computed nodes present in same data center coor

Alfresco CMIS: How to translate a ChangeEvent object id to a Document object id? -

context in cmis, changeevent tells me object has been deleted on remote server, , objectid of object instance workspace://spacesstore/3aca9034-3f53-4946-a0d9-ebcf054912a2;1.0 (real example of changeevent.properties[cmis:objectid] ). i locally kept various identifiers of objects , none of identifiers match identifier in changeevent: document.properties[cmis:objectid] is 3aca9034-3f53-4946-a0d9-ebcf054912a2;1.0 document.properties[alfcmis:noderef] is workspace://spacesstore/3aca9034-3f53-4946-a0d9-ebcf054912a2 . question how should translate changeevent.properties[cmis:objectid] document.properties[cmis:objectid] ? (eg. workspace://spacesstore/3aca9034-3f53-4946-a0d9-ebcf054912a2;1.0 3aca9034-3f53-4946-a0d9-ebcf054912a2;1.0 i remove first 24 characters, guess work alfresco, , not other cmis servers. environment alfresco community 4.2.e accessed dotcmis via http://server/alfresco/api/-default-/public/cmis/versions/1.0/atom need assign dotcmis alf

Estimation of multivariate t distribution in R -

i konw if there function in r allows estimate df of multivariate t distribution. the problem easy: have matrix of 5 variables (columns) 75 observations (rows). estimate df of multivariate t on sample. thanks, juan. *** edition: after fabians suggestions implemented dmvt() formula * ** * # "residuals" matrix residuals model. want estimate df of # sample assuming multivariate-t sigma<-cor(residuals, use="pairwise.complete.obs", method="pearson") my_means<-vector(length = 8) (i in 1:8){ my_means[i]<-mean(my_matrix[,i]) } residuals.scaled<-scale(residuals) df.1 <-dmvt(residuals.scaled, my_means, sigma, log= false, type = "shifted", df = 1) i have doubts regarding: 1) scaling: i'm centering data. don't know if correct. 2) using log = false don't know why densities should given log(d) in case 3) here should estimate likehood of sample data each df. thus, more code lines df.2, df.3, etc should added ,

php - In mysql which is the best way to fetch friends data with join statement or In statement? -

in social networking site have scenario taking news feed of friends against logged in user. i have user table, membership table , feed table. here membership table using friends data. user table have more 100k entries , membership take have more 400k entries. i have 2 way take friends feed... either joining feed , membership tablle select * feed join membership on ... .... or in statement like select * feed user_id in (userids of friends) here facing loading issue when making join statement newly registered user having single friend. so best method along robust future run ?

onInfoWindowClick Method not working in android -

i have create app showing current location in maps.i want show places in toast message under oninfowindowclick method. toast not working .thanks in advance help! here code : public class searchproviderlocation extends activity implements locationlistener,oninfowindowclicklistener { class myinfowindowadapter implements infowindowadapter{ private final view mycontentsview; myinfowindowadapter(){ mycontentsview = getlayoutinflater().inflate(r.layout.custom_info_contents, null); } @override public view getinfocontents(marker marker) { textview tvtitle = ((textview)mycontentsview.findviewbyid(r.id.title)); tvtitle.settext(marker.gettitle()); textview tvsnippet = ((textview)mycontentsview.findviewbyid(r.id.snippet)); tvsnippet.settext(marker.getsnippet()); return mycontentsview; } @override public view getinfowindow(marker marker) { // todo auto-generated method stub return null;

sed - How to place all the delimited records in one column in unix -

i have 1 file abc.txt contains : abc,byc ccf gyh i want place records (which comma separated) in 1 line. abc byc ccf gyh please help with tr : tr ',' '\n' < abc.txt this replaces each comma newline.

oracle - How to catch a plsql output value -

i'm new vb , wondering how catch output value oracle command. i got code: dim paramret dim output sub function() sql = "declare variable := varchar(10); variable := 'test'; begin :=output := variable; end; " connect2oracle executesqlstatement sql set paramret = adocmd.createparameter("output",202,2,"20") adocmd.parameters.append paramret //print paramret.. but don't return value paramret. missing? edit: noticed i've no reference query "sql" in createparameter observation correct? you missing several things. first , foremost, anonymous procedures don't have return value or out parameter. so, return value need create function in oracle database. example: pl/sql: function add5 (num in number) return number begin return (num + 5); end add5; vb: dim cmd new adodb.command dim inputparam new adodb.parameter dim returnparam new adodb.parameter cmd.activeconne

html5 - I want to pass `id` into index.php without using form but it is not working -

i want pass id index.php,my code shown below. my main.php is: <?php $rd = dirname(__file__); //to directory path... $request[]=''; // make empty array if (empty($request[1]) && empty($request[2]) && isset($_session['l_user'])) { $request[1] = 'index'; $request[2] = '?id=1'; include_once($rd.'/php_includes/'.$request[1].'.php'.$request[2]); //i think problem might here... }else { $request[1] = 'index'; $request[2] = '?id=2'; include_once($rd.'/ph p_includes/'.$request[1].'.php'.$request[2]); // , might here } ?> and index.php somethin this: if(isset($_get['id'] == 1)) { //do something... }else{ //do else... } but doesn't have result not have error.its not working. try this, initilaise value top of include_once , , can able initalised variable inside included file (i.e index.php). note can'

Using foreach with two types of conditions in c# -

i used dropdown search. text value should different value. so, created 2 types of methods: list<string> lstroles = new list<string>(); lstroles = _repository.getrolesforfindjobseekers(); list<string> lstfunctions = new list<string>(); lstfunctions = _repository.getfunctionsforrolesfindjobseekers(); list<selectlistitem> selectlistroles = new list<selectlistitem>(); int = 1; foreach (string role in lstroles) { selectlistroles.add(new selectlistitem { text = role, value = role, selected = (i == 0) }); i++; } viewdata["rolesforjobseekers"] = selectlistroles; lstfunctions should come in value field. how add this? you can first combine these 2 lists 1 , loop on list. var lstcombined = lstroles .zip(lstfunctions, (role, function) => new {role = role, function = function}).toli

php - nginx change root on specific url -

i have 1 nginx http server configuration this: server { listen 80; server_name test.loc; root /var/www/test; location ~ \.php { fastcgi_split_path_info ^(.+\.php)(.+)$; set $fsn /index.php; if (-f $document_root$fastcgi_script_name){ set $fsn $fastcgi_script_name; } fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param script_filename $document_root$fsn; fastcgi_param path_info $fastcgi_path_info; fastcgi_param path_translated $document_root$fsn; fastcgi_read_timeout 180; } location / { index index.html index.php; try_files $uri $uri/ /index.php?$args; } location /sample/ { root /var/www/test2/; } } i want address http://test.loc/sample root in folder /var/www/test2 no matter how tried, displays contents of /var/www/test . thank in advance. upd: now have config: server { listen 80; server_name test.loc; root /var/www/test; error_log /var/log/nginx/mytest.log; index index.html index.php; locati

Does arbiter node in mongodb has admin database -

i have set 3 mongodb nodes in replication set - primary, secondary , arbiter. i want know arbiter node in mongo database has admin database default when configured. thanks the arbiter not contain data therefore or application won't need authenticate if connect directly. when application connecting replicaset detect if node arbiter , don't attempt connect it. depending on driver there exceptions (bugs) application still attempt authenticate arbiter.

javascript - 2 Nivo Sliders on same page not working -

for reason can not see, have 2 nivo sliders on same page not work. appreciated. below known nivo slider code adapting. header <link rel="stylesheet" href="themes/default/default.css" type="text/css" media="screen" /> <link rel="stylesheet" href="themes/light/light.css" type="text/css" media="screen" /> <link rel="stylesheet" href="themes/dark/dark.css" type="text/css" media="screen" /> <link rel="stylesheet" href="themes/bar/bar.css" type="text/css" media="screen" /> <link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" /> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> nivo slider 1 <div id="wrapper"> <div class="slider-wrapp

c# - StreamWriter fails to recognize c:\ in compact .net 2.0 -

i have following code using (var str = new streamwriter(newfilename)) { foreach (entry entry in this.entries) { str.writeline( string.format( @"""{0}"";{1:yyyy-dd-mmthh:mm:ss};""none""" , entry.data , entry.date ) ); } } where newfilename = @"c:\asln.csv" this codes works fine on .net framework 2.0 fails miserably on compact 2.0. it throws error "could not find part of path '\\c:\\asln.csv'." so, reason path perpended \\ . how work around that? c:\ not exist in compact framework (windows ce). paths need start backslash (\) so if in root folder path should \asln.csv. make sure file in root. different devices have different rules, , putting file in root not going work on devices.

how do I call a list of functions and use a string list ? -

how call list of functions , use string list ? def apple_w(): print(1) def banana_w(): print(2) def orange_w(): print(3) fruits = ['apple','banana','orange'] in fruits: ....... from syntax of code guess use python. there have globals -function, returns dict global entities. def apple_w(): print(1) def banana_w(): print(2) def orange_w(): print(3) fruits = ['apple','banana','orange'] in fruits: fn = globals()[i + '_w'] # function fn() # call function

node.js - Using nodejs server with request package and function pipe()? -

i'm using nodejs server mockup backend @ moment. server webserver , returns json objects on different requests, works flawlessy. have json objects domain, have proxy server. have found package called request in npm. can simple example work, have forward whole webpage. my code proxy looks this: var $express = require('express'), $http = require('http'), $request = require('request'), $url = require('url'), $path = require('path'), $util = require('util'), $mime = require('mime'); var app = $express(); app.configure(function(){ app.set('port', process.env.port || 9090); app.use($express.bodyparser()); app.use($express.methodoverride()); app.use('/', function(req, res){ var apiurl = 'http://localhost:9091'; console.log(apiurl); var url = apiurl + req.url; req.pipe($request(url).pipe(res)); }); }); $http.createserver(app).listen(app.get('port'), function () {

html - My media query won't work -

i working on project , first media query not work set media screen 768 px , nothing when resize screen 360px media query work here code @media screen , (max-width: 768px){ .grid figcaption p { padding: 20px 7.0546% 20px 7.0546%; font-size: 0.250em; display: none; } .grid { padding: 65px 1.6666% 100px 10%; max-width: 60%; } .grid li { display: inline-block; width: 42%; padding: 20px 2.9629% 20px 2.9629%; } .cs-style-4 figcaption { height: 81.5%; width: 100%; } .grid figcaption { font-family: helvetica, arial, sans-serif; position: absolute; padding: 7.0546%; background: #ffffff; color: #ed4e6e; } } @media (max-width: 768px) implies maximum resolution till following css work such. so, i'm thinking there must media query might causing sort of contradiction. check or try writing .. @media (max-width: 768px) , (min-width:360px){ }

java - How to concatinate two columns in same array? -

how concatinate 2 columns in same array? example: aa ab ac ad 1 0 2 0 2 1 3 3 3 3 0 2 0 2 1 1 output:should this. aaab aaac aaad abac abad acad 10 12 10 02 00 20 21 23 23 13 13 33 33 30 32 30 32 02 02 01 01 21 21 11 how can code in java ? for (int = 0; < row.size(); i++){ for (int j = 0; j < col.size(); j++) { for (int k = j + 1; k < col.size(); k++) { col1.add(val[j]); col2.add(val[k]); finalval.add(col1.get(j) + col2.get(k)); } } system.out.println("finalval"); } public static void main(string[] args) { string[][] input = new string[][] { { "aa", "ab", "ac", "ad" }, { "1", "0", "2", "0" }, { "2", "1", "3", "3" }, { "3", "3", "0", "2"

android - Using Apportable with cocos2d-x -

does have details on porting cocos2d-x project using apportable? doesn't seem straight forward porting cocos2d-iphone project. have been trying trick thinking it's ios changing ccplatformconfig.h define cc_target_platform cc_platform_ios if android flag set. doesn't seem right approach me if has built cocos2d-x project using apportable appreciated. this collin here apportable. hero academy cocos2d-x title used apportable android. you're on right track, should make sure ios code paths compiled , android ones aren't. haven't been testing apportable each new release of cocos2d-x, it's there's tweaking required work properly. if cocos2d-x sample app working, let know , we'll add docs.apportable.com!

Error Saving a List in a xml File in Android -

i have implemented code capable of detecting ble signals , show them in listview (in each item of list show name, address , rssi) when try save xml file occurs error , stops app. here code: package com.example.newblescan; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.objectoutputstream; import java.io.serializable; import com.example.newblescan.r; import android.app.activity; import android.app.listactivity; import android.bluetooth.bluetoothadapter; import android.bluetooth.bluetoothdevice; import android.bluetooth.bluetoothmanager; import android.content.context; import android.content.intent; import android.content.pm.packagemanager; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.listview; import android.widget.toast; import com.example.newblescan.adapter.bledevicesadapter; /** * activity scanning , displaying available bl

winforms - Get Internet Time instead of pc time in vb.net -

this question has answer here: how datetime internet? 7 answers i have application runs on local machines (multiple users) dtr system. application based on client-server architecture, in need same time on pcs, method when on pc application starts fetch current time internet or server provide accurate , same time users. searched other solutions no luck. any ideas , alternatives appreciated! you can query ntp server. server offers information current time. there servers pool.ntp.org or google time servers under time1.google.com , on. in order query these can refer previous answers complete code on: how query ntp server using c#? it's in c# can convert vb.net tools http://codeconverter.sharpdevelop.net/snippetconverter.aspx

c++ - reading a binary unknown size file in c# -

i have switched c# c++. have done task in c++ , same have translate in c#. i going through problems. i have find frequency of symbols in binary files (which taken sole argument, don't know it's size/length).(these frequency further used create huffman tree ). my code in c++ below : my structure this: struct node { unsigned int symbol; int freq; struct node * next, * left, * right; }; node * tree; and how read file : file * fp; fp = fopen(argv, "rb"); ch = fgetc(fp); while (fread( & ch, sizeof(ch), 1, fp)) { create_frequency(ch); } fclose(fp); could 1 please me in translating same in c# (specially binary file read procedure create frequency of symbols , storing in linked list)? help edit: tried write code according henk holterman explained below still there error , error : error cs1501: no overload method 'open' takes '1' arguments /usr/lib/mono/2.0/mscorlib.dll (location of symbol related p

rule - Jena reasoning: dynamically adding new resources in the conclusion -

from have seen far, jena reasoning rules in form below : [hirarchyexpansion: (?x dbo:ispartof ?loc) (?loc dbo:ispartof ?highloc) -> (?x dbo:ispartof ?highloc) ] implies no new resource can added in conclusion. need dynamically name , add new resources in conlcusion of rule. can please refer me solution? thanks.

how draw in realtime to tableLayout - in android with eclipse -

i build table 3*3 game x vs 0, , need draw cells x or 0, dont know how in realtime ' please help! part table new developer @ android need help </tablerow> <tablerow android:id="@+id/tablerow1" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:padding="10dip" > <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:text="row 1" android:gravity="center" android:textsize="24sp" android:layout_span="3" android:background="#ff260a" /> </tablerow> how trigger draw? user clicking on table cell? if so, can create onclick listener each textview view element, , use set text