Posts

Showing posts from July, 2013

Starting Rails with error -

after running rails couple months without issues, got error when starting server (rails s) on macbook pro osx 10.9. new projects scratch return same error. hint appreciated. in advance !! macbook-pro-de-myname:blog myname$ rails s => booting webrick => rails 4.1.4 application starting in development on [...] => run `rails server -h` more startup options => notice: server listening on interfaces (-.-.-.-). consider using 127.0.0.1 (--binding option) => ctrl-c shutdown server [2014-08-17 21:22:30] info webrick 1.3.1 [2014-08-17 21:22:30] info ruby 2.1.2 (2014-05-08) [x86_64-darwin13.0] exiting /users/myname/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/utils.rb:76:in `create_listeners': undefined method `tcp_server_sockets' socket:class (nomethoderror) /users/myname/.rvm/rubies/ruby2.1.2/lib/ruby/2.1.0/webrick/server.rb:132:in `listen' [etc.]

redirect - How do I send values with POST when redirecting in Perl? -

i have 2 values 1 name , password pass page if user entered right combination. if user did know can redirect including values in query string like: $cgi->redirect('http:someotherpage.com?username=$username&password=$password'); but using request, there way same thing using post or there way pass on values when redirecting in perl? know jsp has method called requestdispatcher there in perl if post not available? edit: found link cgi application dispatch earlier it's little technical don't know if right tool job. edit: i'm using cgi.pm when doing http redirect can give url of new target. means, there no way specify data post request, because outside url. from understanding requestdispatcher jsp not send http redirect response, forwards current request internally inside jsp application. comparable let cgi script dispatch current request script on same server, without doing redirect through browser. details how depend on framework use (e.g

c# - PictureBox image not displayed by Form.Shown call -

i have form containing tablelayoutpanel has 1 row , 2 columns. column 1 contains panel contains picture box. column 2 text box. i display form , add text textbox 1 character @ time. works except picturebox image isn't displayed until textbox has finished populating. class program { static void main(string[] args) { mainform mainform = new mainform(); formshown shown = new formshown(mainform); mainform.shown += new eventhandler(shown.mainform_shown); mainform.showdialog(); } } class formshown { mainform mainform; public formshown(mainform amainform) { mainform = amainform; } public void f1_shown(object sender, eventargs e) { mainform.addtext("hello!"); } } public partial class mainform : form { public mainform() { initializecomponent(); picturebox.image = myapp.properties.resources.myimage; } public void addtext(string text) {

c# - Combine datepicker and timepicker to make DateTime object in windows 8.1 app -

i want insert datetime object values in sqlite tabel "create table customer (id integer not null primary key, name varchar(50), designation varchar(50), age integer, datemodified datetime, datecreated datetime)" for have function return formatted string datetime values private string datetimesqlite(datetime datetime) { string datetimeformat = "{0}-{1}-{2} {3}:{4}:{5}.{6}"; return string.format(datetimeformat, datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second,datetime.millisecond); } i have 1 datepicker , timepicker in app . have combine these value pass funcion.how combine both controls values ??

encryption - C# Rijndael IV size doesn't match block size, while it should -

