Posts

Showing posts from March, 2010

android intent has other flags -

i new android developing , looking @ code of guy worked here before. check connect server. works great (see d/connectivitychecker(29802): isonline=true). create new intent , set flag (public static int online_flag = 1) can see in intent.setflags 1. send intent via sendbroadcast connectionchangereceiver. and if read out intents flag not 1 17! this code of connectionchangereceiver: /** * receives notifications connectivity changes */ private broadcastreceiver connectionchangereceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { log.d("connectionchangereceiver","intent.flags(): '" + intent.getflags() + "' icm.online_flag: '" + internetconnectionmanager.online_flag+"'"); setonlinemode(intent.getflags() == icm.online_flag); } }; this logcat: 05-08 14:28:05.615: v/icm(29802): checkconnectivity 05-08 14:28:05.615: v/icm(29802): connectivityche

Alter database design with JPA -

i working on database jpa , curios altering database design. lets have table , want add/remove column in table. i have tried re-deploying technique did not work me. using jpa 2.0 so, want know there standard way alter database tables or manually add/remove table's design? possible change primary key of table ? any highly appreciated. thanks :) for non-production dbs can use persistence.xml properties either create, drop-create or update existing db schema (example hibernate): <persistence ...> <persistence-unit ...> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> for eclipselink, property name different , available options: <property name="eclipselink.ddl-generation" value="create-tables"/> <property name="eclipselink.ddl-generation.output-mode" value="database"/> for production dbs stick manual changes have careful details , timing.

xaml - LongListSelector in WP8 -

