Posts

Showing posts from June, 2012

node.js - How to test nodejs backend code with Karma (testacular) -

how setup karma run backend unit tests (written mocha)? if add backend test script files = [] , fails stating require undefined. you don't. karma testing browser-based code. if have project mocha tests on backend , karma/mocha on front end, try editing package.json under scripts set test to: mocha -r spec && karma run karma.con then, if npm test returns true, you'll know it's safe commit or deploy.

javascript - .htaccess rules make sm2 fail to load mp3s of my website on Android and iPad -

i use .htaccess in application's assets/audio directory prevent direct download of mp3's files played soundmanager2 . following code of .htaccess placed in assets/audio directory: rewriteengine on rewritecond %{http_referer} !^http://(www\.)?localhost [nc] rewritecond %{http_referer} !^http://(www\.)?localhost.*$ [nc] rewritecond %{http_referer} !^http://(www\.)?quran\.2index\.net [nc] rewritecond %{http_referer} !^http://(www\.)?quran\.2index\.net.*$ [nc] rewriterule \.(gif|jpg|mp3)$ - [r=401] errordocument 401 /e401.html addtype audio/mpeg mp3 with desktop (windows 7), web browser able play sounds soundmanager2. live demo found on following url: http://quran.2index.net/viewayah/1 the problem android web browser, opera on android , safari of ipad (those have tested with). browsers not able load mp3 audio file , download file popped up! the weird thing me, when comment out lines of .htaccess regarded above (except first , last lines), sm2 becomes work fine on a...

Rails Paloma Gem - how to load page-specific javascript? -

i loaded paloma gem attempt page-specific javascript. looks straightforward must missing something. rails g paloma:setup application.js: ... //= require jquery //= require jquery_ujs //= require jquery-ui //= require_tree . //= require paloma run command: rails g paloma:add days index in \app\assets\javascripts\paloma\days\index.js: ... paloma.callbacks['days']['index'] = function(params){ // here. alert('paloma!'); }; })(); the javascript loads on page not execute. try changing order of includes to: ... //= require jquery //= require jquery_ujs //= require jquery-ui //= require paloma //= require_tree . i think you're requiring \app\assets\javascripts\paloma\days\index.js require_tree . line before paloma loader/bootstrap javascript depends on.

web - How to preserve user state in the transition between devices? -

recently came across problem users distracted when working mobile phones example when user shopping online, forget continue task, , there no solution can preserve state , later he/she can continue task his/her desktop.i wonder solution storing user state. moreover, here i'm concerned web applications, when user wants resume unfinished work, can desktop computer while work started mobile device. my approach set cookie land on site. depending on how data want save start immediately, after search or viable when add item cart present them option of guest login asking username, use real time ajax check availability of name or present them random 4 digit number smoothly popup alerting them can use restore session on device ask email address think users prefer anonymous name unless planning register. if accept guest login save cookie, username/code, page & items database period of 24-72 hours.

ruby on rails 3 - table width an bootstrap -

i'm having trouble table width in bootstrap, particularly when making responsive. i have table, example <table class="table table-striped table-hover"> <% @list.each |title| %> <tr> <td><%= link_to title, :action => :topic, :title => title %></td> </tr> <% end %> </table> when reduce screen size, doesn't smaller else , stay within page, keeps going on edge of screen. have tried putting in container doesn't seem help... your mark wrong. need <tbody> <table class="table table-striped table-hover"> <tbody> <% @list.each |title| %> <tr> <td><%= link_to title, :action => :topic, :title => title %></td> </tr> <% end %> </tbody> </table>

email - From header php mail() send sms to phone number -