i have following code: private void encryptfile(string inputfile, string outputfile, string pass) { try { string password = @pass; unicodeencoding ue = new unicodeencoding(); byte[] key = ue.getbytes(password); byte[] iv = new byte[128]; for(int =0; < iv.length; i++) { iv[i] = convert.tobyte(true); } string cryptfile = outputfile; filestream fscrypt = new filestream(cryptfile, filemode.create); rijndaelmanaged rmcrypto = new rijndaelmanaged(); messagebox.show(rmcrypto.blocksize + "\n" + iv.length); cryptostream cs = new cryptostream(fscrypt, rmcrypto.createencryptor(key, iv), cryptostreammode.write); filestream fsin = new filestream(inputfile, filemode.open); int data; while ((data = fsin.readbyte()) != -1)

css - Bootstrap: list-inline with bullets? -

anybody knows, how add bullets/separators between elements in horizontal list in bootstrap 3? <ul class="list-inline"> <li>author: michal</li> <li>modified: 17.08.2014</li> <li>comments: 5</li> </ul> thy css: .list-inline{display:block;} .list-inline li{display:inline-block;} .list-inline li:after{content:'|'; margin:0 10px;} you can see fiddle here . needless can use want instead of pipe separator, example

c# - How can I bind an additional property to a DropdownListFor? -

in following code, id of selected country correctly passed controller when form submitted. however, i'd pass along name of country. how can send name along id controller? model public class mymodel { public country country { get; set; } public list<country> countrylist { get; set; } } public class country { public int? id { get; set; } public string name { get; set; } } view @using (html.beginform()) { <div> @html.dropdownlistfor(m => m.country.id, new selectlist(model.countrylist, "id", "name")) </div> } controller mymodel model = new mymodel(); public actionresult index() { using (var service = new service()) { model.countrylist = service.getcountries(); return view(model); } } public actionresult index(mymodel tmpmodel) { return redirecttoaction("index"); }

java - Is an XOR swap equivalent to a traditional swap in all cases? -

below method performs ‘in place ' string reverse i.e. black cat becomes cat black. in second swap section if traditional swap (commented out) used tests pass if xor swap used 1 test passes. is not possible 'swap' (int = count; <= (end + count) / 2; i++) { char temp = arr[i]; arr[i] = arr[end - (i - count)]; arr[end - (i - count)] = temp; } to (int = count; <= (end + count) / 2; i++) { arr[i] ^= arr[end - (i - count)]; arr[end - (i - count)] ^= arr[i]; arr[i] ^= arr[end - (i - count)]; } method public class reversestring { public static char[] revstring(string input) { char[] arr = input.tochararray(); int length = arr.length; (int = 0; < (length / 2); i++) { arr[i] ^= arr[length - - 1]; arr[length - - 1] ^= arr[i]; arr[i] ^= arr[length - - 1]; } int end;

ios - Can't Run xCode 6 Beta 5 Swift App on iPhone 5? -

Image
i'm trying test swift app on iphone 5 device. i'm getting following message: i updated iphone 5 , xcode 6 latest versions. ideas? found out issue deployment target in build settings 8.0, should 7.0 if want swift app run in ios 7.

delphi - MSAccess SQL Too few parameters. Expected 4 -

i'm using delphi xe2 , anydac , msaccess db. the table 'timea' has 5 fields: rec_no autonumber app text user_id text pw text comment memo this code throws error below. query works fine in access query designer. sql := 'insert [timea] (app, user_id, pw, comment) values ("zoo", "bill", "mi7", "liger");'; adconnection1.execsql(sql); project pwb.exe raised exception class emsaccessnativeexception message '[anydac][phys][odbc][microsoft][odbc microsoft access driver] few parameters. expected 4.'. both sql , delphi using single quotes string boundaries. since want have singe quote inside string, have "escape" using doube single quote. for example, if write s := 'guns''n''roses' varieble s contain string guns'n'roses - 12 characters, not 14. be careful when concatenating string values, since might contain single quotes, t

html5 - I am trying to implement an html link to open up local files from my hardrive on Chrome -

i use file:/// protocol followed file location , reason keep getting same: "webpage not found" error. eg: <a href="‪file:///c:\desktop\projects\webpage.htm"><li>home</li> </a> this syntax works me: <a href="‪file:///c:/desktop/projects/webpage.htm">home</a> also putting <li> inside of <a> not valid html, because <li> should element of list ( <ul> or <ol> ). correct way put <a> inside of <li>.

Grouping MySQL results by 7 day increments -

hoping might able assist me this. assume have table listed below. hosts can show multiple times on same date, different backupsizes. +------------------+--------------+ | field | type | +------------------+--------------+ | startdate | date | | host | varchar(255) | | backupsize | float(6,2) | +------------------+--------------+ how find sum total of backupsize 7 day increments starting earliest date , through last date? don't mind if last few days cut off because don't fall 7 day increment. desired output (prefered): +------------+----------+----------+----------+----- |week of | system01 | system02 | system03 | ... +------------+----------+----------+----------+----- | 2014/07/30 | 2343.23 | 232.34 | 989.34 | +------------+----------+----------+----------+----- | 2014/08/06 | 2334.7 | 874.13 | 234.90 | +------------+----------+----------+----------+----- | ... | ... | ...

Building RPMs: ask rpmbuild to follow symlinks in spec -

i trying create rpm out of binaries/libraries without source (source not available me). package structure looks this: prefix: /pkg/ %file /pkg/bin /pkg/lib everything under bin , lib symlinks other locations. still want keep simple structure with actual files when install it. how tell rpmbuild follow symlinks in %file directive? i tried above when installed rpm, installed symblinks, not actual files. you can't. rpmbuild include symlinks part of package; there's no way tell rpmbuild package target of symlink rather symlink itself. best way avoid problem put files want package buildroot rather putting symlinks buildroot. rpmbuild has behavior 2 reasons: to make package building consistent, reproducible process (the contents of target of symlink vary across build hosts) to make easy include symlinks in packages

svnignore - svn copy:how to ignore files not under version control -

i want use svn copy create new tag,but have files not under control(e.g.:some js files generated coffeescript). svn copy command abort , display error: error: <file> not under version control. my question is:how ignore files not under version control when run svn copy ? my command svn copy trunk/* tags/2014-08-18/

javascript - Jquery, prevent redirecting, validating then submit the form -

i need validate form , display errors if there are. (that part of script working) if there no error submit form (no ajax, keep redirecting before posted data). my actual code not redirect @ all. don't see other way using .submit() posting data. if i'm not mistaken window.location.href not post data. $('#contact-form').submit(function(e) { e.preventdefault(); var count_error = 0; // validating ... if(count_error == 0){ $('#contact-form').submit(); //redirecting form action posted data } }); $("#contact-form").submit(function(e) { var count_error = 0; // validating ... if (count_error == 0) { return; } e.preventdefault(); });

c# - Can a derived class be marked BeforeFieldInit even if the base class cannot? -

in code below, a cannot marked beforefieldinit due existence of static constructor. however, did not write static constructor b . abstract class { static a(){} public static object a; } class b : { static object b = a; } is possible b marked beforefieldinit though base class a cannot?

flash - How to disable audio of the SWF file in Java Script (HTML) -

i've tried following code , not work . wondering how disable sound embedded flash object html. here code: <object codebase="http://download.macromedia.vn/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="622" height="560" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"> <param name="wmode" value="transparent"> <param name="movie" value="intro/flash/main.swf"> <param name="quality" value="high"> <param name="volume" value="0"> <embed wmode="transparent" width="622" height="560" src="intro/flash/main.swf" quality="high" pluginspage="http://www.macromedia.vn/go/getflashplayer" volume="0" type="application/x-shockwave-flash"> </object>

Read a json string using jquery -

how can read json string using loop, intention create/append table 3 columns containing in each row 1 of json values, not sure how can achieve it { "1": { "update":"ja existe", "numero":1, "registro":"ibram - 2014" }, "2": { "update":"ja existe", "numero":2, "registro":"pm-sp - 2014" }, "3": { "update":"ja existe", "numero":3, "registro":"artesp - 2014" } } if string, can convert json object , iterate through each element follows: var json = json.parse('the json string'); (key in json) { var value = json[key]; // whatever wanna value }

java - Piping output from an output stream to an input stream -

my problem piping input 1 socket another. currently, using code: for(;;) { try { output2.write(input1.read()); } catch(exception err) { err.printstacktrace(); } } even though technically works, there faster way this? you can use bytestreams#copy(inputstream, outputstream) google guava: try { bytestreams.copy(input1, output2); } catch (ioexception x) { x.printstacktrace(); }

python - Pandas prepend data to multi-indexed series -

i have following pandas.series object following data: country year united states 2004 416.205383 2005 430.326178 2006 444.208260 2007 456.880067 2009 472.733367 2008 474.420151 2010 480.486400 2011 495.654594 2012 505.911360 2013 513.322114 name: fp.cpi.totl, dtype: float64 let's call cpi. i'd prepend year 2014 series, instead use string name 'ttm'. cpi.index multiindex(levels=[[u'united states'], [u'2004', u'2005', u'2006', u'2007', u'2008', u'2009', u'2010', u'2011', u'2012', u'2013']], labels=[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 5, 4, 6, 7, 8, 9]], names=[u'country', u'year']) and cpi.values array([ 416.20538282, 430.32617782, 444.208

c# - Generics in a Dictionary as an Input in a method -

i trying create method accepts dictionary input. however, when try add following: public void writetojsonfile(dictionary<string, t> diclist) { ... stuff } it state t missing assembly or reference. now, have worked around adding <t> to class name generic class. using dictionary class want create method accept dictionary key string value can of object? i have worked around adding <t> class name generic class. you should not this, unless have specific need class generic. all want create method accept dictionary key string value can of object? all need dictionary<string,object> then: way, single dictionary have objects of different types, keyed string. better, use idictionary<string,object> let class users pass other implementations of idictionary<k,v> interface.

java - PackageManager not found using android and phonegap -

package com.example.jqmtest; import android.app.activity; import android.os.bundle; import org.apache.cordova.*; public class myactivity extends droidgap { /** * called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); super.loadurl("file:///home/dotcue/jqmtest/assets/www/index.html"); } } i use code , getting following error. error:(7, 8) java: cannot access android.content.pm.packagemanager class file android.content.pm.packagemanager not found i new android , phonegap. kindly me. thank you i write following.and working fine me. i think error because of syntax of loadurl .change below hope work. package com.demoapp; import org.apache.cordova.droidgap; import android.os.bundle; public class eosactivity extends droidgap { /** called when activity first created. */ @override public void oncreate(bundle savedinstances

Generating equations from factors in R -

this question has answer here: google docs exports spreadsheet values commas. read.csv() in r treats these factors instead of numeric 2 answers i new r, , trying create new column, 1 column minus column. example: price <- c("$10.00", "$7.15", "$8.75", "12.00", "9.20") quantity <- c(5, 6, 7, 8, 9) price <- as.factor(price) quantity <- as.factor(quantity) df <- data.frame(price, quantity) in actual data set, columns imported factors. when try create new column this: diff <- price - quantity in ops.factor(price, quantity): - not meaningful factors i have tried coerce data numeric using as.numeric(df), as.numeric(levels(df)), as.numeric(levels(df))[df], , setting stringsasfactors false, data gets converted nas. data.matrix changes values. there way above equation work? thanks! you should

c# - DataGrid columns is not loaded at first time in WPF -

i tried fill datagrid view not working first time. in datagrid view columns not updated. first time datagrid column 0 , second time column count updated correctly. //_dtsource nothing dataview dgrid.itemssource = _dtsource; dgrid.columns[0].visibility = visibility.visible; dgrid.columns[1].visibility = visibility.visible; dgrid.columns[2].visibility = visibility.hidden; xaml code : <grid height="642" width="835"> <textblock horizontalalignment="left" margin="283,10,0,0" textwrapping="wrap" text="access permissions" verticalalignment="top" width="200" height="23" fontsize="14" fontweight="bold"/> <textblock horizontalalignment="left" margin="10,68,0,0" textwrapping="wrap" text="list of forms :" verticalalignment="top" width="100" height="23"/>

python - Where is the circular reference? -

i'm writing python classes want encode json. when try jsonify objects, error mentioning 'circular reference'. think understand circular reference means, can't find examples in code. the relationship (has a/is a) between objects signup has a registrant has a address code (python): class address: def __init__(self, address1, address2, city, state, zip): self.address1 = address1 self.address2 = address2 self.city = city self.state = state self.zip = zip class signup: def __init__(self, registrant, classid, date, time, paid, seatcost, notes, classname, seats, groupid, agentname, agentcompany): self.registrant = registrant self.classid = classid self.date = date self.time = time self.paid = paid self.seatcost = seatcost self.notes = notes self.classname = classname self.seats = seats self.groupid = groupid self.agentname =

ios - Use UILabel in Class Method -

so have this: @interface viewcontroller : uiviewcontroller{ iboutlet uilabel *screen; } +(void)num:(int)number; and want access screen in class in num method so: +(void)num:(int)number{ screen.text = @"test"; } but xcode says "instance variable 'screen' accesses in class method" is there way this? yes, reason not letting because + sign in method denotes class method aka called on viewcontroller class don't have reference specific screen outlet. change + - , able call method like [self num:7] and access screen outlet in method hope helps!

testing - How to get the body of an email? -

i new testing using cucumber capybara. got application test flow is:'after submitting form, email sent user contains link app. in order access app have open mail , click link, redirect app.'. don't have access mail id. there way extract link , continue flow? have tried not working. below snippet trying: path_regex = /(?:"https?\:\/\/.*?)(\/.*?)(?:")/ email = actionmailer::base.deliveries.last path = email.body.match(path_regex)[1] visit(path) its showing 'unknown error:'url' must string' error. can 1 me it? i use mailcatcher works how you're describing.

How do I know if my project is using Azure Shared Cache? -

azure shared caching deprecated 1st sept 2014. i have been asked evaluate if project did not build utilizes azure shared cache. i know project use form of azure caching struggling identify one. how know if use or not? according msdn : to create and manage caches , must go cache section. on main page of management portal, click service bus, access control, & caching @ bottom of left pane. in left pane, expand services, , click cache. i not sure if info still actual.

Copy and Paste the html table with line breaks on excel not working -

so have textarea when type something, prints type on table. the table generates same format when type texts line breaks in it. when highlight , copy table , paste on excel file, copied table line breaks consume cells in rows. i want paste table same format table generates including line breaks. anyone have idea how that? i tried use paragraph tag no use, excel file paste white space. here sample of script <style> td { border: 2px solid black; } <br style="mso-data-placement:same-cell;"/> </style> <script> function myfunction(){ var mytextarea = document.getelementbyid("thetextarea"); document.getelementbyid("myprint").innerhtml = mytextarea.value; } </script> <textarea id="thetextarea" cols=20; rows=20; onkeyup="myfunction();"></textarea> <table> <td><pre id="myprint"></pre></td> <td&g

php - How to rewrite URL using htaccess for clean url (remove unnecessary parameter from url) -

i working on localhost php project. need solution. current url : http://localhost/project/portfolio/php_files/port_sub_sidebar.php?x=opencart now, want show in url this: http://localhost/project/portfolio/opencart how's possible doing change in .htaccess file in .htaccess rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^/(.*)(\.jpg|\.gif|\.png|\.css|\.js)$ rewriterule ^(.+)$ index.php?url=$1 [l,qsa] you can url code below $url = $_get['url']; $segments = explode("/",$url); print_r($segments); then can implement routing system based on provided segments

r - Vertical alignment of legend title (ggplot2) -

Image
i trying align legend title colorbar in ggplot2. how can make title vertically aligned colorbar (instead of whole colorbar plus number)? up result, trying various theme , element_text , guides options, whatever vertical position of title not change. library(ggplot2) library(grid) theme_set(theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position="bottom", legend.text=element_text(size=14), legend.title=element_text(size=14,hjust=-0.4), legend.direction='horizontal', legend.box = "vertical", strip.background = element_rect(colour='black',fill = "white"), plot.margin=unit(0.05*c(1,1,1,1),'npc'), plot.title=element_text(size=18), axis.title=element_text(size=18,vjust=0.2), axis.text=element_text(size=14), strip.text=element_text(size=14))) ggplot(diamonds,aes(x,y,color=z))+ g

sql - Function to create a view not working in postgresql - ERROR: column does not exist -

i trying make function creates simple view stored function. below query: create or replace function cc_getbalancesfordate_vw(thedate date) returns void $body$ create view cc_showbalances_vw select * cc_getbalancesfordate(thedate::date); $body$ language sql if execute above query in pgadmin sql window works. if run query below select cc_getbalancesfordate_vw('2014-02-15'); to test function getting following error error: column "thedate" not exist line 5: select * cc_getbalancesfordate_vw(thedate::date); thedate not column. looking date pass function parameter. i have tried following: create or replace function cc_getbalancesfordate_vw(thedate date) returns void $body$ begin create view cc_showbalances_vw select * cc_getbalancesfordate(thedate); end; $body$ language plpgsql volatile i got same error. have looked on , cant find example this. examples found run static query table. not single example using f

excel - Convert all files from .html to .xlsx in a folder and save as filename using VBA -

my problem header states. convert files within folder html (downloaded browser) .xlsx format. i use same folder path store files want converted , supersede on daily basis the number of files used on daily basis change there no 'file masks' relevant files ones within folder, there no subfolders files must opened, converted xlsx , saved again same name of source file. rinse , repeat until files have been converted , saved within same (or different if easier folder) i using excel 2011 (for mac) therefore file paths little different, if vba code, there should no issues of using on platform. main difference paths separated : instead of \ . e.g. macintosh hd:users:documents:r7m:planning:locations some of links have researched come close answer here: opens txt files , saves excel : tried changing of information looping through files in folder mac : advanced, reference need used. wasn't allowed post 3 links site gives references... think. this (from link

c - start speech recognition program when specific microphone is detected at USB port (inorder to avoid careless usage) -

i want restrict speech recognition program used 1 single specific microphone. how design module if specific microphone connected further execution start, otherwise terminated. i want because, carry out speech recognition in noisy scenario , hence use of noise cancellation based microphone strictly recommended, other microphone give false recognition in noisy scenario. the main codes in c programming language , executing shell script. is there anyother techniques can used in case.. example rfid? share experiences. thank you in shell, when run below command, list connected audio devices cat /proc/asound/cards or arecord -l you can parse output , decide, expected micro phone connected or not. by way, linux machine.

cluster remote lucene indec with dcs -

i try use lucene index on remote server input carrot2 installed on same server. regarding documentation should possible carrot2-dcs (documentation chapter 3.4 carrot2 document clustering server: various document sources included. carrot2 document clustering server can fetch , cluster documents large number of sources, including major search engines , indexing engines (lucene, solr)). after installing carrot2-dcs 3.9.3 discovered lucene isn´t available document source. how proceed? to cluster content lucene index, index needs available on server dcs running (either through local file system or e.g. nsf mount). to make lucene source visible in dcs: open editing: war/carrot2-dcs.war/web-inf/suites/source-lucene-attributes.xml uncomment configuration sections , provide location of lucene index , fields should serve documents' titles , content (at least 1 required). remember fields must "stored" in lucene speak . make sure edited file packed war archive

c# - Azure Cloud Service Project opens two Browser Windows on Start when Debugging -

Image
i have vs2013 (update 3) solution 1 azure cloud service project has 1 web role / asp.net project , later has 'don't open page.' selected underneath propers > web tabcard, whenever start azure cs .ccproj debugging (the later set startup project), 2 (not one) browser windows opened each time. does know can disable or @ least set 1 window only? it's running azure sdk 2.4, using iis express & (azure) emulator express. right click on web role --> properties --> startup action --> please uncheck 1 of boxes under launch browser for

dynamic - Is there any way to create zip in a zip file using java dynamically..? -

Image
i have bunch of files, 4 files.. want zip 2 files zip "inner.zip" , rest parent directory of "outer.zip". i.e inputstream streamtoreadfile=readfile(filepath); string zipentryname = foldername + "/" + filenametowrite; zipentry anentry = new zipentry(zipentryname); // couldn't able create zip in zip file. streamtowriteinzip.putnextentry(anentry); while ((bytesin = streamtoreadfile.read(readbuffer)) > 0) { streamtowriteinzip.write(readbuffer, 0, bytesin); } the inner zipoutputstream should call finish() instead of close() finish() flushes compressed data, not close outer zip. mind test erroneousness of close() 1 need add yet file, inner zip last. path sourcepath = paths.get("c:/d/test.html"); try (zipoutputstream zipout = new zipoutputstream( new fileoutputstream("c:/d/test/test.zip"))) { zipout.putnextentry(new zipentry("file1.txt"

c# - save xml file using streamwriter -

i trying find way save data xml file encoding "iso-8859-7". firstly loading xml using public xmldocument loaddocument(string x) { xmldocument document = new xmldocument(); streamreader stream = new streamreader(xml, encoding.getencoding("iso-8859-7")); document.load(stream); return (document); } to load attributes inside form controls , when save button clicked private void savebtn_click(object sender, eventargs e) { xmlnodelist attributes = commonmethods.loaddocument(xml).documentelement.selectnodes("//class[@name='" + classname + "']/property[@id='" + id + "']/attribute::*"); (int x = 0; x < attributes.count; ) { foreach (control ctr in table1.controls) { if (ctr textbox) { if (ctr.text == attributes[x].value.tostring()) { x++; } else

c# - Incorrect syntax near '('. Connection to database with entity framework -

i have asp.net mvc app works on local server. when i'm deploying windows server 2008 standard in iis (v7.0) app running property (i can see panel log in), when want log in, have such error. have page contact , when want run have same error. add model.edmx using ado.net entity data model . the code simple: in controller: private importentities entity = new importentities(); public actionresult contact() { var dane = entity.contact.firstordefault(); return view("contact",dane); } connection string in web.config: <add name="importentities" connectionstring="metadata=res://*/models.model.csdl|res://*/models.model.ssdl|res://*/models.model.msl; provider=system.data.sqlclient; provider connection string=&quot;data source=aaa\aaa; initial catalog=database_name; integrated security=true; multipleactiveresultsets=true; app=entityframework&quot;" providername="system.data.entityc

java - Array / Vector as method argument -

i have read should use vector everywhere in java , there no performance issues, true. i'm writing method calculate mse (mean squared error) , noticed slow - passing vector of values. when switched array, 10 times faster don't understand why. i have written simple test: public static void main(string[] args) throws ioexception { vector <integer> testv = new vector<integer>(); integer[] testa = new integer[1000000]; for(int i=0;i<1000000;i++){ testv.add(i); testa[i]=i; } long starttime = system.currenttimemillis(); for(int i=0;i<500;i++){ double testval = testarray(testa, 0, 1000000); } system.out.println(string.format("array total time %s ",system.currenttimemillis() - starttime)); starttime = system.currenttimemillis(); for(int i=0;i<500;i++){ double testval = testvector(testv, 0, 1000000); } system.out.println(string.format("vector total time %s "

java - Load ResourceBundle depending on context -

i have application separated in several contexts same layout each context different messages. example on context "a": title label: text example on context "b": title b label: text b note "label" same on each context , context "a" default context. i need have 1 properties files per context: resources.properties (context - default) title=title label=label text=text resources_b.properties (context b) title=title b text=text b and load property file depending on context. the first solution found use locale this: // context either "a", "b"... resources = resourcebundle.getbundle(config, new locale(context)); this way, if message not found in resources_b.properties , return 1 resources.properties expected. what best way have "pretty" resource loading per context not using locale ? the application in english, may change in future...

javascript - CountDown Timer Before Redirect In Pure PHP -

i using pure javascript count down timer shared below redirect url after time , show left time visitor also. demo: jsfiddle <form name="redirect" id="redirect"> redirected next page after <input size="1" name="redirect2" id="counter"></input>seconds. </form> <script type="text/javascript"> var countdownfrom=5 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=0){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ showit() return } settimeout("countredirect()",1000) } countredirect() function showit() { window.location.href = "http://jsfiddle.net/"; } </script> now want same function , features , work in pure php know many old mobile browsers still does't not support javascript , many using javascript blocker. possible same in pure php , no <script> ta

r - numbers within apply get filled with spaces -

i want create folder name based on 2 variables in data frame , wrong here... head(clustering) line x y qerror 1 200 15 19 1.118677 2 201 11 19 1.038482 3 202 0 6 1.238026 4 203 0 18 1.321878 5 204 0 12 1.204173 6 205 5 0 1.394773 str(clustering) 'data.frame': 3406 obs. of 4 variables: $ line : factor w/ 3406 levels "1001","1003",..: 814 822 831 841 847 858 891 ... $ x : num 15 11 0 0 0 5 16 8 1 0 ... $ y : num 19 19 6 18 12 0 14 19 17 18 ... $ qerror: num 1.12 1.04 1.24 1.32 1.2 ... when try create folder name x , y columns, following: apply(head(clustering),1,function(x){paste0('x',x[2],'_by_y',x[3])}) 1 2 3 4 5 6 "x15_by_y19" "x11_by_y19" "x 0_by_y 6" "x 0_by_y18" "x 0_by_y12" "x 5_by_y 0" as can see, x , y additional space, if value smaller 10. when use without appl

android - How to get the cause of an insert() error using ContentProvider? -

i have code inserts row db, using custom contentprovider: uri contenturi = uri.withappendedpath(dataprovider.content_uri, usertable.table_name); uri resulturi = getcontext().getcontentresolver().insert(contenturi, contentvalues); boolean success = (long.parselong(resulturi.getlastpathsegment()) != -1); the insert() method defined in contentprovider follows: public class dataprovider extends contentprovider { // ... @override public uri insert(uri uri, contentvalues initialvalues) { string table = gettablename(uri); sqlitedatabase database = dbhelper.getwritabledatabase(); long value = database.insert(table, null, initialvalues); return uri.withappendedpath(content_uri, string.valueof(value)); } } i've noticed that, sometimes, insertion fails returning row id equals -1 (as can see in third line of first code, success should become false). problem can't understand reason because logcat doesn't print exception related

Scala string pattern matching by multiple possible groups -

given input map[string,string] such val in = map("name1" -> "description1", "name2.name22" -> "description 22", "name3.name33.name333" -> "description 333") what simple way extract each name , each description , feed them method such as def process(description: string, name: string*): unit = name match { case seq(n) => // find(n).set(description) case seq(n,m) => // find(n).find(m).set(description) case seq(n,m,o) => // find(n).find(m).find(o).set(description) case _ => // possible error reporting } many thanks you can use splat operator _* : val in = map("name1" -> "description1", "name2.name22" -> "description 22", "name3.name33.name333" -> "description 333") def process(description: string, name: string*) = ??? in.map { x =>

c# - Windows 8 Tablet App - Webview not supporting HTML 5 and mousover -

in windows 8 app using webview websites don't work properly. html 5 not supported , mouseover effects buggy well. when hover on button has mouseover-dropdown-menu on windows opens, when click in webview on windows 8 tablet, not open mouseover-dropdown-menu performs click on button (leading reload of webpage usally). is there alternative webviews? best way show websites on windows 8 tablets?

android - View outside a Dialogs bounds -

Image
i want this: the users profile picture "popping out" on dialogs bounds. i've tried everything: messing clipping every possibly combination under sun, dynamically creating view after dialog , adding root content view, using seperate view , loading in dialog.setcustomtitle(), hacking images ondraw() methods , applying all-sorts of bounds/positional hacks --- no matter image gets clipped , split in half. i've gone extent of decompiling play store apk , seeing how did it. unfortunately resource files don't give away , can't find in smali. can help? please... :-( edit : i'm talking user profile image @ top of dialog, not dialog itself. dialog method: dialog dialog = new dialog(this); dialog.requestwindowfeature(window.feature_no_title); dialog.setcontentview(r.layout.mhp); dialog.getwindow().setbackgrounddrawable(new colordrawable(color.transparent)); dialog.show(); mhp.xml <relativelayout xmlns:android=&quo

full screen slider in WordPress -

i installed easy full screen slide plugin( https://wordpress.org/plugins/easy-fullscreen-slider/ ) unfortunately can't find shortcode have use show plugin. 1 me , tell me short code have use show plugin? this plugin has no shortcodes @ all. you have go preferred page/post , edit plugin settings there in "easy fullscreen slider - settings" meta box, somewhere below wysiwyg editor. controls slideshow settings on per page/post basis. also, have global settings page, called "easy fullscreen slider". way can control global settings apply sliders (they can overwritten on per page/post basis described above).

jquery - unable to stop ajax call on document ready -

i have ajax function optionally run mvc view loaded, can't stop running. i've set boolean variable stop function, value ignored. when understand why, i'll try , pass value view model set true/false - govern whether or not call ajax function when view loads. following snippet makes ajax call though seems shouldn't. $(document).ready(function () { $("#divloading").show(); var doit = false; if (doit) { callajaxpost(); } }); function callajaxpost() { var url = '@url.action("postmethod", "nav")'; $.post(url, null, function (data) { $("#pid")[0].innerhtml = data; $("#divloading").hide(); }); } there error in code. works expected.

linux - Potential issues of chmod 777 on a directory? -

assuming have directory structure: /tmp/mysockets/appname/ what security drawbacks doing chmod 777 on /tmp/mysockets/? user delete or mess reference appname/ directory? want allow other users add own directories /tmp/mysockets/ don't want allow them rename or delete files/subdirectories inside (owned user). i think looking sticky bit, thats want. permissions 777 grant read/write permissions therefore files can removed/renamed a sticky bit permission bit set on directory allows owner of file within directory or root user delete or rename file. no other user has needed privileges delete file created other user. to set sticky bit use following chmod o+t /tmp/mysockets/ or e.g. chmod 1757 /tmp/mysockets/

java - Spring-Integration using Jdbc-Templates, for operations such as batch-Updates? -

this question regarding "spring integration" using jdbctemplates , not usual spring jdbctemplates (for several examples available on web). i have been following documentations , examples spring-integration jdbc outbound gateway. these fine basic sql queries. documentation says spring-integration can work either datasource (examples provided) or jdbctemplate (examples not provided). basically, wanted know, if want implement batchupdate (which available in jdbctemplate), how should specify? lets say, if have following spring-context file? spring integration not support batch jdbc updates. but, can use jdbctemplate within code (a pojo) , invoke using <service-activator/> .

wpf - How to hide/enable UserControl in all xaml pages? -

i have user control. usercontrol have functionalities. have called usercontrol in common resource directory file. inherit resource directory page in pages. enables user control in pages. want is, want usercontrol particular page can set. code. resource directory file: <resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:l="clr-namespace:usercontrols"> <!-- navigation appbar --> <l:navigationappbarusercontrol grid.row="1" grid.column="0" width="100" horizontalalignment="left" visibility="visible" /> </resourcedictionary> window1.xaml: <src:windowbase x:class="" xmlns:src="clr-namespace:projectone" title="window1"> <grid> //

c# - Object deep copy in Silverlight -

i trying create copy of objects in silverligth 5 interfaces iformatters , iccloanble not support. * my objects this: (note these obkjects obtained on deserializing xml): tried copy this: [xmlroot(elementname = "component")] public class component { [xmlelement("attributes")] public attributes attributes { get; set; } [xmlignore] public attributes atrbtorginal = new attributes(); [xmlignore] public attributes atrbtcopy{ get; set; } } public component() { atrbtcopy= atrbtorginal ; } sure not work got code on seraching on google : public static class objectcopier { public static t clone<t>(t source) { if (!typeof(t).isserializable) { throw new argumentexception("the type must serializable.", "source");

shell - Error installing compass. Failed to build gem native extension (Compass) -

after installation of sass, did : gem install compass and error appears. building native extensions. take while... error: error installing compass: error: failed build gem native extension. /system/library/frameworks/ruby.framework/versions/2.0/usr/bin/ruby -r ./siteconf20140818-5119-rfb64z.rb extconf.rb mkmf.rb can't find header files ruby @ /system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/include/ruby.h extconf failed, exit code 1 gem files remain installed in /library/ruby/gems/2.0.0/gems/ffi-1.9.3 inspection. results logged /library/ruby/gems/2.0.0/extensions/universal-darwin-13/2.0.0/ffi-1.9.3/gem_make.out do have solution ? i had faced same issues, after going through following link , have installed xcode , issues resolved. try install xcode or apple developer tools.

ios - Navigation Stack is nil after setViewControllers -

here hierarchy: a - b - c - d (tabs) | | | | | | | | ----------------> addeventviewcontroller (can called tabs) | | |----> suggestfeedcontroller (can accessed b only) let's imagine i'm in d tab, , call addeventviewcontroller. after this, want redirect user "suggestfeedcontroller", want keep hierarchy, means pressing button should redirect b , not addeventviewcontroller nor d. what have tried following: uitabbarcontroller *tabbarcontroller = ((uitabbarcontroller *)appdelegate.window.rootviewcontroller); [tabbarcontroller setselectedindex:1]; // selecting b tab uistoryboard* storyboard= appdelegate.window.rootviewcontroller.storyboard; uicategoryfeedcontroller *cfvc = [storyboard instantiateviewcontrollerwithidentifier:@"uicategoryfeedcontroller"]; // instantiating b view controller suggestfeed *suggestfeed = [storyboard instantiateviewcontrollerwithidentifier:@"suggestfeed"]; nsarray

git - What is the best approach for deploying a sails.js application? -

i developing web application using sails.js back-end. app used different schools , first approach deploy each school instance of application. example: school1.application.com having instance of sails app on school.application.com:8080 school2.application.com having instance of sails app on school.application.com:8081 each instance have bitbucket repository (or branch) , source updated using git. for maintenance purpose, thinking of using dashboard connected git repository , manage push there. on other hand, more manageable have 1 instance school how used separate database each 1 ? using 1 db not risky when having 20 schools ? using second approach, if application down, schools affected opposed first one. i hope clear in explanations. thank insights. where sails app hosted? you? i.e. nodejitsu, amazon, etc. or app deploy on school server? approach: if you'll host app, can make 1 app , deploy once. add schools models , create relationship between users

Unix: I want capture the output of top into variable instead of file -

i want capture output of top variable instead of file. and tried below top -n 1 -b | head > top_op echo "inside: $top_op" $top_op | grep cpu > cpu echo "$cpu" but output just inside: if want store output variables, use command substitution: top_op=$(top -n 1 -b | head) echo "inside: $top_op" cpu=$(echo "$top_op" | grep cpu) echo "$cpu" using backquotes $() more recommended recursive without quoting. top_op=`top -n 1 -b | head`

Show Row Per Row While Scrolling Listview -- Android -

i have listview rows big device screen , want show row per row while sliding, don't want show parts of rows when doing so, there way of doing it. listviews not made kind of use case. viewpagers are, scroll horizontally. it's possible make scroll vertically (see android: vertical viewpager ), should you're looking for. the problem adjusting size of each listview item fill screen match_parent doesn't work. need calculate exact size need (screen height minus action bar , other views not part of listview). it's possible, not worth trouble.

android - CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 happens when record is deleted -

a understand in cursor, can't figure out solution own. need help. , happens when delete record. on displaycontact.java in line 65. here class files. displaycontact.java import java.text.simpledateformat; import java.util.calendar; import android.app.activity; import android.content.intent; import android.database.cursor; import android.os.bundle; import android.view.keyevent; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; import android.widget.toast; public class displaycontact extends activity { int from_where_i_am_coming = 0; private dbhelper mydb ; textview name ; textview note; int id_to_update = 0; button btndel; string formatteddate; textview txtview; simpledateformat date; calendar c; // textview dosage; // textview day; @override pr