Posts

Showing posts from April, 2013

asp.net - how to rectreate this dynamic controls -

try make simple application in have dropdown list tems - numbers 1 4. depending on number user choose - create dynamically number of checkboxes binded checkedchanged event. when user checks of checkboxes checkedchanged event raised , store text of checked checkbox in session , when click button want see text checked checkboxes. but seems in checkedchanged event handler should recreate dynamic cotrol haven't found solution. thank in advance. public partial class proba : system.web.ui.page { protected void page_load(object sender, eventargs e) { dd1.items.add("1"); dd1.items.add("2"); dd1.items.add("3"); dd1.items.add("4"); } protected void dd1_selectedindexchanged1(object sender, eventargs e) { int numtourists = convert.toint32(dd1.selecteditem.text); (int = 0; < numtourists; i++) { checkbox chk = new checkbox(); chk.id = "chk" + i; chk.text =

android - TextView below ImageView -

Image
i can't place label want. show picture. i have following code: <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:layout_weight="1" android:orientation="vertical" > <textview android:id="@+id/textviewnombrevideo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/imageviewlogo" android:layout_alignparentbottom="true" android:layout_alignright="@+id/imageviewlogo" android:lines="2" android:scrollhorizontally="false" android:singleline="false" android:text="medium text" android:textappearance="?android:attr/textappearance" android:textcolor="@android:color

drupal 7 - How do you assign certain permissions to a single user without using the roles? -

adding permissions role enables given permission users in role default; want avoid. want able set permissions "booking: view own bookings" @ user level , not role level. is there module this, or can give me possible approaches or pseudo code of kind? yes, there's user permissions module. user permissions provides interface giving additional permissions individual users without need assign them special role. when module enabled, users 'administer permissions' permission can access 'user permissions' tab on each user's account.

Cakephp 2.3 baking with mongodb datasource -

i try use "./cake bake" configure db (mongo) , models. when digit command on shell, output is: welcome cakephp v2.3.2 console app : app path: /var/www/cakephp/app/ interactive bake shell [d]atabase configuration [m]odel [v]iew [c]ontroller [p]roject [f]ixture [t]est case [q]uit bake? (d/m/v/c/p/f/t/q) d database configuration: name: [default] > datasource: (mysql/postgres/sqlite/sqlserver) where mongodb's drivers? try taking @ this github repo . it allow use mongodb datastore cake

java - openCV: reading submat while sliding over bigger Mat -

i want read fixed-size-submat bigger mat while sliding on bigger 1 pixel pixel (or maybe 5 pixel 5 pixel or somtheing that, hope idea). is there predefined function in opencv, if 1 it? (besides using java opencv 2.4.5..) have idea how write myself in java using mat.submat(a,b,c,d) , thought underlying c++ dll implementation lot faster. is want? cv::mat i; // large mat cv::rect win; // sub mat win.width = 5; win.height = 5; for(size_t i=0;i<i.rows-5;++i) for(size_t j=0;j<i.cols-5;++j) { win.x = i; win.y = j; i(win) //<- submat } `

vba - How to break long string to multiple lines -

i'm using insert statement in code in vba excel i'm not able break more 1 line sqlquerystring = "insert employee values(" & txtemployeeno.value & " _ ,'" & txtcontractstartdate.value & "' _ ,'" & txtseatno.value & "' _ ,'" & txtfloor.value & "','" & txtleaves.value & "')" it giving error "expected end of statement". plz help. you cannot use vb line-continuation character inside of string. sqlquerystring = "insert employee values(" & txtemployeeno.value & _ "','" & txtcontractstartdate.value & _ "','" & txtseatno.value & _ "','" & txtfloor.value & "','" & txtleaves.value & "')"

javascript - How to validate multiple fields at the same time using JQuery -