i want change parameter absolutely want, when sending sms php's mail() function. e.g user sees text message "the developer" on phone screen. don't want @domain response, nor email address. $headers = "from: " . "the developer" . "\r\n"; mail('#@domain', 'check', $client, $headers);` as far have seen, headers stripped / replaced sms gateway headers prepare. altering parameter on end have no effect. option @ renting short code number or using price-based sms gateway provider. i'm assuming measure in effect prevent malicious intent.

ruby - rails render format- why two formats -

this code generated scaffolding def index @swimming_classschedules = swimming::classschedule.all respond_to |format| format.html # index.html.erb format.json { render json: @swimming_classschedules } end end why generated 2 formats . seems use html format. when json format used? sometimes need data in format of json. ruby on rails 1 of must used framework backend of mobile application (android, ios). android , ios support data in format of json. data of json format generated when scaffloding. in case of web application not necessary generate data in format of json.

amazon ec2 - Deploy ruby 2.0 and rails 4.0 on EC2 with beanstalk -

i deployed rails 4 app on ec2 beanstalk. since there no ruby 2.0 , rails 4.0 container available currently, installed ruby 2.0 , rails 4.0 on instance follow post: installing ruby 2.0 , rails 4.0.0beta on aws ec2 but still got error passenger: your ruby version 1.9.3, gemfile specified 2.0.0 (bundler::rubyversionmismatch) i cd /var/app/current, run $ ruby -v ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux] is there missed? thanks some info updates: $ bundle /usr/local/rvm/gems/ruby-2.0.0-p195/bin/bundle $ gem env rubygems environment: - rubygems version: 2.0.3 - ruby version: 2.0.0 (2013-05-14 patchlevel 195) [x86_64-linux] - installation directory: /usr/local/rvm/gems/ruby-2.0.0-p195 - ruby executable: /usr/local/rvm/rubies/ruby-2.0.0-p195/bin/ruby - executable directory: /usr/local/rvm/gems/ruby-2.0.0-p195/bin - rubygems platforms: - ruby - x86_64-linux - gem paths: - /usr/local/rvm/gems/ruby-2.0.0-p195 - /usr/local/rvm/ge...

ios - PersistenceManager issue -

i have written code save screen data , retrieve second time. code is: <?xml version="1.0" encoding="utf-8"?> <s:view xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" title="homeview" add="addhandler(event)"> <fx:script> <![cdata[ import mx.events.flexevent; import spark.managers.persistencemanager; protected function savebutton_clickhandler(event:mouseevent):void { var savemanager:persistencemanager = new persistencemanager(); savemanager.setproperty("mytext", myinput.text); } protected function addhandler(event:flexevent):void { var loadmanager:persistencemanager = new persistencemanager(); if(loadmanager.load()) { var saveddata:object = loadmanager.getproperty("mytext"); if(saved...

c# - How to set focus to a bound ListboxItem by pressing its child element? -

Image
i developping small wpf application consist in displaying observablecollection<> in others observablecollection<> , , on. here code example of application looks like: <listbox name="mainlist" itemssource={binding}> <listbox.itemtemplate> <datatemplate> <stackpanel> <textblock text={binding mainname} /> <button>add item</button> <button>delete item</button> <listbox name="childlist" itemssource="{binding path=childitem}"> <listbox.itemtemplate> <datatemplate> <textblock text={binding childname} /> </datatemplate> </listbox.itemtemplate> </listbox> </stackpanel> </datatemplate> </...

android-studio new project -

when create new project in android-studio , perfect before launching take lot of time download maven repository , can download of dependencies manually , add android studio . thanks you can have repositories on local file system. works both maven , ivy repositories. example 8.7. usage of local ivy directory build.gradle repositories { ivy { // url can refer local directory url "../local-repo" } } http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html

sql - r XLconnect equivalent to sqlFetch -

i have old 32 bit snippet xl <- odbcconnectexcel("c:/myfile.xls") data <- sqlfetch(xl, "flowers$") but have 64 bit machine , can't use odbcconnectexcel. have read should use xlconnect, how use sqlfetch xlconnect? i.e how rewrite second line of code? try this library(xlconnect) xl <- loadworkbook("c:/myfile.xls") data <- readworksheet(xl,"flower") #assumes worksheet name "flower"

C/C++ Check to see if bit 31 is set in an unsigned int -

i'm trying check , see if bit set in unsigned int. i'm not sure how can this, assume this. i'm trying make cdq instruction in c++ (but function) here have unsigned int cdq(unsigned int eax) { unsigned int edx = 0; if( (eax >> 31) & 1 ) { edx = 0xffffffff; } return edx } when use function following values: cdq(0x12345678) bit 31 set (1) should return (unsigned int)-1 cdq(0x01) bit 31 not set (0) should return 0 the problem returns 0, , i'm not sure why cdq(0x12345678) bit 31 set (1) no, it's not ... highest bit set bit 28: 1 2 3 4 5 6 7 8 0001 0010 0011 0100 0101 0110 0111 1000 ^ ^ | | 31 28 you code should work, use if( eax & (1u << 31) ) edx = 0xffffffff; since it's bit more direct , shifts constant rather variable less work @ run time (although optimizing compiler should produce same code both). actually write like int cdq(int eax) { return eax ...

qt - How to make compiler check what's given to SIGNAL()? -

in writing qt4 app, clumsily wrote: qobject::connect(spinbox, signal(vlauechanged(int)), .... and compiled, , ran, of course spinbox didn't have effect. such misspellings should caught. assumed valuechanged() declared in header file, apparently not. arbitrary garbage can given signal() or slot(), , it'll compile. toy program small. huge app dynamically created controls connected on fly, error hard track down. is there way error checking kind of typo? possible compiler (gcc) this, or other tool appropriate? this has been changed qt5. can read here .

ruby - Rails Form Image_Tag VS File_Field_tag -

i'm making profile picture user can either linkedin or upload it's own. when user get's linkedin it's shown via image_tag : image_tag(base64::decode64(field_value), :alt => "profile_pic",:id => "profile_pic") but user can upload image: file_field_tag("profile_pic") these code rendered apply_helper.rb: def render_profile_image(field, alt, title) if field.nil? content_tag(:span, title) + tag(:br) + image_tag("user.png", :alt => alt) + tag(:br) + \ file_field_tag("profile_pic") + tag(:br) + content_tag(:small, t("apply.create.labels.profile_pic")) + tag(:br) else field_value = field["value"] content_tag(:span, title) + tag(:br) + image_tag(base64::decode64(field_value), :alt => "profile_pic",:id => "profile_pic") + tag(:br) + \ file_field_tag("profile_pic") + tag(:br) + content_tag(:small, t("apply.create.labels.profil...

matplotlib - only 1 colorbar for multiple pie chart using matlibplot -

Image
i have such plot, , add colorbar code (which color corresponds number) on right hand below. saw example used imshow not pie chart. #!/usr/bin/env python """ http://matplotlib.sf.net/matplotlib.pylab.html#-pie docstring. """ pylab import * fracs = [33,33,33] starting_angle = 90 axis('equal') item in range(9): color_vals = [-1, 0, 1] my_norm = matplotlib.colors.normalize(-1, 1) # maps data range [0, 1] my_cmap = matplotlib.cm.get_cmap('rdbu') # can pick color map patches, texts, autotexts = pie(fracs, labels = none, autopct='%1.1f%%', startangle=90, colors=my_cmap(my_norm(color_vals))) subplot(3,3,item+1) fracs = [33,33,33] starting_angle = 90 axis('equal') patches, texts, autotexts = pie(fracs, labels = none, autopct='%1.1f%%', startangle=90, colors=my_cmap(my_norm(color_vals))) item in autotexts: item.set_text("") subplots_adjust(left=0.125, bottom=0.1, ...

javascript - Jquery Help Need For Div Height -

i'm trying auto height of div, div box setup via css 160px overflow: hidden; how can check auto height more 160px or not via jquery ? i need because have box have button show more or show less if height not bigger height 160px pass command ... right making box smaller my code this: <script type="text/javascript"> $("#show_more_websites").click(function() { var button_value = $("#show_more_websites").attr("value"); var box_height = $('.box_show_websites').outerheight(); if(button_value == "show more") { if(box_height <= "160") { var el = $('.box_show_websites'), curheight = el.height(), autoheight = el.css('height', 'auto').height(); el.height(curheight).animate({height: autoheight}, 500); } $("#show_more_websites").attr('value', 'show less'); } if(button_value == "show less") { var el = $('....

dbus - Change Emacs 24 theme depending on connected monitors -

i'm using emacs 24 on ubuntu linux running laptop, connected nice external monitor, 1 color theme (using deftheme). when i'm on road, deftheme. how can make emacs listen monitor connection events, , set theme accordingly? i doubt there easy way react on changes display configuration. on linux, may lucky find dbus service signals such changes, can react upon means of emacs d-bus library , on os x , windows doubt there such simple way. you may better off simple key binding toggles between 2 favorite themes: (defvar my-current-theme nil "the last used theme.") (defun my-toggle-themes () "toggle between favorite themes." (let ((new-theme (if (eq my-current-theme 'solarized-light) 'zenburn 'solarized-light))) (load-theme new-theme :no-confirm) (setq my-current-theme new-theme))) (global-set-key (kbd "c-c t") #'my-toggle-themes)

naming conventions - When to use the Y-Namespace -

is there accepted convention among abap developers when use y-namespace , when use z-namespace customer repository objects? the original intention use namespace y... centrally developed solutions (head office) , z... local development (branch office) - can still find in older (and perhaps more recent) documentation . in experience however, unless enforces these rules system landscape, each developer chooses whatever seems appropriate @ time...

java ee - How can I make this sql query with jpa ? -

i'm trying create query in entities. i have these following tables in mysql db : categorie : id, nom ... article : num_code_barre_, categorie ... in entity categorie : ... @id @generatedvalue(strategy = generationtype.identity) @basic(optional = false) @column(name = "id") private integer id; @size(max = 30) @column(name = "nom") private string nom; ... in entity article : ... @id @basic(optional = false) @notnull @size(min = 1, max = 50) @column(name = "num_code_barre_") private string numcodebarre; @basic(optional = false) @notnull @column(name = "categorie") private int categorie; ... i have tested sql query in db, it's work : select c.nom , count(a.numcodebarre) categorie c inner join article on c.id = a.categorie group a.categorie but when try create namedquery in categorie entity receive error in output: "synthax error parsing query ..." @namedquery(name = "categorie.count...

c# - How to make a process send notification upon its termination -

i wanted programatically determine when process has terminated. searched in various forums , came across pssetcreateprocessnotifyroutine routine. also, came across similar stackoverflow question: .net events process executable start . in accepted answer see query can possibly use. unable quite comprehend query. can suggest way can implement solution? basically, need hook windows management api, allows listen started , stopped processes. once wmi send notification program control inside either of (based on answer ) private void processended(object sender, eventarrivedeventargs e) private void processstarted(object sender, eventarrivedeventargs e) from arguments able process name. this how receive notification in managed code. next step send notification script, , depending can use inter-process communication wcf, restfull call, run script parameters etc.

reverse engineering - How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez? -

i purchased fitbit zip. device uses bluetooth 4.0 le. @ least connect via bluez. if successful want see how of protocol can figure out. i using lenovo p500 ideapad has integrated support bluetooth 4.0. seems work (kind of) when do: hcitool lescan i able find device's bluetooth address, (though potentially irrelevant) is: cf:d9:24:db:f4:7b now, read in question: bluetooth low energy: listening notifications/indications in linux can listen notifications , other protocol features. i've worked old bluetooth, have no experience bluetooth le. i getting stuck trying use hcitool lecc or gatttool connect device. connection times out , seems leave bluetooth in bad state on linux box. able fix reloading bluetooth related kernel modules. any hints appreciated. i'm trying latest bluez now. have @ galileo project , able connect tracker (and synchronise it) using fitbit dongle, bluetoothle connector. bytes used there should figure out 1 need ... full disclo...

c# - TRIGGER show two row affected T-SQL -

i data once. how it? example first action table mytable1 ( name, surname, username, userdate ) first action mytable1 insert mytable1 select name, surname mytable2 second action mytable1 create trigger example on mytable1 after insert update mytable1 set username = 'sysuser1212' , userdate = '2004-09-02 00:00:00.000' i 2 row affected mytable3 once create trigger example2 on mytable1 insert update delete insert mytable3 select name, surname, username, userdate inserted create instead of trigger instead. inside replace username 'sysuser1212' , userdate '2004-09-02 00:00:00.000' while doing insertion. create trigger examplex on mytable1 instead of insert insert mytable1 (username, userdate, name, surname) select 'sysuser1212' , '2004-09-02 00:00:00.000' , name , surname inserted -- following disapear /* create trigger example on mytable1 after insert update ...

Show array values within an array php -

i have piece of code loops , displays values job vacancies: <?php foreach($arrxml $inner_arr) foreach($inner_arr $value) { ?> <p>job ref: <?php echo $value['jobref']; ?></p> <p>date: <?php echo $value['date']; ?></p> <p>title: <?php echo $value['title']; ?></p> <p>company: <?php echo $value['company']; ?></p> <p>minimum salary: <?php echo $value['salarymin']; ?></p> <p>maximum salary: <?php echo $value['salarymax']; ?></p> <p>benefits: <?php echo $value['benefits']; ?></p> <p>salary: <?php echo $value['salary']; ?></p> <p>job type: <?php echo $value['jobtype']; ?></p> <p>location: <?php echo $value['location']; ?></p> <p>count...

url rewriting - Implement friendly URLs with product name -

i'm working on e-commerce site following url format individual products: examplesite.com/shop.php?sec=prod&prod=373 where 373 individual product number. rewrite product urls this: examplesite.com/product-name-here unfortunately, of product names contain characters such *, / , !, should not included in url. i have access everything, limited skills, please assume i'm naive if answer! thanks! using unique slugs ('product-name-here') tricky sometimes. it's better have this: examplesite.com/373/product-name-here.html // or examplesite.com/373-product-name-here ... or other combination, keep product id in url. create slugs, google php slug generator if you're running server apache, need load mod_rewrite module , add .htaccess root of project (there execute index.php) rewriteengine on options followsymlinks # examplesite.com/373/product-name-here.html rewriterule ^([0-9]*)/([a-za-z0-9+-_\.])\.html$ shop.php?sec=prod&prod=$1 ...

php - should I use ajax to import large csv file to mysql database? -

there large csv file need import mysql database there ways bellow 1 , upload csv file using php <?php $row = 1; $handle = fopen("test.csv","r"); while ($data = fgetcsv($handle, 1000, ",")) { // record rows to database } fclose($handle); ?> this way easy ,but waiting long time 2, upload csv file using php use ajax record each row of csv , output ajax feedback <script type="text/javascript"> var row =0; $.ajax({ url:"csv_to_db.php", //record 1 row type:"post", data:{ row : row; }, success:function(){ row++; } }); </script> this way can see active feedback ajax info ,and browser not die when method 1 wait long time way excute fgetcsv function in "scv_to_db.php" every time, seems waiting cpu , memery

java - GAE + Spring MVC : Saving image file to BlobStore -

i succesfully save image blob in datastore code : @requestmapping(value = "/add", method = requestmethod.post) public string add(modelmap model, product form, httpservletrequest request) { if(servletfileupload.ismultipartcontent(request)) { // if(form.getimage().getbytes().getsize() != 0) { try { blob file = new blob(form.getimage().getbytes()); form.setimg(file); } catch (ioexception e) { e.printstacktrace(); } } //save datastore etc } and try save in blobstore , save blob key in datastore. posible? snippet no works : @requestmapping(value = "/add", method = requestmethod.post) public string add(modelmap model, product form, httpservletrequest request) { map<string, blobkey> blobs = blobstoreservice.getuploadedblobs(request); blobkey blobkey = blobs.get("image"); form.setimage1(blobkey); //save datastore etc } i learn this ...

visual studio - How can a web page run a program on client's computer? -

i developed web software visual studio. within web software when click on button, user's computer should run application given .exe file. application console application , needs receive commandline parameters. i've tried run javascript, removed due security issues. dim startinfo new processstartinfo("c:\programadres\program.exe") startinfo.windowstyle = processwindowstyle.normal startinfo.arguments = "arguments" process.start(startinfo) this code successfuly runs application, on server side. need because not know activexand don't know how start.

maven - Warning POM missing in the jar -

i have created jar through maven other project. jar reside in location repository. jar contains pom.xml file in meta-inf/maven///pom.xml , pom.properties. have copied pom.xml file while running pom project using resource-copy plugin. still getting below warning , there fore during building of war maven not able include dependent jars of above jars in war file. other option add thoses jars runtime dependency in war pom file. [warning] pom org.artifact:runtime.ui:war:1.0.0-snapshot missing, no dependency information available i found goal packaging put artifact in local repository. each artifact need install in files system repository pom file. copying pom file using resource plugin not help.

php - Peculiar situation inside an if loop -

i find myself in very peculiar situation . issue function trying call inside if loop not work . if call same function without if loop works fine . $this->build($passed_menu_id, $id_link); . if condition works absolutely fine because echo "hello" gets printed . means going inside loop not executing function . this scenario working fine function menu($passed_menu_id, $id_link) { $this->array_collection = array(); $this->menu_collection = array(); $this->menu_id = $this->_pickmenuid($passed_menu_id); $this->build($passed_menu_id, $id_link); } this scenario not work function menu($passed_menu_id, $id_link) { $this->array_collection = array(); $this->menu_collection = array(); $this->menu_id = $this->_pickmenuid($passed_menu_id); if($this->menu_id==1003){ echo "hello"; $this->build($passed_menu_id, $id_link); } thanks...

Django-CMS multi-regional and multilingual subsite -

we have create multi-regional , multilingual web site. example: http://mysite.com/jp/us/ japan in english http://mysite.com/jp/jp/ japan in japanese http://mysite.com/au/us/ australia in english for multiligual, django-cms , i18n_patterns handle well. when try use django sites framework add multi-regional support, doesnot work expected :(. add site subdomain: mysite.com/au , mysite.com/vn, mysite.com/us. in django-cms admin page add content site already. don't know how config url match site. and want have http://mysite.com/<region>/<language>/ i18n_patterns seem force url http://mysite.com/<language>/<region>/ . how change also please help i'm not sure how flexible url scheme, how this: use standard django cms i18n url rules (so end yoursite.com/ja/ , yoursite.com/en/). next create 2 pages: 'au' , 'jp'. redirect homepage 1 of 2 pages (or write smarter logic that, example in middleware). keep re...

sql server - Instead of NULL how do I show `0` in result with SELECT statement sql? -

i have 1 stored procedure giving me output (i stored in #temp table) , output i'm passing scalar function . instead of null how show 0 in result select statement sql? for example stored proc having select statement follwing : select ename , eid , eprice , ecountry etable ecountry = 'india' which giving me output like ename eid eprice ecountry ana 12 452 india bin 33 null india cas 11 null india now instead of showing null how can show price 0 ? what should mention in select statement make null 0 ? use coalesce() : select coalesce(eprice, 0) eprice in sql server only, can save 2 characters isnull() : select isnull(eprice, 0) eprice

Generic fast coded PHP MySQL dynamic insert/update query creating table/fields named as variables if doesnt exists -

i'm looking way make mysql insert/update queries more dynamic , fast code since 1 need field in form (when example prototyping application). might dumb question. my idea make insert or update if ids match, , if table/fields doesn't exists create 1 function dynamically. <?php // $l set db-login stuff // creates , inserts $f[] = nf(1,'this_id_x'); // this_id_* prefix ids $f[] = nf('value yep',$fieldname_is_this2) $tbl_name = "it_didnt_exist"; nyakilian_fiq($l, $tbl_name, $f); // done! //this update on above $fieldname_is_this2 = "this updated"; $f[] = nf(1,'this_id_x'); $f[] = nf($fieldname_is_this2); // function takes variable name field name $tbl_name = "it_didnt_exist"; nyakilian_fiq($l, $tbl_name, $f); ?> i have been using function success. doesn't add column against structure of mvc framework. try this: public function save(databaseconnection &$db) { $properties = get_object_va...

java - String [] Array Error -

when used string [] array, this: import java.lang.string.*; import java.text.decimalformat; import java.text.numberformat; public class javajoe { public static void main(string args[]) { string [] day = {"monday", "tuesday", "wednesday", "thursday", "saturday", "sunday"}; the output of this: if(day[0] == ("monday")) { double cost = 30; double totalcost = 30 * 1.15; //cost including tax money = money - totalcost; system.out.println("it " + day + " , joe has spend " + decimal.format(totalcost) + " on new pair of shoes. has " + decimal.format(money) + " left."); } //if gave me this: it [ljava.lang.string;@1ea2dfe , joe has spend $34.50. have $165.50 left. can tell me why? why doesn't tell me it's monday? in advance! because printing array itself, calls tostring method of java array. if check implementation of method, see doe...

jquery - JavaScript - Submit Form - To a specific method on a controller -

i've got mvc 4 app. have following javascript function fires whenever change made element id of 'file'. submit works fine. however, submit specific action method on current controller , not method defined in html.beginform definition. i'm new , not sure how go doing this. how can change code submit named action method on controller? $(function () { $("#file").change(function () { $("form").submit(); }); }); you can set action before submitting form: $(function () { $("#file").change(function () { $("form").attr("action", '@url.action("action", "controller")'); $("form").submit(); }); }); update: based on clearer understanding of requirements, if want user stay on same page when posting via change event, can make ajax post, this: $(function () { $("#file").change(function () { var ajaxdata = { ...

asp.net - How do QueryString parameters get bound to Action method parameters? -

i have webforms project, , attempting run code allows me make call mvc route , render result within body of web forms page. there couple of httpresponse/request/context wrappers use execute call mvc route, e.g.: private static string renderinternal(string path) { var responsewriter = new stringwriter(); var mvcresponse = new mvcplayerhttpresponsewrapper(responsewriter, pagerenderer.currentpageid); var mvcrequest = new mvcplayerhttprequestwrapper(request, path); var mvccontext = new mvcplayerhttpcontextwrapper(context, mvcresponse, mvcrequest); lock (httpcontext.current) { new mvchttphandlerwrapper().publicprocessrequest(mvccontext); } ... the code works fine executing simple mvc routes, e.g. "/home/index". can't specify query string parameters (e.g. "/home/index?foo=bar") ignored. have tried set querystring directly within requestwrapper instance, so: public class mvcplayerhttprequestwrapper : httprequestwrapper { private r...

javascript - Dynamic file mapping with relative destination -

Image
this generic question dynamic file mapping grunt.js , example purpose, i'll trying build coffee files in project dynamic structure : here, can have multiple (dynamic) target folders different depth. finding coffee files remain easy, match **/coffee/*.coffee anytime. what i'm trying achieve, making dest property relative matched coffee file : find **/coffee/*.coffee compile ../js/*.js instead of making relative project folder (gruntfile). coffee: { compile: { files: [ { expand: true, src: ['**/coffee/*.coffee'], dest: '../js/', // won't work ! wish :) ext: '.js' } ] } } how achieve ? i don't think that's idea. sounds each target should perhaps repository of own. if ignore that, you'll have other problems, such difficulty telling target , non-target folders apart. example, current pattern potentially mat...

sql server - Vietnamese characters in sql select like -

when search following query select * [table] name '%hà nội t&t%' in mssql database no results , though i'm sure exists in db. i seem have trouble characters ộ, ẫ, , Đ . i have tried changing collation-settings nothing helps. any suggestions? try: select * [table] name n'%hà nội t&t%'

Android. ListView. Add items dynamically -

there listview uses own customarrayadapter. can't dynamically add items listview. listview component of fragment. if(!recentitems.isempty()) { getactivity().runonuithread(new runnable() { public void run() { myfragment.listadapter.additems(recentitems); myfragment.listadapter.notifydatasetchanged(); } }); } all new items added arraylist of customarrayadapter. private arraylist<listitem> values; public void additems(arraylist<listitem> list) { if(build.version.sdk_int < build.version_codes.honeycomb) { for(listitem item : list) { values.add(item); } } else { values.addall(list); } } i have read lot of suggestions till none of them worked me. call notifydatasetchange() after add values.

java - JSF related project facets not appearing in Eclipse Juno -

Image
i'm trying create dynamic web project jsf 2.0 configuration in eclipse java ee juno sr1 . i have installed wtp tools http://download.eclipse.org/releases/juno/ . i use java 1.6 i face following problems : 1. don't have jsf facets in eclipse 2. also, after installing wtp tools, don't web page editor. 3 . on related note, i'm trying use jboss 7.1 application server eclipse, not able find it's adapter either. i use eclipse juno java 1.6

android - How to store information: a database or your apps memory? -

i've been wondering lot. so made database android application. big advantage on making information strings , retrieving them way? or there no advantage @ all? if have single record, case "settings" , "preferences", then, guess store properties file or json string in file system, or more preferably "shared preferences". however, if have multiple records, let's keeping track list of friends current user has, then, database ideal, allow create queries, create cursors lists, , many more advantages.

html - why horizontal Scrolling done by jquery mobile is very slow in android phone? -

i have implemented div image in it.initially div has class div1. when checkbox checked removed class div1 div , added div2 using jquery mobile. when ran project of android phone vertical scrolling working fine horizontal scrolling irritating. horizontal scrolling moving little. moving as movement providing 1 click scroller on browser. need solution. can 1 please ? my html : <div id="mydiv" class="div1"> <img id="img1" src="images/desert.jpg"></img> </div> my css: .div1 { margin-top:5px; margin-left:0px; border-width:5px; border-style:solid; border-color:#000000; overflow: scroll !important; -webkit-overflow-scrolling: touch !important; } .div2 { margin-top:5px; margin-left:0px; border-width:5px; border-style:solid; border-color:#000000; } i have noted before on firefox on platform, browser-side option "smooth scrolling" cause. i'm not sure if reason in case, since searched hours so...

c++ - Multiple uses of new and delete -

i'm simulating traditional card game between 2 players using c++: defined "card" structure that card sample; cout << sample.numb << " of " << sample.suit << " ownded player " << sample.own reads e.g. "10 of spades owned player 2". i set vector "deck" (of size 40) keeping track of every card, , i'm dynamically allocating vectors "g1" "g2" , "tab" @ every step of game, in order handle player 1's hand, player 2's hand , cards on table 3 separated objects (this kind of necessary game itself). since players keep putting cards on table , gaining/losing new cards sizes keep changing, every time this: delete g1; delete g2; delete tab; n1=count (1,deck); // counts how many cards in "deck" have .own field==1 n2=count (2,deck); // counts how many cards in "deck" have .own field==2 nt=count (0,deck); // cards having .own field == 0 on ta...

cq5 - Configure dispatcher on ubuntu 12.04 -

am not able dispatcher working on ubuntu machine, following error after apache restart syntax error on line 2 of /etc/apache2/conf.d/dispatcher.any: invalid command '/farms', perhaps misspelled or defined module not included in server configuration action 'configtest' failed. am using default dispatcher.any file without changes. i've enabled dispatcher module below: loadmodule dispatcher_module /usr/lib/apache2/modules/dispatcher-apache2.2-4.1.4.so <ifmodule disp_apache2.c> # location of configuration file. eg: 'conf/dispatcher.any' dispatcherconfig conf.d/dispatcher.any # location of dispatcher log file. eg: 'logs/dispatcher.log' dispatcherlog /var/log/apache2/dispatcher.log # log level dispatcher log # 0 errors # 1 warnings # 2 infos # 3 debug dispatcherloglevel 3 # if turned 1, dispatcher looks normal module dispatchernoserverhe...

html - Scroller for message content and then fixed text field at the bottom -

hello i'm wondering how able achieve chatbox fixed header & reply textbox. far have. .headerchat{ background-color: #336699; width: 100%; padding-top: 3px; padding-bottom: 3px; font-weight: bold; color: #fff; display: block; } .buddies { background-color: #fff; border: 1px solid #ccc; bottom: 30px; display: none; font-size: 12px; left: 205px; position: fixed; width: 235px; height: 200px; margin: 0; padding: 0; overflow-x: hidden; overflow-y: auto; } .messages { background-color: #fff; border: 1px solid #ccc; bottom: 30px ; font-size: 12px; display: none; left: 205px; position: fixed; width: 235px; height: 400px; margin: 0; padding: 0; overflow: scroll; z-index: 100; } .gray{ color:#aaa; } .chat{ word-wrap:break-word; width: 235px; } .username{ text-decoration: none; color: #336699; text-transform: capitalize; } .username:hover{ text-decora...

objective c - Signaling options change in iOS -

in first "real" ios application, want push options view , signal main controller if options changed. main controller creates options object , passes option view controller, may change properties; question how alert main controller of changes. come several ways this, seems common thing there must standard design pattern, , haven't been able find it. recommendations? handling changes, actions, or user interaction in other views essential use case of delegates . best practice have first view controller delegate of options controller, , user chooses 1 of options, calls methods on delegate notify of final choice. in response delegate calls reload table view, disable/enable buttons, or other updates need do. other options keeping values/state in sync between views are: core data - best used data key-value observation - best used data nsnotification s sent through nsnotificationcenter - best used actions

iphone - Copy From One NSArray to another when generate the Randomly images from First Array -

i developing 1 app in loading images nsmutablearray. generate random images , load uiimageview in ios. want save array after loading array how may this. in advance. my code below. //frontscards array for(m=0; m<[frontscards count];m++) { imgview.alpha=1; imgview.tag=m; nslog(@"img view tag %d",imgview.tag); randidx=arc4random()%[frontscards count]; nsstring *imagename=[frontscards objectatindex:randidx]; nsstring *fullimagename=[nsstring stringwithformat:@"%@",imagename]; int padding=0; cgrect imageviewframe=cgrectmake(scrollview.frame.size.width*m+padding, scrollview.frame.origin.y, scrollview.frame.size.width-2*padding, scrollview.frame.size.height); imgview=[[uiimageview alloc]initwithframe:imageviewframe]; [imgview setimage:[uiimage imagenamed:fullimagename]]; [scrollview addsubview:imgview]; [imgview setaccessibilityidentifier:[frontsc...

java - JDialog inside a wrapper class does not appear -

i have login form instance of jdialog class. doesn't appear inside jframe . implemented inside application before method , worked. after wrapping inside login class not work there not error. problem? public class application extends jframe { jdialog loginform = null; public application() { setdefaultcloseoperation(jframe.exit_on_close); setextendedstate(jframe.maximized_both); setminimumsize(new dimension(800, 400)); setvisible(true); loginform = (jdialog) new login(); } public static void main(string[] args) { try { uimanager.setlookandfeel("com.alee.laf.weblookandfeel"); weblookandfeel.setdecoratedialogs(true); } catch (exception e) { } application app = new application(); } } public class login extends jdialog { private jbutton loginbutton = null; private jbutton cancelbutton = null; private jtextfield usernamefield = null; pr...

jquery - Detecting scroll to bottom - disable up/down scrolling buttons with return -

i have content div lot of stuff in - headers, paragraphs, tables, images, etc - scrollable through up , down buttons. the buttons have mousenter, mouseleave, mousedown , mouseup events. want mousevents disabled - return - when reach respective up/down limits. did (down button): $('.compositos_infobtndown').on('mouseenter', function(){ if ($('.compositos_infocontent').scrolltop() + $('.compositos_infocontent').height() == $('.compositos_infocontent').height()){ return; } // mousenter animation }); $('.compositos_infobtndown').on('mouseleave', function(){ // mousleave animation }); $('.compositos_infobtndown').on('mousedown', function(){ if ($('.compositos_infocontent').scrolltop() + $('.compositos_infocontent').height() == $('.compositos_infocontent').height()){ return; } // mousdown animation // scroll code (working fine) });...

iphone - How to get top left coordinate when the coordinate on circumference of circle is known? -

Image
i have 2 concentric circles, distance between constant. obtain coordinate on circumference of outer circle based on angle obtained when touch in circular portion(including black circle inside). this subclass of uicontrol , use touches method point on circumference. i exact angle , hence exact point on circumference of outermost circle. but want place button on top of concentric circle such diameter = distance_between_concentric_circles + 2 * offset. this offset used button edges should come outside area of concentric circle. image below and each time move button, should move along circular path. since not want draw , m using uibutton , image view, , m finding hard top left co-ordinate based on point on circumference of outer circle , size of uibutton. i can move button not correctly place on circular path. can tell me if there way top left co-ordinate set frame of uibutton. i want without drawing it. any appreciated. it's easier not worry top left...

Options for jQuery's on and dynamically added html -

i'm using jquery's on method bind button click events event. i'm using css class assignment. $('.removebtn').on('click', function () { //code execute on click here }); when page loads, buttons class "removebtn" bound accordingly , work without problem. i dynamically add buttons after page has loaded. these have class "removebtn", not fire. i add these new button's click event handler existing predefined handler, can't find examples of how this. all examples have found want add function event handler @ creation. seems fine simple alert or call, have ajax call , string parsing , validation. don't want repeat code again. i tried adding function call both places, required duplication too. i'd way create new button , tell user function defined in code shown above. what options? you need use event delegation $(document).on('click','.removebtn', function () { //code ...

c# - asp.net mvc 4 letter from site encoding -

i have feedback form on mvc site, need send form email. want test form, save mailmessage object disk *.eml file [httpget] public actionresult contacts() { feedbackform temp = new feedbackform(); temp.message = @resources.global.contacts_form_message_field; return view(temp); } [httppost] public actionresult contacts(feedbackform model) { mailmessage msg = new mailmessage(); msg.bodyencoding = encoding.utf8; msg.from = new mailaddress(model.email, @resources.global.contacts_form_email_title); msg.to.add("tayna-anita@mail.ru"); string message = @resources.global.contacts_form_name_field + ": " + model.name + "\n" + "email: " + model.email + "\n" + @resources.global.contacts_form_phone_field + ": " + model.phone + "\n\n" + model.me...

parsing - Ignoring directories from a file -

i in process of creating script lists files opened via lsof output. checksum specific files , ignore directories output @ loss effectively . example: (i'm using freebsd btw) lsof | awk '/\//{print $9}' | sort -u | head -n 5 prints: / /bin/sleep /dev/bpf what i'd is: output, ignore directories , perform md5 on files (not directories). any pointers? give try following perl command: lsof | perl -mdigest::md5=md5_hex -ane ' $f = $f[ $#f ]; -f $f , printf qq|%s %s\n|, $f, md5_hex( $f ) ' it filters lsof output plain files ( -f ). take perlfunc change add different kind of files. it outputs each file , md5 separated space character. example in system like: /usr/lib/libm-2.17.so a2d3b2de9a1f59fb99427714fefb49ca /usr/lib/libdl-2.17.so d74d8ac16c2d13128964353d4be7061a /usr/lib/libnsl-2.17.so 34b6909ec60c337c21b044642b9baa3d /usr/lib/ld-2.17.so 3d0e7b5b5c4e59c5c4b6a858cc79fcf1 /usr/sbin/lsof b9b8fbc8f296e47969713f6369d97c0d ...

How can I access Spring properties defined in app.properties from Mule FuncionalTestCase? -

how can access spring properties defined in app.properties mule funcionaltestcase? for example, in production config have ${sessionexpiresinsecondsvalue} passed in bean property. want value , use functionaltestcomponent wait same amount of time value , don't want harcode test go out of sync value. the easiest bean receives ${sessionexpiresinsecondsvalue} registry, via mulecontext , , call getsessionexpiresinsecondsvalue() on it.

java - I cannot delete the icon on toolbar -

Image
i new android , copied sample code web , build app on sample code. trying delete image on top toolbar. cannot locate program puts image. here screen. put red mark on toolbar talking , want remove smily face on bar. dont want delete image, want find code puts face there. that located in manifest file under <application> tag. here example: <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme"> now each of ="@somewhere/name" pointer. icon under res/drawable , while other 2 under res/values/

protobuf net - Overriding serialization method of inbuilt types -

i need switch different methods of serialization inbuilt types (datetime example) during runtime or @ least during model initialization. best approach this? have tried surrogating them custom model ( runtimetypemodel.add(typeof(datetime), false).setsurrogate(typeof(uint)) ), got error "data of type has inbuilt behaviour, , cannot added model". it isn't scenario have considered hugely, honest. of "inbuilt behaviour" types really bad idea change implementation, since part of protobuf specifical; however, in case of datetime , timespan , decimal , guid there perhaps alternative layouts supported. can ask want here? there may better ways it. equally important be: magnitude? if few cases, shim property might preferable, example: public datetime when {get;set;} [protomember(4)] private uint whenserialized { { return yourconverter.fromdatetime(when); } set { when = yourconverter.todatetime(value); } } it may possible enable "surrogate...

Sharepoint 2010 DocumentSets - How to Manage Programatically? -

i new sharepoint 2010 not new .net programming. here situation, have large set of files uploaded sharepoint 2010 metadata. have decided write c# class library handle documentsets programatically. have use documentsets , able create documentset. stuck following: how check if documentset exists? how remove documentset? here code create documentset: using (spsite site = new spsite(spurl)) { using (spweb web = site.openweb()) { splist docs = web.lists["documents"]; if (docs != null) { spcontenttype docsetct = docs.contenttypes["document set"]; if (docsetct != null) { hashtable docsetprops = new hashtable(); docsetprops.add("new docset", "new docset"); documentset docset = documentset.create(docs.rootfolder, documentsetname, docsetct.id, docsetprops, true); docs.update(); } } } } ...

android - Pass integer between classes in Java -

this question has answer here: transferring int variable between activities android 2 answers so have class push button, , @ , int maxpluseen want pass on classb. private void populatebtn() { foto1 = (button) this.findviewbyid(r.id.button2); foto1.setonclicklistener(new view.onclicklistener() { @suppresslint("simpledateformat") @override public void onclick(view v) { int maxpluseen = maxindex + 1; log.d("log!", "uiteindelijk resultaat " + maxpluseen); intent myintent = new intent(classa.this, classb.class); classa.this.startactivity(myintent); } }); } i tried doing following: public static int access(int maxpluseen){ return maxpluseen; } and in classb protected void oncreate(bundle savedin...

javascript - variable at end of string -

i'm trying open popup window on left upper corner of current window. far y positioning works fine, can't x work. how syntax right? function openpopup() { var url = this.href; window.open(url, 'popup_id', 'scrollbars, resizable, width=400, height=300, top='+ window.screeny,'left='+ window.screenx''); return false; } you forgot second + window.open(url, 'popup_id', 'scrollbars, resizable, width=400, height=300, top='+ window.screeny +', left='+ window.screenx);

c - sizeof character and strlen string mismatch -

as per code, assume each greek character stored in 2bytes. sizeof returns size of each character 4 (i.e sizeof int ) how strlen return 16 ? [making me think each character occupies 2 bytes] (shouldn't 4*8 = 32 ? since counts number of bytes.) also, how printf("%c",bigstring[i]); print each character properly? shouldn't read 1 byte (a char) , display because of %c , why greek character not split in case. strcpy(bigstring,"ειδικούς");//greek slen = strlen(bigstring); printf("size %d\n ",sizeof('ε')); //printing each character printf("%s of length %d\n",bigstring,slen); int k1 = 0 ,k2 = slen - 2; for(i=0;i<slen;i++) printf("%c",bigstring[i]); output: size 4 ειδικούς of length 16 ειδικούς character literals in c have type int , sizeof('ε') same sizeof(int) . you're playing fire in statement, bit. 'ε' multicharacter literal , isn't standard, , might come bite you....