i trying create first wp8 application. have experience on silverlight & wpf not cake me expected :(. making create employ form in user entered different information of employ. need show country list combobox. noticed in wp8, have use longlistselector confused how display other textboxes etc control form. longlistselector work on full page want show combobox in simple window form application. know basic question appreciate help. you cant use combobox in wp8 ... you can use listpicker new control introduced in wp8 toolkit... in if list contains less 5 members show dropdown otherwise show list on different page.

Twitter Bootstrap - Button Width in Drop-down menu -

fairly new bootstrap-- have button , drop down menu composed of unordered list containing buttons. how make button widths same-- or off base code: here code: <div class="btn-group" style="margin-bottom: 5px"> <a class="btn btn-large dropdown-toggle" data-toggle="dropdown" href="#"> <i class="icon-wrench"> </i>admin actions <span class="caret"></span></a> <ul class="dropdown-menu"> <li> <button class="btn btn-large"> <i class="icon-plus"></i>create content</button> </li> <li> <button class="btn btn-large"> <i class="icon-wrench"></i>edit page</button></li> <li><button class="btn btn-large"> <i cla

c# - What is the best practice to define consistently from access layer to listitems -

i quite new asp.net / webforms , might sound basic question, if defining client class in webforms asp.net hold clientid, clientname , type of client (proposed, fullclient, dead) not sure of best way make consistent access layer/database, hold type of 'p' - proposed f - fullclient , 'd' dead definition of client class through creating listitem setting client in html of possible choices requires option , description believe class uses enum? if point me simple great. thanks in advance. just use enum , can store things in shared project other projects have references too, yourproject.utilities. here's enum : public enum clienttype { [description("proposed")] proposed = 1, [description("dead")] dead = 2, [description("full client")] fullclient = 3 }

linux - Why doesn't this call to `poll` block correctly on a sysfs device attribute file? -

i have simple sysfs device attribute shows under sysfs directory, , on call read returns value of kernelspace variable. want call poll on attribute allow userspace thread block until value shown attribute changes. my problem poll doesn't seem block on attribute -- keeps returning pollpri though value shown attribute not change. in fact, have no calls @ sysfs_notify in kernel module, yet userspace call poll still not block. perhaps should checking return value of other pollpri -- according documentation in linux kernel, sysfs_poll should return pollerr|pollpri : /* ... when content changes (assuming * manager kobject supports notification), poll * return pollerr|pollpri ... */ is there i'm forgetting poll ? the device attribute located at: /sys/class/vilhelm/foo/blah . i load kernel module called foo registers device, , creates class , device attribute. the userspace application called bar spawns thread calls poll on device attribute, checkin

java - Indenting TextView Text in android -

i have textview text let's say • asking question stackoverflow how can make textview show like • asking question stackoverflow string facil = accomodation.facilities; facil = facil.replace("<>", "%"); spanned sp = html.fromhtml(facil); facil = sp.tostring(); string[] items = facil.split("%"); charsequence allfacil = ""; (int = 0; < items.length; i++) { string text = items[i]; spannablestring s = new spannablestring("• " + text + "\n"); s.setspan(new bulletspan(bulletspan.standard_gap_width), 0, text.length(), 0); allfacil = textutils.concat(allfacil, s); } facilities.settext(allfacil.tostring()); i have done this... string[] items = new string[] { "item 1", "item 2", "item 3" }; charsequence alltext = ""; (int = 0; < items.length; i++) { string text = items[i]; spannablestring s = new spannablestr

caching - How to suppress azure cache client warnings from the WAD logs -

we have 2 roles use cache role share data. when deploy many many of following entries in logs: information: <casclient> updated partition table (1-901) generation: 635036190744461419:0 transfer (1-901) generation: 635036190744461419:0; tracesource 'w3wp.exe' event information: <complaint> add hard complaint :0 ; tracesource 'w3wp.exe' event changing values of setting: <setting name="microsoft.windowsazure.plugins.caching.clientdiagnosticlevel" value="0" /> seems have no effect. any ideas how can remove noise wadlogs table? it seems there bug in caching (see post ). tried rid of these log entries no luck running sdk1.8. switched sdk2.0 unfortunately problem still not fixed. bug report on github

javascript - Twitter bootstrap popover with manual click trigger. Preventing default -

i'm trying figure out how configure multiple twitter bootstrap's popovers manual click. but first, code: # bootstrap.js.coffee # opens popover new server data $('*[data-poload]').bind 'click', -> $this = $(this) $.get $this.data('poload'), (d) -> $this.popover content: d html: true title: $this.parents("tr").data("title") .popover 'show' # handles clicks everywhere on page , decides if finds opened popovers $("html").click (e) -> $('*[data-poload]').each -> $(this).popover "hide" if not ($(this).is(e.target) or $(this).has(e.target).length > 0) , $(this).siblings(".popover").length isnt 0 , $(this).siblings(".popover").has(e.target).length 0 this popoverable link. have hundreds of these on same page different data-poload attribute: <a href="#" data-poload="/resources/some-id/popover">text<

css - How to hide/remove "box" with comments and "Share on facebook" information? -

how hide/remove "box" comments , "share on facebook" information?(it displayed after click "like") https://developers.facebook.com/docs/reference/plugins/like/ when have issue/need add width element containing iframe(like button), believe somewhere around 80px.

html - CSS Layout Issue - Div not extending with content -

i new div layouts , working css please forgive me if don't make sense i'm ask. issue have page if blank page renders correctly divs filling screen. when tested situation content larger content area content div did not expand in height content. have worked on couple of hours can't seem work. below css sheet looks like. guidance can give appreciated. ideal fix header section @ top @ 100px, submenu section under header @ 50px, footer @ bottom of page @ 50px , content section between submenu , footer section. if content doesn't fill page content section fills rest of page footer @ bottom , if content larger page content section pushes footer down screen fill content in. (hope makes sense) i webpage has following divs in it. div 1 - container div 2 - header div 3 - submenu div 4 - content div 5 - footer css sheet body, html { height: 100%; margin: 0px; padding: 0px; background-color: #7eb5d6; } .container { width: 700px; height: 10

jsp - Servlets and Spring Integration -

i'm new in jsp , servlets, web.xml file <?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>loginpage</servlet-name> <servlet-class>com.planner.servlet.loginpage</servlet-class> </servlet> <servlet-mapping> <servlet-name>loginpage</servlet-name> <url-pattern>/loginpage</url-pattern> </servlet-mapping> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <context-param> <param-name>contextconfiglocation</param-name>

html - Link to a page with iFrame to load different PDF files -

i'm working on project has slight complexity it, , i'm not on how approach this. can load pdf's in iframe no problem, issue have follows: we have landing page links pdf articles. create second page, header , navigation of landing page, include type of iframe or viewer allow user click given pdf link, , have document load in viewer or iframe of second page. any on how achieve appreciated. use shadowbox that. site shadowbox.js it's easy install, follow simple instructions. on landing page need link <a href="second_page.html#mypdf">pdf</a> on second page shadowbox style link <a href="mypdf.pdf" rel="shadowbox" id="mypdf">pdf</a> don't forget fix paths.

How to set td width by jquery? -

i have table width 100%. table can have several cells. how can set cell width jquery. if have 2 td need set them 50%, 50%. <table> <tbody> <tr> <td></td> <td></td> </tr> </tbody> </table> please go through documentation . $('table td').width(value);

android - Lazy Loading (Image + Text) for Linear Layouts -

Image
i trying implement activity shown in image(wireframe) uploaded(). there n number of such items.(lazy loading expected implemented.) images imagebuttons , qty(quantity) spinners. item name, item price , item images fetched server. i expect different implementation when click on item image , when click on qunatity spinner. not possible when implement using listview + adapter. (i have followed http://wptrafficanalyzer.in/blog/android-lazy-loading-images-and-text-in-listview-from-http-json-data/ ) i expect images loaded in different thread. could please give me direction on how go this? have read enough implementations using listview + adapters. none of them solve problem lars has great tutorial on listviews , using custom adapters populate them here . section titled "listviews , performance" should helpful. for lazy loading, check out universal image loader . have initialize image loader in application class , call imageloader.getinstance() anywhere need u

What is the least-dirty way to expose private javascript vars for testing? -

i've got state machine in js (to simplify) has initial state set before happens. define(function() { var state = 'initial', exports = {}; exports.getstate = function() { return state; }; exports.dosomething = function() { state = 'newstate'; }; return exports; }); because state permanent until app reloaded, after first test state never 'initial' again, , need way reset it. which least dirty way of doing this? should i... a) make state public mark private _? define(function() { var exports = {}; exports._state = 'initial' exports.getstate = function() { return this.state; }; exports.dosomething = function() { this.state = 'newstate'; }; return exports; }); b) make state writable via function? define(function() { var state = 'initial', exports = {}; exports.getstate = function() { return state; }; exports.dosomething = function() { state = &

php - How do I access a variable inside of preg_replace_callback? -

i'm trying replace {{key}} items in $text values passed array. when tried adding print_r see going on got undefined variable: kvpairs error. how can access variable form within preg_replace_callback ? public function replacevalues($kvpairs, $text) { $text = preg_replace_callback( '/(\{{)(.*?)(\}})/', function ($match) { $attr = trim($match[2]); print_r($kvpairs[strtolower($attr)]); if (isset($kvpairs[strtolower($attr)])) { return "<span class='attr'>" . $kvpairs[strtolower($attr)] . "</span>"; } else { return "<span class='attrunknown'>" . $attr . "</span>"; } }, $text ); return $text; } update: i've tried global scope thing, doesn't work either. i've added 2 print statements see whats doing on, 1 inside , 1 outside preg_replace_callba

How to make sure String objects are garbage collected in Java -

here code snippet. method(){ string s1="abc"; string s2 = new string ("abc"); s1=null; s2=null; -------- --------- } at end s1 & s2 objects exists? how make sure these objects garbage collected ? they garbage collected after go out of scope. unless you're having serious performance issues, i'd stop worrying , let garbage collector it's thing. you should careful though, there kinds of elements such file streams, open sockets, , such not managed that. have close those.

c++ - How to find largest figure in 2d array -

Image
i have image example of matrix marked cells in makes figures. the thing is, have count , find largest figure in matrix. as can see there 3 figures each 3, 19 , 2 black fields. ok understund how if cell black or white, how can tell figure counted , 1 biggest. this task connected component labeling algorithm

php - Make RokSprocket to fetch k2 item's video but getting undefined property error -

i'm bulding website joomla, , i'm using roksprocket display featured item on frongpage. roksprocket can use k2 content provider, though can't fetch k2 item's video. tried modify php files got undefiend property $stdclass::video error. here's do: roksprocket using function convertrawtoitem convert raw items(in case k2 items) roksprocket items: protected function convertrawtoitem($raw_item, $dborder = 0) { //$textfield = $this->params->get('k2_articletext_field', ''); $item = new roksprocket_item(); $item->setprovider($this->provider_name); $item->setid($raw_item->id); $item->setalias($raw_item->alias); $item->settitle($raw_item->title); $item->setdate($raw_item->created); $item->setpublished(($raw_item->published == 1) ? true : false); $item->setcategory($raw_item->category_title); $item->sethits($raw_item->hits); $item->setrating($raw_

Issue With mapping 2D to 1D array in CUDA -

i had written following code in cuda __global__ void test(int *b_dev) { int index=blockdim.x*blockidx.x+threadidx.x; b_dev[index]=1; } int main() { int **a; int *b_dev; a=(int**)malloc(sizeof(int*)*4); for(i=0;i<4;i++) a[i]=(int*)malloc(sizeof(int)*4); //initialise array here 0 cudamalloc((void**)&b_dev,sizeof(int)*16); cudamemcpy(b_dev,a,sizeof(int)*16,cudamemcpyhosttodevice); test<<<4,4>>>(dev_b); cudamemcpy(a,b_dev,sizeof(int)*16,cudamemcpydevicetohost); for(i=0;i<4;i++) for(j=0;j<4;j++) cout<<a[i][j]; } i have 2d array in host flatten 1d array , process in gpu code produces segmentation fault when try print array a,in host,but when comment out line b_dev[valindex]=1 in kernal,it prints array a initialised zeroes. visual c++ debugger indicates that cxx0030:error expression cannot evaluated. kindly please lead me on when have array of arrays allocated in manner

asp.net - How to avoid SQL injection -

i have tool points out sql injection issues , found 1 follows : "select gb.btn,gup.cust_username,gup.email gbs_btn gb,gbs_user_btn gub,gbs_user_profile gup gb.btn=gub.btn , gub.cust_uid=gup.cust_uid , gb.et_id='" + straccountid + "' order create_date desc",ocin" can please tell me how construct above query avoid sql injection? option 1: use parameterized queries instead of contencating strings. more info can found here: http://msdn.microsoft.com/en-us/library/ff648339.aspx option 2: use parameterized stored procedures option 3 escape strings using replace() should last resort. it's weak, , there ways around it. string sql = "select * sometable somestringfield = '" + myvariable.replace("'", "''") + "'";

c++ - Strange output for a simple OpenMP program on Multi2sim v4.0.1 -

i'm trying run simple program using openmp the program follows #include <iostream> #include <fstream> #include <vector> #include <omp.h> #include <algorithm> #include <math.h> #include <map> #include <string> #include <ctime> using namespace std; #define num 10 void openmp() { omp_set_num_threads(1); int sum =0; #pragma omp parallel shared(sum) { (int i=0;i<100;i++) { sum++; } } cout<<"sum = "<<sum<<endl; } int main() { cout<<"open mp \n"; openmp(); return 0; } now when compile using g++ test.cpp -fopenmp -o test and run on ubuntu terminal ./test the output correct - think - follows open mp sum = 100 but when try run using multi2sim using these 2 files given instructor multicore-config: [ general ] cores = 4 threads = 1 multicore-mem-config: [cachegeometry geo-l1] sets = 256 asso

Xcode 4.6 if statement with && -

my problem is -(ibaction)setaction:(id)sender{ if ([labelone.text isequal: @"one"] && [labeltwo.text isequal: @"two"]) { labelshow.text = @"yes works :)"; } } and if build it. show me error code: thread 1: signal sigbart but works if this -(ibaction)setaction:(id)sender{ if ([labelone.text isequal: @"one"]) { labelshow.text = @"yes works :)"; } } what can do, first 1 works?:) the sibabrt implies either labeltwo or labeltwo.text pointing bad memory. first figure out pointer bad, , debug see why. also, provide crash log when possible. there should error message associated in debug output pane. check out this debugging tutorial .

Suppress display of a result in scala worksheet -

i suppress output of helper variables in scala worksheet: val sqs = scen.rssis.toseq.filter { case (ap,s) => s.exists(e => e.epoch > 1) }.sortby { -_._2.length }.take(10) //> sqs : // *snip* lot of stuff i'd rather not have //| output exceeds cutoff limit. sqs foreach { case (api,s) => println(f"${scen.aps(api).ssid}%-10s ${s.length}% 5d") } //> 2wire230 74 //| 2wire736 74 //| jamie56 73 //| vvhoa 69 //| 2wire059 68 //| rainsnet 68

.net - C# Windows Form Project Loading Blank On Other Machines -

i searched around not find on this. i have programmed c# application in vs 2010, targeted .net framework 4.0. has .dll , few config files have being copied output directory upon compilation. works great on computer, have .net 4.0 extended , .net 4.0 client installed. set build configuration "release" on "any cpu". after compiles copy files release directory folder on shared drive, multiple computers on network can execute it. when execute computer used develop it, runs great. when others try execute starts shows small blank form, , that's it. make sure have .net 4.0 installed (both extended , client, though think full version required). i can't life of me figure out why this. all machines running 32 bit windows vista sp2. any thoughts? appreciation help. it can lot of things. first, 1 comment, should quick deployment project , try install on computer see how work. if can't that, here couple of things check: it can networ

ios - Proper declaration of global C-constants in Objective-C -

i'm trying declare , initialize global c-variables. const int numberoftickmarks = 6; const double tickvalues[numberoftickmarks] = {500, 2000, 3000, 4000, 6000, 8000}; when in header file (before @interface ), linker error. when in .m file (before @implementation ), things seem work desired. is latter accepted way declare global constants c/objective-c? your global variables should declared in header file: extern const int numberoftickmarks; extern const double tickvalues[numberoftickmarks]; without extern , linker errors inevitable. in implementation file, have define them again this: const int numberoftickmarks = 6; const double tickvalues[numberoftickmarks] = {500, 2000, 3000, 4000, 6000, 8000};

sql server 2008 - Unpivot columns to generate rows -

i have query this: select '35111212', '11245452', '42215512'...... , more values. this results in: (no column name) (no column name) (no column name) -------- -------- -------- 35111212 11245452 42215512 and need transform to: (no column name) -------- 35111212 11245452 42215512 is possible without using "union"? have large amount of values in select. you can this, if columns named: select val ( select col1 = '1', col2 = '2', col3 = '3' ) unpivot ( var col in (col1, col2, col3) ) unpvt

sql server 2008 - Capture allotments used for unresolved cases in CRM -

is there way capture minutes used service activities performed under case without resolving case ( case status active)? i have report captures allotment details ( total allotments, remaining allotments, used allotments) resolved cases. but, know how time being spent activities case still active. i appreciate if me out! new , learning! you can calculate since creation of case or if have audit enabled since specific state of case. option create new fields , create plugin when pass through state calculate minutes between last state example.

sharepoint - Retrieve All Documents from all Subfolders in a Document Library - CSOM -

i using client side object model approach c# in order retrieve list items document library containing sub folders. checked out msdn documentation , stuck why cannot field property, or if doing right. networkcredential credentials = system.net.credentialcache.defaultnetworkcredentials; clientcontext clientcontext = new clientcontext(resources.defaultspsite); clientcontext.credentials = credentials; //load libraries sharepoint //web site = clientcontext.web; clientcontext.load(clientcontext.web.lists); clientcontext.executequery(); //list shareddocumentslist = clientcontext.web.lists.getbytitle("testldocs"); //camlquery camlquery = new camlquery(); //camlquery.viewxml = @"<view scope='recursive'><query></query></view>"; foreach (list list in clientcontext.web.lists) { clientco

php - retrieve values from database and use foreach -

i have database 3 columns: product_id, product_name, product_image. need run query retrieve values , create list of data. product_id | product_name | product_image | 1 | ball | ball.jpg | 2 | shirt | shirt.jpg | 3 | car | car.jpg | this code i'm using: $q1 = $db->execute("select * products"); $q1_items = array(); while(!$q1->eof){ $q1_items[] = $q1->fields; $q1->movenext(); } foreach ($q1_items $items) { echo '<a href="index.php?main_page=product_info&products_id='. $items['products_id'] .'"><img src="images/'. $items['products_image'].'" alt="'. $items['products_name'].'" title="'. $items['products_name'].'" /></a>\n'; } this zen cart site $db->execute defined , works fine. the output i'm expecting this: <a href="inde

java - Correct way to "merge" two custom listview adapters -

i'm using custom listview adapter connect listview database. i'd add endless list functionality listview. i've found custom listview adapter here https://github.com/commonsguy/cwac-endless implements endless functionality i'm looking for. now what's ideal way integrate these 2 adapters? should make current listview adapter sub-class of endless one? i.e. baseadapter -> endlesslistadapter -> mycustomlistadapter. work? they'll duplicate overridden methods. have downloaded demo app of cwac-endless ? have demo, , demo answer question, have class called demoadapter overrides endlessadapter. :) also, take @ this "to use endlessadapter, need create subclass control endlessness, specifying view use "loading" placeholder, , updating placeholder actual row once data has been loaded."

javascript - Using yeoman 1.0b, the grunt server's livereload functionality does not work correctly -

i trying yeoman running again on mac. 1.0 beta confusing error present when restart mac. in earlier versions start yeoman server , hit control+c terminate it. when wanted server again, yeoman start again. think problem livereload not shut down correctly (or still running), dont know how shut down properly. grunt start .... yeoman log .... ... uhoh. got error listen eaddrinuse ... error: listen eaddrinuse @ errnoexception (net.js:884:11) @ server._listen2 (net.js:1022:14) @ listen (net.js:1044:10) @ server.listen (net.js:1110:5) @ server.listen (/users/theuser/web/2013/project/node_modules/grunt-contrib-livereload/node_modules/tiny-lr/lib/server.js:133:15) @ object.startlrserver (/users/theuser/web/2013/project/node_modules/grunt-contrib-livereload/lib/utils.js:22:11) @ object.<anonymous> (/users/theuser/web/2013/project/node_modules/grunt-contrib-livereload/tasks/livereload.js:44:20) @ object.thistask.fn (/users/theuser/web/2013/project/nod

Facebook App "Misconfigured for Mobile Access" - Works in different places depending on Facebook settings, but not everywhere at once -

i've developed facebook web app (so, 1 lives inside iframe when load @ apps.facebook.com/myappname). in facebook app settings, i've set "app on facebook" section include canvas url , secure canvas url. if check "mobile web" section , enter secure canvas url mobile site url, whenever load app mobile browser (e.g., iphone, ipad), following error: "the mobile version of app "appname" unavailable because misconfigured mobile access." i see same error if try go app facebook ios app. however, if not mobile site url, don't see errors in mobile safari, different error trying link app within facebook ios app: "either application has not configured mobile web url or url not verified owned application. unable redirect." i've done lot of searching , i'm not able find clear direction on correct combination of settings is. should specifying mobile url? can same canvas url? etc. i don't have specified in "

css - Removing class Jquery -

i want remove class of .active on $(document).ready . css .active { color: "red" } html <div class="item step-00"> test </div> <div class="item step-0 active"> test1 </div> jquery $(document).ready(function() { $(".item step-0 active").removeclass("active"); $(".item step-00").addclass("active"); }); fiddle you need . before each class this: $(document).ready(function(){ $(".item.step-0.active").removeclass("active"); $(".item.step-00").addclass("active"); }); or simplify this: $(document).ready(function(){ $(".item.step-0, .item.step-00").toggleclass("active"); }); edit: need enable jquery in fiddle. fiddle

google app engine - NDB Query not returning most recently added object -

i have gae website. home page displays list of project objects , form adding more projects. when submit button pressed, ajax request made runs 'create_userstoryproject()' method. method adds new project , returns list of projects, including 1 added. reason, query in 'create_userstoryproject()' method not return project added. however, if refresh page, causing 'get()' method run, newly added project shows fine. haven't simplified code--it's cut , pasted. have idea why newly created project doesn't show until refresh page? class home(baseapp): #baseapp derived webapp2.requesthandler def get(self): self.context['userstoryprojects'] = userstoryproject.query().order(userstoryproject.order) self.context['userstorystatuses'] = userstorystatus.query().order(userstorystatus.order) self.render('/userstories') def create_userstoryproject(self): description = self.request.get('userstoryproject[descrip

jquery - Correct way to use Mustache.js? -

i using mustache.js templating engine. on page load, create list of items send ajax request: private static list<items> items; protected void page_load(object sender, eventargs e) { items = service.getmyitems(0, "text", "sometext"); } in view, ask items using ajax call: <script> getmyitemsbyajax(); </script> which, on success, creates mustache html items, , appends control. i way, avoid waiting time blank page while items list being created. i curious: there smarter way of doing this? your way valid. thing question necessity of using mustache. unless you're generating complex html mustache template alleviate, can append items in ajax callback function , skip client side templating. it's balance between: loading mustache library + creating mustache template or generate html in ajax callback.

javascript - Automatic arrangement of images/rectangles on a canvas with overlapping -

i looking randomly arrange number of images (or simplicity, rectangles) of given sizes on canvas. want these images/rectangles able overlap (edges, sides etc) i.e. don't want image covering image entirely. these images/rectangles parallel x , y axes. also, want images fit canvas area no unused white space. i came across bin packing, quadtree etc. none of these allow overlaps. have idea how might implemented? or point me towards right direction? thank :) assuming conditions specified: no unused white space axis aligned orientation allow margin overlapping never cover whole image we can use bin packing or quadtree algorithms (or whatever), first want manipulate data set. loop through list of image dimensions decide if image should allowed overlap (for tuning desired output) increase dimension data (within margin) used in preferred algorithm(bin-pack/quadtree) (keeping original data well) process data chosen algorithm sort z order/render order (sort r

ruby - how to save the user_id after using "create!" in rails 3? -

i've updated controller code create class micropostscontroller < applicationcontroller before_filter :signed_in_user def create @micropost = current_user.microposts.build(params[:micropost]) if @micropost.review params[:micropost].delete :review @thread = discussion.create!(params[:micropost]) else @micropost.save end redirect_to root_path end when use above, seems work discussion or micropost gets created. however, believe using "create!" not save user_id. when view discussions, user_id nil. how can save user_id whoever made post? tables in schema.db create_table "users", :force => true |t| t.string "name" t.string "email" t.timestamp "created_at", :null => false t.timestamp "updated_at", :null => false t.string "password_digest" t.string "remember_toke

How to find cell value based on row and Column ID in excel VBA -

need vba sub find cell value based on row , column id. in example below need select value east , rt3 intersect 80. b c d e 1 null rt1 rt2 rt3 rt4 2 north 31 40 78 11 3 south 32 41 79 12 4 east 33 42 80 13 5 west 34 43 81 14 use similar below not tested : function getcell(ct string, rt string) range activecell r = .columns("a").find(rt).row c = .rows("1").find(ct).column 'the below escape function if none found if r = nothing or c = nothing exit function set getcell = .cells(r, c) end end function

is it possible write to console without stdlibs? c/c++ -

i programming on arm microprocessor , trying debug using print statements via uart. not want add stdlibs debugging. there way print console without stdio.h / iostream.h ? possible me write own printf() ? alternatively can using dma controller , writing uart directly. avoid possible. using built in test function "echo" or "remote loop-back" know have uart configured properly. short answer: yes, it's entirely possible both of solutions. the printf function quite complex if want support of data types , formats. it's not hard write can output string or integer in few different bases (most people need decimal , hex, octal adds 3-4 lines of code once have decimal , hex). typically, printf written this: int printf(const char *fmt, ...) { int ret; va_list args; va_start(args, fmt) ret = do_xprintf(outputfunc, null, fmt, args); va_end(args); return ret; } and do_xprintf() hard work variants (printf, sprint

sql server - date filtering in dynamic SQL -

set @vsqlfilters = '(abra.start_date !> ' + cast(@denddate varchar(26)) + ' or abra.end_date !< ' + cast(@dstartdate varchar(26)) + ')'; i want parameters @dstartdate , @denddate keep quotes around them. currently, they're typed in manually end user quotes around them. right now, get (abra.start_date !> 2013-05-01 or abra.end_date !< 2011-04-05) in query instead of (abra.start_date !> '2013-05-01' or abra.end_date !< '2011-04-05'). since thrown dynamic sql query, need @denddate , @dstartdate cast strings. want treat dstartdate , denddate dates not integers. don't see how can sql compare dates. thanks! put doubled-up single quotes anywhere within statement want single quote appear: set @vsqlfilters = '(abra.start_date !> ''' + cast(@denddate varchar(26)) + ''' or abra.end_date !< ''' + cast(@dstartdate varchar(26)) + ''')'; howev

javascript - How do I use a php authentication script as proxy to CouchDB and still maintain full REST API functionality? -

i've installed couchdb version 1.2.1 , test can access using following apache rewrite in centos 6: rewriterule couchdb/(.*)$ http://127.0.0.1:5984/$1 [qsa,p] i have php authentication class use across home grown api support mobile apps. api accepts , authenticates each request using hmac signature included in url so: https://api.domain.com/endpoint/?timestamp=[timestamp]&signature=[signature]&id=[id]...etc each endpoint has corresponding script ensures checks proper signature before processing. ideally, i'd replace above reverse proxy rewrite rule sort of php script act gatekeeper/gateway couchdb instance, leveraging authentication class, while still preserving native couchdb rest api functionality, including not limited replication , cookie authentication users (the above api authentication). can done? i've tried using this solution modified below, while in fact kick valid json responses, replication fails, , suspect other aspects such user authen

oop - php class constants with bitvalues -

can classes have bitshifted values defined class constants / static variables ? i want implement permission system similar 1 described here http://www.litfuel.net/tutorials/bitwise.htm (sorry best example find quick google) for example ive tried this class permissions { const perm1 =1; const perm2 =2; const perm3 =4; //--cut-- const perm24 =8388608; const perm25 = perm1 | perm2; } gives syntax error, unexpected '|', expecting ',' or ';' and preferred way class permissions { static $perm1 =1<<0; static $perm2 =1<<1; static $perm3 =1<<2; //--cut-- static $perm24 =1<<23; static $perm25 = $perm1 | $perm2; } which gives syntax error, unexpected t_sl, expecting ',' or ';' the latter way works outside of class environment eg $perm1 =1<<0; $perm2 =1<<1; $perm3 =1<<2; //--cut-- $perm24 =1<<23; $perm25 = $perm1 | $perm2; echo $perm25; giving expected 3 (2+1) (or 2^0 + 2

wordpress - Hide admin menu items and restrict access based on Role -

i know way show/hide menu items in admin based on user roles, can type address , access specific menu. wondering if there way restrict well. for moment i'm using code: add_action( 'admin_init', 'my_remove_menu_pages' ); function my_remove_menu_pages() { // if user not have access publish posts if(!current_user_can('add_users')) { // remove "tools" menu remove_menu_page('tools.php'); } } how going other way: http://codex.wordpress.org/function_reference/add_role

javascript - angular: deep scope traversal and updating -

i have angular scope looks this: { node_type: 100, node_instance: 001, value: 'pony', show: true, childnodes: { node_type: 100, node_instance: 011, value: 'cat', show: false, childnodes: { node_type: 101: node_instance: 001, value: 'apple'show: true, } node_type: 100: node_instance: 012, value: 'kitty', show: true, node_type: 100: node_instance: 013, value: 'meow', show: true, } node_type: 100, node_instance: 002, value: 'horse', show: true, childnodes: { node_type: 102: node_instance: 001, value: 'dog', show: false, node_type: 100: node_instance: 014, value: 'mutt', show: true, } } it's (much) deeper , more complex this. upon making various actions (say, changing "mutt" "fido"), server return newly updated, seemingly unrelated data in set like… { node_type:101, node_instance:001, show:false } i've found various ways of traversing scope fi

html - Chrome Table List rendering bug -

we encountering problem layout of styled unordered list inside of table cell in google chrome. problem not happening in firefox, safari or internet explorer. the unordered list has styles applied margin-left , text-indent. spans associated each list item set "nowrap" white-space. when list item text span wide enough reach right-hand edge of cell, can end getting displaced down , text overlap cell border. problem easiest duplicate when changing zoom settings inside chrome, can occur unpredictably when first rendering page or changing window size. here's link displays html reproduces problem: http://www.grandavenue.com/codeexamples/chrome_table_list_bug.html here's image of problem: chrome bug http://www.grandavenue.com/codeexamples/chrome_td_ul_bug.gif here example html page reproduces problem: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html x

AngularJS module .run order and e2e mocks -

i working on e2e tests angularjs. i have implemented $httpbackend ngmocke2e. this works well, in instances http requests being made before mocks have been set up. the mock set as: angular.module('mock', ['ngmocke2e']). run(function($httpbackend) { $httpbackend.whenpost('/path1').respond({ exampleresponse: 'valid' }); $httpbackend.whenpost('/path2').respond({ exampleresponse: 'valid' }); and used below: angular.module('application', ['firstdependency', 'mock', 'thirddependency']); however firstdependency , thirddependency can make http requests happen before mock .run() block has been executed. results in request errors. am setting mocks correctly? best way ensure mocks loaded in right order? this doc says: dependencies: modules can list other modules dependencies. depending on module implies required module needs loaded before requiring module loaded. in

ruby on rails - precompiling assets failing on remote -

everything working fine locally, when do: bundle exec rake assets:precompile on server, here's get: /usr/local/rvm/rubies/ruby-2.0.0-p0/bin/ruby /usr/local/rvm/gems/ruby-2.0.0-p0@global/bin/rake assets:precompile:all rails_env=production rails_groups=assets rake aborted! uninitialized constant activerecord::connectionadapters::mysql2adapter /mnt/home/bigdata/config/initializers/special_mysql_types.rb:5:in `<top (required)>' /usr/local/rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/engine.rb:588:in `block (2 levels) in <class:engine>' /usr/local/rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/engine.rb:587:in `each' /usr/local/rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/engine.rb:587:in `block in <class:engine>' /usr/local/rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec' /usr/local/rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run' /usr/l