i have created form validates using jquery , javascript. problem is, validates 1 field @ time. user has correct first field first , press submit again see if next field valid. what to do, have jquery validate whole form after pressing submit , show applicable error messages. here js: function validateusername() { var u = document.forms["newuser"]["user"].value var ulength = u.length; var illegalchars = /\w/; // allow letters, numbers, , underscores if (u == null || u == "") { $("#erroruser").text("you left username field emptyyy"); return false; } else if (ulength < 4 || ulength > 11) { $("#erroruser").text("the username must between 4 , 11 characters"); return false; } else if (illegalchars.test(u)) { $("#erroruser").text("the username contains illegal charectors men!"); return false;

ruby - Finding in txt specific chars by index -

i have problem ruby homework. there txt file 1000 chars (one per each line) program asks user 9 numbers 0..999 after should find , print 9 chars file example output give 1. number between 0-999: 444 give 2. number between 0-999: 756 give 3. number between 0-999: 223 give 4. number between 0-999: 999 give 5. number between 0-999: 0 give 6. number between 0-999: 123 give 7. number between 0-999: 23 give 8. number between 0-999: 44 give 9. number between 0-999: 533 word ryqbaasqn here code #coding:utf-8 path = "7-3_tiedosto.txt" lst = array.new word = array.new text = "" puts "luodaan salasana." in 1..9 print "anna #{i}. luku väliltä 0-999: " lst.push(gets.to_i) end = file.open(path, "r") my.each{|line| word.push(line.chomp)} my.close in 0..8 = lst[i] text = text << word[a] end puts "ohjelma loi salasanan #{text}" this looks opportunity familiarize ruby debugging. issues

c# winforms gridview and selection boxes -

i have winforms c# app displays tabular data db gridview control. i need programmatically add final column tickbox each row, in order find out rows have been ticked form current view. how go doing that, tickbox column not exist in db? you add column directly datasource before binding datagridview. supposing using datatable datacolumn dc = table.columns.add("select", typeof(bool)); dc.defaultvalue = false; grid.datasource = dt; another method define datagridviewcheckboxcolumn() , append current column list checkcol = new datagridviewcheckboxcolumn(); checkcol.headertext = "select"; checkcol.width = 80; checkcol.readonly = false; grid.columns.add(checkcol);

java - How to stop repeated keyPressed() / keyReleased() events in Swing -

so problem having appears bug occurs on linux. i'm trying have swing app record when key pressed down, detect when key released. shouldn't in issue because keylistener supposed handle me. the problem when hold key down lots of repeated keypressed()/keyreleased() events instead of single keypressed(). have solution or workaround knowing when key released on linux? thank you. so problem having appears bug occurs on linux yes linux problem. on windows when key held down multiple keypressed events single keyreleased event. this question asked , i've never seen solution. but think basis of solution use timer. when key pressed start timer. when keypressed restart timer. long timer interval greater repeat rate of key board timer continually reset when key held down. when keypresses stop being generated timer fire assume key has been released. implies have delay in processing keyreleased.

c# - Binding to DataGrid of TabItem not Working using MVVM -

Image
i have small application myself learn wpf , mvvm etc. have been using example josh smith found here construct own application. have got application adding tabitem s, embedded datagrid bound observablecollection<resourceviewmodel> not showing data, see image below: the datagrid section surrounded in blue. usercontrol seems showing in tab reason, not problem asking here. usercontrol contains datagrid bound follows <datagrid itemssource="{binding resources}" dataaccess:datagridtextsearch.searchvalue="{binding elementname=searchbox, path=text, updatesourcetrigger=propertychanged}" alternatingrowbackground="gainsboro" alternationcount="2" horizontalalignment="stretch" verticalalignment="stretch"> ...</datagrid> the resources property defined in viewmodels namespace internal class resourcedataviewmodel : workspaceviewmodel {

How to set script-src in a Chrome packaged app? -

i'm trying create chrome packaged app complicated web app. i'm getting error: refused execute inline event handler because violates following content security policy directive: "default-src 'self' chrome-extension-resource:". note 'script-src' not explicitly set, 'default-src' used fallback. how explicitly set policy in manifest.json? i've tried things like: "content_security_policy": "default-src 'inline'; script-src 'inline'" but still same error message. syntax wrong, or error red herring? you can't loosen default csp in packaged app. if you're doing <button id="foo" onclick="dosomething()"> should instead include separate js file in html document.queryselector("#foo").onclick = dosomething; in onload handler. comply csp , make app more resistant xss attacks.

jquery event bubbling and mobile :active hacks -

i'm fixing :active states of buttons on mobile page so: $('body').on('touchstart', 'a', function (e) { $(this).addclass("active"); }).on('touchend touchcancel click', 'a', function (e) { $(this).removeclass("active"); }); this delegation/bubbling approach works great, because i'm doing lots of dynamic page manipulation , don't want have re-apply hack. however, have additional code this: $('a#myanchor').click(function(e){ e.preventdefault(); // return false; }); this of course prevents first block working :( there elegant solution this? i know can re-apply hack #myanchor , that's ugly. is there way prevent clicking <a> causing navigation, allowing click event still propagate dom? bonus: can prevent other explicit click handlers attached #myanchor firing, still allow propagation dom? you've sorted now, it's annoying seeing unanswered quest

phpunit - Force loading of extra-lazy assoc in Doctrine2 for unit testing (no DQL) -

i'm running small problem unit testing in symfony2. have few associations marked extra-lazy, fine. however, when testing them, don't loaded (of course), means assertions fail. i'm not doing dql, entity testing. how can tell doctrine ignore extra-lazy tag unit testing alone ?

javascript - Jquery Text editor issue -

the following code of page want use jquery text editor (jqte). however, after trying nothing seems working. have included required files in same folder aspx page.the jquery reference included on masterpage. <%@ page title="" language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codefile="articleview.aspx.cs" inherits="articles_articleview" %> <asp:content id="content1" contentplaceholderid="head" runat="server"> <link href="jquery-te-1.3.6.css" rel="stylesheet" type="text/css" /> <script src="jquery-te-1.3.6.min.js" type="text/javascript"></script> </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <div></div> <div> <textarea class="jqte-test" na

How to process onchange events for select elements which is dynamically created using javascript? -

i have create few "select" elements in html file dynamically. , intend create same amount "select" elements according value of former created "select" elements. thus have set of "select" elements pair. when first "select" element's selected value changed, second "select" elements refresh options using according records in database. my problem can't receive correct value of first "select" element. everytime when onchange event called, value passed on onchange function( in case, it's called "fillsource()" value before change happened instead of changed selected value. do know how solve problem? the following javascript code: <script> var selectcount = 1; var cats = #{dropcatsjson}; var subcats = #{dropsourcejson}; function addnewsource() { var inputchange = document.createelement('select'); inputchange.options[0] = new option("pls

php - Foreach and unset() -

ran little snag , wondering if there "best practices" way around it. so learned "a php foreach execute on entire array regardless. test unsetting value next in iteration. iterate on offset, value null. – kevin peno dec 22 '09 @ 21:31" how remove array element in foreach loop? it's first part of that messing me. i'm iterating through array foreach. it's search function i'm removing element searched for, when loop runs again minus element. i not want reindex if @ possible, although if have can. array ( [0] => array ( [0] => [1] => aa [2] => aaa ) [1] => array ( [0] => b [1] => bb [2] => bbb ) [2] => array ( [0] => c [1] => cc [2] => ccc ) [3] => array ( [0] => d [1] => dd [2] => ddd ) ) foreach($array $key=>$value) { $searchresult[] = search functi

Windows App Store - use of "results" view for my own search -

Image
i have implemented search mechanism in app. user fill textbox , click on button. there way use nice results view of microsoft? i'm talking view can see in image attached. i giving few resources, please check out , let know if face problem. guidelines , checklist search (windows store apps) quickstart: adding search app windows 8 , future of xaml: part 4: contracts in winrt/windows 8 search contract sample msdn

assembly - GAS, MOVQ Throws operand mismatch, when trying to copy rax to mmx register -

i'm using gnu assembly , gcc compiler. have make operations using mmx registers. i've got memory buffer of bytes, i'm reading 1 byte memory %al, making logical , operation , shifting rax left 1 byte , inserting on lower bits next byte memory until %rax gets full. when i'm trying do: movq %rax, %mm0 compilers throws: error: operand type mismatch `movq' examples: this works: mov $0, %rcx\n" movl , %ecx\n" mov (%1, %rcx, 8), %rbx\n" movq %rbx, %mm0 this don't: mov (variable_that_contains_address, %rcx, 4), %rax ;get 4 bits memory movb %al, %bl andb $0b00011111, %bl ;only lower 5 bits needed movb %bl, %dl ;store whole byte @ rdx shl $8, %rdx ;make space next byte shr $5, %rax ; need next 5 bits, because data in memory saved not in bytes movb %al, %bl ;next 5 bits ;repating until rdx full (some higher bits unused) movq %rdx, %mm0 ; , compiler throws mismatch error this code not full code - full code long. it'

opengl - Crash when glDrawArray and glDrawElements in one programme -

Image
void init_cube(void){ makecube(cbr_points,cbr_normals); glgenvertexarrays(1,&vaid_cube); glbindvertexarray(vaid_cube); glgenbuffers(1,&vbid_cube); glbindbuffer(gl_array_buffer,vbid_cube); glbufferdata(gl_array_buffer,sizeof(vec4)*cbr_points.size()+sizeof(vec3)*cbr_normals.size(),0,gl_static_draw); glbuffersubdata(gl_array_buffer,0,cbr_points.size()*sizeof(vec4),cbr_points.data()); glbuffersubdata(gl_array_buffer,cbr_points.size()*sizeof(vec4),cbr_normals.size()*sizeof(vec3),cbr_normals.data()); gluint vposition = glgetattriblocation(g_idshader,"vposition"); glenablevertexattribarray(vposition); glvertexattribpointer(vposition,4,gl_float,gl_false,0,buffer_offset(0)); gluint vnormal = glgetattriblocation(g_idshader,"vnormal"); glenablevertexattribarray(vnormal); glvertexattribpointer(vnormal,3,gl_float,gl_false,0,buffer_offset(cbr_points.size(

ssh - Keypair login to EC2 instance with JSch -

i want able use jsch java ssh library connect ec2 instance. how use .pem keypair aws jsch? how deal unknownhostkey error when attempting connect? the groovy code use jsch library connect ec2 instance, run whoami , hostname commands, print results console: @grab(group='com.jcraft', module='jsch', version='0.1.49') import com.jcraft.jsch.* jsch jsch=new jsch(); jsch.addidentity("/your path pem/gateway.pem"); jsch.setconfig("stricthostkeychecking", "no"); //enter own ec2 instance ip here session session=jsch.getsession("ec2-user", "54.xxx.xxx.xxx", 22); session.connect(); //run stuff string command = "whoami;hostname"; channel channel = session.openchannel("exec"); channel.setcommand(command); channel.seterrstream(system.err); channel.connect(); inputstream input = channel.getinputstream(); //start reading input executed commands on shell byte[] tmp = new byte[1024]; while (

java - Save is not performing in Spring Mvc 3Hibernate -

article class: package net.devmanuals.model; import java.util.date; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.table; import javax.persistence.temporal; @entity @table(name = "imei") public class article { @id @column(name = "imei1",nullable = false) private long imeino; @column(name = "date_added") @temporal(javax.persistence.temporaltype.date) private date addeddate; public article() { } public long getimei1() { return imeino; } public void setimei1(long imei1) { this.imeino = imeino; } public date getaddeddate() { return addeddate; } public void setaddeddate(date addeddate) { this.addeddate = addeddate; } } articlecontroller class: package net.devmanuals.controller; import java.util.hashm

c++ - Google Mock Destructor -

i'm trying become familiar google's mocking framework can more apply tdd c++ development. have following interface: #include <string> class symbol { public: symbol (std::string name, unsigned long address) {} virtual ~symbol() {} virtual std::string getname() const = 0; virtual unsigned long getaddress() const = 0; virtual void setaddress(unsigned long address) = 0; }; i want verify destructor called when instance deleted. have following mocksymbol class: #include "gmock/gmock.h" #include "symbol.h" class mocksymbol : public symbol { public: mocksymbol(std::string name, unsigned long address = 0) : symbol(name, address) {} mock_const_method0(getname, std::string()); mock_const_method0(getaddress, unsigned long()); mock_method1(setaddress, void(unsigned long address)); mock_method0(die, void()); virtual ~mocksymbol() { die(); } }; note: i've omitted inc

web crawler - PHP Start script where it timed out -

i'm building web crawler start test on shared webhosting, not allow set_time_limit can't make sure script keeps running longer 30 seconds. what best way start php script next time timed out before? thinking saving last crawled url in file there other options? edit: scallioxtx right, can't use variables goto label. around large if statement, @ point i'd it's best not use goto @ all. here alternative method: <?php // load label number database or text file $label_num if($label_num <= 1) { // stuff } if($label_num <= 2) { // more stuff } // ... ?> old (incorrect) method: you can of course use goto : http://us1.php.net/goto i use temporary measure until better hosting. here's do: at various locations throughout code, write label (ex. count1: , count2: , etc.) at each location added label, write label name database or text file at beginning of script, load value , jump specifi

ember.js - Load model like a refresh without ember-data -

i'm writing little ember app without using ember-data (using themoviedb api) , don't understand why model not load when click on {{#linkto}} link, when refresh page manually datas loaded correctly. here app.js : window.app = ember.application.create(); app.router.map(function() { this.route('about'); this.resource('movie', { path: '/movie/:movie_id' }) }); app.indexroute = ember.route.extend({ setupcontroller: function (controller) { var movies = []; $.ajax({ url: "http://api.themoviedb.org/3/movie/popular?api_key=5b088f4b0e39fa8bc5c9d015d9706547", type: "get", async: false, success: function (data) { var length = data.results.length; data.results.foreach(function (item) { if (item.backdrop_path != null) { var tmp = item.backdrop_path;

database - Normalization a table -

i want normalize table 3nf ----------------------------------- | | | | | v v v ---------------------------------------------------------------------------------------------------------- |user_name|post_id|post_title|post_text|post_submitted_time|comment_id|comment_text|submited_comment_time| ---------------------------------------------------------------------------------------------------------- | | ^ ^ ^ | | | | | ------------------------------------------------------------------------------------------- how can work? assuming user_name pk. ------------------------------------------------------------ |post_id|post_title|post_text|post_submitted_time|user_name| --------------------------------

Javascript vs jQuery Function Difference? -

i've been making program , want know difference between starting 2 functions so: $(function () { //content }); and function name () { //content } also, why can't name first example? tried changing first example second type, , function stopped working fully. i've used jquery first example , fine, different example, function stopped working. so what's difference? $(function () {}); shortcut $(document).ready(function(){}); while this: function name () { //content } is standard javascript function. http://api.jquery.com/ready/ http://www.w3.org/wiki/javascript_functions

sql - PSQL - how to insert data to the altered table? -

i have employee table foreign key dno refers dnumber in department table. in department table there foreign key mgr_ssn refers ssn in employee table. i created table using alter table employee add foreign key (dno) references department(dnumber) on delete restrict on update cascade; (both dno , mgr_ssn not null) but confused how insert data, because violates referential integrity constraint, suggestion? thank :) foreign keys not given "not null" constraint. if there new employee has not been assigned dept. or new dept no manager. still, problem should use " deferrable " property of oracle constraints. means, constraint checked @ commit point only. can insert dno , empnos first, commit later. @ point there no constraint viokation fk exists. alter table employee add foreign key (dno) references department(dnumber) deferred deferrable; --do same dept then, insert emp (...) insert dept(...) commit;

glassfish - Java bean server not running properly -

i using java beans create application remote interface, have simple methods printdetail returns "abcd", test method. have session bean this: @stateless public class mysession implements mysessionremote { @override public void businessmethod() { system.out.println("aaaababa"); } when deploy server, error: severe: core10012: application deployed not @ original location more i use glassfish 3.1 i found solution, go browser type localhost:4848, select applications in left list, disable other running apps deployed. e.g mine saying like severe: core10012: application deployed not @ original location more "c:user/ .... / xyz " then should disable app xyz because apparently server still running app if have created new one.

jquery - Why are my tab contents not refreshing? -

i have page several tabs on it. when user enters value in text input , mashes button, want replace contents on particular tab. have code (some of details elided show pertinent parts/explain i'm doing). it works great first time - tab loads fine; subsequent clicks of button (after changing text input value) has no effect, though. why not? must force tab "refresh"? equivalent, perhaps, "application.processmessages()" in desktop environment? here's pertinent html: <input type="text" name="inputtext" id="inputtext" placeholder="enter something" autofocus style="display: inline-block;" /> <input type="button" name="inputbutton" id="inputbutton" value="find" style="display: inline-block;" /> ...and jquery: <script> $.support.cors = true; $(document).ready(function () { $("#duckbilledplatypustabs").tabs({

[org.openqa.selenium.remote.RemoteWebElement@f76d0bdd -> unknown locator] -

i trying read element can later use id of element. using below code first webelement. throws following in console: "[org.openqa.selenium.remote.remotewebelement@f76d0bdd -> unknown locator]" webelement ele = driver.switchto().activeelement(); system.out.println("webelement :"+ele); you seeing because asking code print ele.tostring() . which, according source, going give exact message see: https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/remote/remotewebelement.java#375 specifically: public string tostring() { if (foundby == null) { return string.format("[%s -> unknown locator]", super.tostring()); } return string.format("[%s]", foundby); } it says 'unknown locator' because 1 isn't explicitly set setfoundby . so, suggest if want id of element, use: ele.getattribute("id");

c# - asp.net MVC 4 - output list of checkbox items, associate selections with user - allow display & editing later -

asp.net c# mvc 4 code first application - in visual studio 2012 express, sql server 2012 express. i have places object. output name of places in list - check box next each. i logged in users select places - , have saved. later can login , see them again, appropriate check boxes selected. what best approach? i'm new mvc , not sure of best practice here. thanks update the below checkboxlistfor helper worked great, though wasn't obvious how process user selection (it returns list of ids). i created below take list of ids - convert list of objects, , add selectecities list in view model. select checkboxes user selected before page posted: public actionresult examples(postedcities postedcities) { // viewmodel citiesviewmodel cvm = new citiesviewmodel(); // create list of cities list<city> cities = new list<city>{ new city { id = 1, name = "london"}, new city { id = 2, name = "saigon"}, new city { id = 3, name = "new

c++ - got an unexpected answer from the x?y:z expression -

here simple c++ snippet: int x1 = 10, x2=20, y1=132, y2=12, minx, miny, maxx, maxy; x1<=x2 ? minx=x1,maxx=x2 : minx=x2,maxx=x1; y1<=y2 ? miny=y1,maxy=y2 : miny=y2,maxy=y1; cout<<"minx="<<minx<<"\n"; cout<<"maxx="<<maxx<<"\n"; cout<<"miny="<<miny<<"\n"; cout<<"maxy="<<maxy<<"\n"; i thought result should be: minx=10 maxx=20 miny=12 maxy=132 but result is: minx=10 maxx=10 miny=12 maxy=132 could give explanation why maxx not 20? thanks. due operator precedence, expression parsed this: (x1<=x2 ? minx=x1,maxx=x2 : minx=x2), maxx=x1; you can solve with: (x1<=x2) ? (minx=x1,maxx=x2) : (minx=x2, maxx=x1); and don't need first 2 pairs of parentheses. also check question .

Interrupt MATLAB programmatically on Windows -

Image
when using matlab through gui, can interrupt computation pressing ctrl - c . is there way same programmatically when using matlab through the matlab engine c api ? on unix systems there solution: send sigint signal . not kill matlab. it'll interrupt computation. looking solution works on windows. clarifications (seeing answerer misunderstood): i looking way interrupt matlab calculation, without having control on matlab code being run. i'm looking programmatic equivalent of pressing ctrl - c in @ matlab command window, on windows systems. a mathematica-matlab interface : need forward interrupts mathematica matlab. mentioned above, have working implementation on unix; question how on windows. one way make matlab engine session visible, prior executing long computations. way if want interrupt execution, bring visible command window focus , hit ctrl-c. this can done using engsetvisible function here quick example tried using matlab com automation

Android Fragment Unable to go back -

i have app uses fragments tabs/viewpager [tab 1][tab 2][tab 3] tab2 has listview , in onclick method of listview showing detail view following code fragmenttransaction transaction = getchildfragmentmanager().begintransaction(); nextfragment nextfragment = new nextfragment(); transaction.replace(r.id.container, nextfragment); transaction.addtobackstack(null); transaction.commit(); the issue in nextfragment when use hardware button whole app closes? i'm not sure why doesn't let return when pressed, i've done in application following: i have overriden onbackpressed action , created check once pressed , user in fragment wants return from, create fragment transaction previous fragment. have done because needed update previous fragment, i'm sure there better way solve problem.

python - Can I link numpy with AMD's gpu accelerated blas library -

i reconized numpy can link blas, , thought of why not using gpu accelerated blas library. did use so? update (2014-05-22) amd has produced beta release of amd core math library (acml) version 6.0 can offload fft , blas functions gpu using clmath internally. announcement here: acml beta 6.0 release leverages power of heterogeneous compute . caveat here input data must transferred cpu gpu , output data returned cpu on each blas or fft call. therefore, amd has bunch of scripts tuning when problem large enough acml use gpu instead of cpu. for sake of completeness, i'll mention nvidia supports similar functionality nvblas library relies on cublas , cuda won't work on nvidia gpus. original answer unfortunately, amd's gpu accelerate blas library cannot directly link numpy or other application expecting standard cpu-based blas library. reason existing gpu blas libraries require 1 first copy matrices gpu before calling blas functions. requires modify n

Accessing @attribute from php object -

i'm trying access values php object returned api. trying 'total' atribute. stdclass object ( [@attributes] => stdclass object ( [status] => ok ) [invoices] => stdclass object ( [@attributes] => stdclass object ( [page] => 1 [per_page] => 25 [pages] => 1 [total] => 5 ) my returned object stored in variable called $list. $list->invoices->attributes->total i'm trying echo / print_r that, getting nothing? any appreciated! the @ part of property name, can't ignore it. echo $list->invoices->{'@attributes'}->total;

Why is python itertools "consume" recipe faster than calling next n times? -

in python documentation itertools provides following "recipe" advancing iterator n steps: def consume(iterator, n): "advance iterator n-steps ahead. if n none, consume entirely." # use functions consume iterators @ c speed. if n none: # feed entire iterator zero-length deque collections.deque(iterator, maxlen=0) else: # advance empty slice starting @ position n next(islice(iterator, n, n), none) i'm wondering why recipe fundamentally different (aside handling of consuming whole iterator): def other_consume(iterable, n): in xrange(n): next(iterable, none) i used timeit confirm that, expected, above approach slower. what's going on in recipe allows superior performance? uses islice , looking @ islice , appears doing fundamentally same thing code above: def islice(iterable, *args): s = slice(*args) = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1)) nexti = next(i

caching - Couchdb conceptual problems -

as understand, update object couchdb. have send whole object since "inserting" new revision same id. neat , works quite well. but have problem, i'm not sure how should handle that. have object can't sent user completely. have hide informations such password hash. the data sent client, revision sent too. when try update object have 1 problem. since data missing, update erase attributes missing user. that said, easiest way have object couchdb, check if id , rev matches. if match, merge object missing attributes. work pretty , can support deleting attributes too. then using technique, add objects cache reduce time query frequent objects database. if object can updated, clear cache id. if object newer, i'll have handle error or merge object. is there better "good way" handle problem? edit after thinking during night, think found much better solution. instead of having username , password inside profile. i'll separate identification obje

python - Profiling CherryPy -

i've been trying start profiling cherrypy webserver, documentation lacking in detail in how should set up. understand should able use cherrypy.lib.profiler middleware mount initial server. right now, have code following: server_app = serverclass() cherrypy.tree.mount(server_app, '/', '/path/to/config/file.cfg') cherrypy.engine.start() cherrypy.engine.block() i want mount profiling middleware, , seems following required: from cherrypy.lib import profiler server_app = serverclass() server_cpapp = cherrypy.application(server_app, '/', '/path/to/config/file.cfg') server_profile_cpapp = profiler.make_app(server_cpapp, '/home/ken/tmp/cprofile', true) #cherrypy.tree.mount(server_profile_cpapp) cherrypy.tree.graft(server_profile_cpapp) cherrypy.engine.start() cherrypy.engine.block() for reason cherrypy.tree.mount doesn't work, if use cherrypy.tree.graft seems operate fine (i can make requests server normal) however, above code

Issue with MySQL INSERT via PHP mysql_query -

i'm having problems bizarre problem when trying insert record mysql via php , wondering if shed light on it, because i'm out of ideas now. database table: field type null default comments userid bigint(20) no autoincrement userguid text no serverid int(11) no username text no passwrd text no prompt text no answer text no email text no verified int(11) no 0 language text no gender int(1) yes null dateofbirth int(11) yes null country int(11) yes null postcode text yes null state text yes null town text yes null snippit of relevant php code... public function signupuser($uid, $pwd, $prompt, $answer, $email, $lang, ... &$result) { $guid = $this->getguid(); $serverid

Rails OmniAuth NoMethodError with Facebook -

i've been following this tutorial setting omniauth facebook, when try run /auth/facebook, error follows: nomethoderror in sessionscontroller#create undefined method `[]' nil:nilclass my code same 1 in tutorial, except auth = request.env['rack.auth'] is changed to auth = request.env['omniauth.auth'] thanks in advanced, please. matt those instructions bit dated. try railscasts instead.

ios - Phonegap/Cordova 2.7.0: exec_gap file not found -

ive started new project cordova 2.7.0. when run in web browser , @ console see error saying file !exec_gap? not found. i've done searching , see others have had problem cordova in past. there answers change line execxhr.open('head', "file:///!gap_exec", true); to: execxhr.open('head', "/!gap_exec", true); in cordova.js file. however, in 2.7.0 line this: execxhr.open('head', "/!gap_exec?" + (+new date()), true); does know how fix this? (ps: if matters running jquery mobile , working on ios) phonegap/cordova framework mobile development framework. used develop mobile application using html, css , javascript. if there native app needed camera, phone book , etc., framework used these our html app. this, app call gap_exec . the app developed using phonegap can't run in application. kind of application call hybrid application. hybrid application: combination of both native application ,

vba - Visual Basic-Excel copy only some column to other sheet -

Image
is there way click , copy value of column other sheet. this picture explain more: here code have errors dont know why: private sub worksheet_selectionchange(byval target range) sheets("sheetb").select ' find last row of data finalrow = cells(rows.count, 1).end(xlup).row ' loop through each row x = 1 finalrow ' decide if copy based on column in sheetb thisvalue = cells(x, 1).value if thisvalue = target.value cells(x, 1).resize(1, 33).copy sheets("sheetc").select nextrow = cells(rows.count, 1).end(xlup).row + 1 cells(nextrow, 1).select activesheet.paste sheets("sheetb").select end if next x end sub try below code : kindly add header columns on sheet b before running code. suggest using procedure worksheet_selectionchange event. private sub worksheet_selectionchange(byval target range) applicat

asp.net mvc - Cross browser compatibility issue for showing and hiding div -

i have mvc app. i have written below code in js in create view. on basis of selection on drop down show , hide div. problem below code works in google chrome , mozilla firefox. working in ie 8. what should ? $('#paymenttype').change(function(){ var ptype=document.getelementbyid("paymenttype").value; if(ptype=="on account") { $(".invoicediv").hide(); } else { $(".invoicediv").show(); } }); i not sure real issue since using jquery why don't use ptype, too? this, cross-browser issue minimized (if not avoided). $('#paymenttype').change(function(){ var ptype = $(this).val(); ... }); hope helps.

compilation - Main C Program does not find header and methods -

wasn't sure how explain better in title. learning how separate code in c. have main, equivalent of arraylist class java (but converted c , basic) , header file declares struct , functions in use. using sample code out of text , using latest version of dev c++ windows 8. every time try compile main get: in function main undefined reference "newlist" [error] id returned 1 exit status here code: main.c #include <stdio.h> #include "arraylist.h" int main(int numparms, char *parms[]){ list mylist; mylist = newlist(mylist); printf("end"); return 0; } arraylist.c #include <stdio.h> #include "arraylist.h" list newlist(list mylist){ mylist.size = 0; return mylist; } list add(list mylist, int value){ mylist.values[mylist.size] = value; mylist.size++; return mylist; } int get(list mylist, int position){ int entry; entry = mylist.values[position]; return entry; } int size(list mylist){ re

Objective C - Faded Gradient on left/right sides of UICollectionView -

Image
i have horizontal-scrolling uicollectionview within main view of view controller (grey uiview, wood uicollectionview): i want add fixed faded gradients on far left & far right sies of uicollectionview scrolls appear vanish user scrolls. how go doing this? involve use of cagradientlayer? grateful can give me! i managed figure out using 1 mask layer this tutorial @ cocoanetics . here's did: @interface scalesviewcontroller : uiviewcontroller { cagradientlayer *masklayer; } @end then in .m, placed in following: - (void)viewdidappear:(bool)animated { [super viewwillappear: animated]; if (!masklayer) { masklayer = [cagradientlayer layer]; cgcolorref outercolor = [[uicolor colorwithwhite:0.0 alpha:1.0] cgcolor]; cgcolorref innercolor = [[uicolor colorwithwhite:0.0 alpha:0.0] cgcolor]; masklayer.colors = [nsarray arraywithobjects: (__bridge id)outercolor, (__