Posts

Showing posts from June, 2012

javascript - jQuery - using JS events like "dragover" -

i've got javascript function eventlistener `dragover. it looks this: document.getelementbyid("someid").addeventlistener("dragover", function(){ //do logic }, false); the thing - someid dynamic element - gets removed , added on page. after it's removed , added in, eventlistener no longer pickup dragover event. way know of how deal situation use jquery's .on() my problem: can't find dragover event under jquery api... exist? if not how can use in jquery? you can define customer drag event as, (function(jquery) { //defining drag event. jquery.fn.drag = function() { eventtype = arguments[0] || 'dragstart'; onevent = typeof arguments[1] == 'function' ? arguments[1] : function() { }; eventoption = arguments[2] || false; $(document).on('mouseover', $(this).selector, function() { if ($(this).hasclass(eventtype)) { return;

GWT -- Retain search text value in html text box after filtering in cell table -

i created custom header cell table in gwt. consists of filter text box , below column name. able filter column data. not able retain search text after filtering cell table. text box becoming empty after filtering. have used html text box in header. please me retain search text value after filtering cell table. have added code below onbrowserevent... @override public void onbrowserevent(context context, element elem, nativeevent event) { super.onbrowserevent(context, elem, event); int eventtype = event.getkeycode(); if (eventtype == keycodes.key_enter) { inputelement inputelement = getinputelement(elem); setvalue(inputelement.getvalue()); if(filterhandler != null){ filterhandler.onfilter(getvalue()); } inputelement.setattribute("value", inputelement.getvalue()); //event.preventdefault(); } } protected inputelement getinputelement(element parent) { element elem = parent.getelem

sql - How to join a view on an array_agg column in Postgresql? -

i'm searching syntax join view array_agg column. view: create view sampleview select groupid, array_agg(akey) keyarray sampletable group groupid; now want this: select s.groupid, a.somedata sampleview s join anothertable on a.akey in s.keyarray; error message: error: syntax error @ or near "s" line 3: join anothertable on a.akey in s.keyarray; either syntax wrong (most likely) or not possible. don't believe not possible if asking alternative option. expected output pseudo query above (with testing code): groupid | somedata ---------+---------- 1 | foo 1 | bar 2 | monkey (3 rows) testing code: create table sampletable (groupid int not null, akey int not null); create table anothertable (akey int not null, somedata varchar(20)); create view sampleview select groupid, array_agg(akey) keyarray sampletable group groupid; insert sampletable values(1,20),(1,22),(2,33); insert anothertable values(20, 'foo'),(22,'ba

java - How to add double elements to RList? -

i tried call r rserve using java code. wanted use rexpgenericvector store , pass array r: rlist r = new rlist(); r.add(new double(1.0)); rexpgenericvector v = new rexpgenericvector(r); // make new local connection on default port (6311) rconnection c = new rconnection(); // assign data variable x c.assign("x",v); system.out.println("printing out v:"+v); however, error message shows @ c.assign("x",v); : java.lang.classcastexception: java.lang.double cannot cast org.rosuda.rengine.rexp @ org.rosuda.rengine.rlist.at(rlist.java:103) @ org.rosuda.rengine.rserve.protocol.rexpfactory.getbinarylength(rexpfactory.java:489) @ org.rosuda.rengine.rserve.rconnection.assign(rconnection.java:272) @ com.xypress.test.main(test.java:29) how can add double or string or other type of data rlist? thanks in advance. i ran in same trap! try class rexpdouble, instead of double. for example: double doublevalue = 1.0; r.add(new rexpdouble(doublevalue));

c++ - Using mpz_t as key for std::map -

i trying build map mpz_t keys uint values. don't know why mpz_t keys can somehow not looked in map. mpz_t leftsidevalues[1 << 20]; int main() { std::map<mpz_t, uint> leftside; (uint = 0; < 1 << 20; i++) { mpz_init(leftsidevalues[i]); // compute stuff here... // save computed value our map leftside[leftsidevalues[i]] = i; // lookup see whether our value can found std::cout << leftside.at(leftsidevalues[i]) << " -- " << << std::endl; } return 0; } the expected output lot of lines looking "0 -- 0", "1 -- 1" etc. not happen. instead: terminate called after throwing instance of 'std::out_of_range' what(): map::at is there other step need take make mpz_t usable in map? it seems map cannot compare 2 mpz_t instances. according the c++ reference maps implemented binary search trees. therefore if elements

php - How to create a common function in codeigniter for checking if session exist? -

i creating application in users have login access various modules. need check if user session exist before providing access each module. now checking session in each function / module / controller avoid unauthorized access. if($this->session->userdata('userid')!=''){ something; } is there better way this? can have common function similar sessionexist(); such can called module / controller / function common whole project? if should write common function such can called anywhere. you want helper function, here is: if ( ! function_exists('sessionexist')) { function sessionexist(){ $ci =& get_instance(); return (bool) $ci->session->userdata('userid'); } } save file in application/helpers/ , include application/config/autoload.php file: $autoload['helper'] = array('my_helper_file');

Handsontable coloring cells using button -

i want allow user color selected cells clicking button (say, red, green , blue buttons). to selected cells found code: $('div#example1').handsontable(options); //get instance using jquery wrapper var ht = $('#example1').handsontable('getinstance'); //return index of selected cells array [startrow, startcol, endrow, endcol] var sel = ht.getselected(); //'alert' index of starting row of selection alert(sel[0]); but can't run code when clicking button, because selection "disappear" after clicking , before function starts run. i try following this instruction need workaround issue. please add outsideclickdeselects: false, options in constructor , can perform 'ht.getselected()' method.

python - In C++, How to read one file with multiple threads? -

i reading .csv file local hard drive using vs2012 in windows 7, 64-bits, 8 core. the file reading has 50,000+ lines , each line has 200+ attributes, read data , feed them corresponding variables time consuming. therefore, wondering if can speed multithreads, each thread reads part of file. i've googled it, , found said that, since hard drive not multithreading, using multiple threads acctually slow down . is true? if possible read file multiple threads, can give me an example can learn from? also, possible explicitly assign thread or task cpu core? and final question: i've read same file python, , has been finished in few seconds. may know why python read faster c++? reading file requires making syscall in language or os, means making call underlying operating system, , waiting put contents of file memory (assuming pass os's security checks , that). multi-threading file read indeed slow down since you'd making more syscalls pops out of program ex

angularjs - Animations in partial views is not working -

i'm attempting use ng-view produce simple slide effect between views. not sure if doing right. codes follows: script: (1.15) <script src="js/lib/angular-1.1.5/angular.min.js"></script> routing: app.config(function ($routeprovider) { $routeprovider. when("/", { templateurl: "partials/loading.html" }). when("/session", {templateurl: "partials/session.html", controller: "timercontroller" }). when("/settings", { templateurl: "partials/settings.html", controller: "settingscontroller" }). otherwise({ redirectto: "/" }); html containing ng-view , ng-click used switch views: <div class="flex-container viewport"> <div class="flex-item-1"> <div> <button class="overlay btn icon-cog" ng-click="changeview('/settings')" type="button"></button>

How does Haskell's "boobs operator" work in plain non-functional English? -

this question has answer here: composing function composition: how (.).(.) work? 7 answers in answer https://stackoverflow.com/a/11006842/1065190 "owl operator" mentioned: absoluteerror = ((.) . (.)) abs (-) to express absolute error function in point-free notation. anyway, how notation work? could you, please, explain non-functional c++ programmer? as possible (.).(.) , written (.:) sometimes, function composition when function being composed on right side has 2 missing arguments. if try use (.) directly doesn't typecheck, although it's quite tempting due idea of functional "plumbing". also, it's worth thinking how (.:) kind of plumbing opposite of data.function.on . flip on :: (a -> b) -> (b -> b -> c) -> (a -> -> c) (.:) :: (a -> b) -> (c -> d -> a) -> (c -> d ->

java - Spring 3: Network Client-Server with custom protocol for runtime service generation -

i looking simplest solution create client-server network architecture using spring 3 framework. architecture woill have many clients , multiple servers. each client can connnect each server. each client can define set of services have generated during runtime server. communication protocol: client says hello 1 of 5 servers. server gather local metadata stored data , send client client pick of info , send metadata subset server deciding data need later. server basing on metadata choice, picked client, generates dynamically services made available client supplying him data pointed requested (step 3) config (eg in form serialized json) client information generated services , use future calls services. the biggest issue client doesn't know nothing server resources served until receives answer , server has no services since request client. i considered spring 3: http invokers jms netty (joined spring) but far tried above it's ether hard provide dynamic serv

facebook - Django allauth: disable form login/signup -

i'd know if know if it's possible disable form login/signup in django-allauth . in business model, user can login/signup using facebook, whenever use @login_required decorator, redirects user login page can input email/password. i couldn't find in docs, thought should ask. you write custom login page has fb link on it. define path page in settings file login_url.

How to get current zoom level from google map for ios? -

i use method camera digital value this: camera = [gmscameraposition camerawithlatitude:37.35 longitude:-122.0 zoom:6]; and need automatically redraw map current position via timer: -(void)gmapredraw{ nslog(@"gmapredraw"); // self.mapview.camera [locationmanager startupdatinglocation]; nslog(@"lat %f, lon %f", locationmanager.location.coordinate.latitude, locationmanager.location.coordinate.longitude); camera = [gmscameraposition camerawithlatitude:locationmanager.location.coordinate.latitude//37.36//-37.81319//-33.86 longitude:locationmanager.location.coordinate.longitude//-122.0//144.96298//151.20 zoom:6]; self.mapview.camera = camera; } -(void)timer{ [nstimer scheduledtimerwithtimeinterval:0.5 target:self selector:@selector(gmapredraw)

php - Search results to display only results that match all terms -

i'm new programming php beyond manipulating prewritten scripts , after lot of reading, , lessons on php searches, cannot find name for, or solution this. using hashtags example since that's want use, i'm looking have search page if search #php #stackoverflow #search bring results contained at least 3. result #php #search, or #php #stackoverflow not come because they're both missing 1 of terms criteria. the idea search own database not through api or sites db. i apologize if isn't right way ask/use stackoverflow, i've never posted here, browsed , read. to simplify; there name/example share me when require search terms matched?

r - Index element from list in Rcpp -

suppose have list in rcpp, here called x containing matrices. can extract 1 of elements using x[0] or something. however, how extract specific element of matrix? first thought x[0](0,0) not seem work. tried using * signs doesn't work. here example code prints matrix (shows matrix can extracted): library("rcpp") cppfunction( includes = ' numericmatrix randmat(int nrow, int ncol) { int n = nrow * ncol; numericmatrix res(nrow,ncol); numericvector rands = runif(n); (int = 0; < n; i++) { res[i] = rands[i]; } return(res); }', code = ' void foo() { list x; x[0] = randmat(3,3); rf_printvalue(wrap( x[0] )); // prints first matrix in list. } ') foo() how change line rf_printvalue(wrap( x[0] )); here print the element in first row , column? in code want use need extract element computations. quick ones: compound expression in c++ can bite @ times; template magic gets in way. assign list object whatever

oop - Hide variables within an anonymous JavaScript function but access them using `this` -

i'll use following javascript code demonstrate trying do. var app = function() { var url var width var height function init() { url = window.location.href width = document.body.clientwidth height = document.body.clientheight } function run() { init() alert(url + ' - ' + width + 'x' + height) } return { run: run } }() app.run() ( run code at: http://jsfiddle.net/zepq9/ ) the above code achieves 3 things: avoids global variables , functions (except global object app intentionally exposed global namespace). hides url , width , height variables , init() function within anonmyous function. exposes run() function outside anonymous function. however, not approach because init() , run() functions have work variables url , width , height . in more involved , larger javascript code, difficult see variable url in function , tell coming from. 1 has lot of

sql server - SQL for duplicating parent and children records -

i'm trying figure out best way create sql statement (in sql server) duplicate parent record , children records. have below example; -- duplicate order insert orders (customerid, employeeid, orderdate, requireddate, shippeddate, shipvia, freight, shipname, shipaddress, shipcity, shipregion, shippostalcode, shipcountry) select customerid, employeeid, getdate(), requireddate, null, shipvia, freight, shipname, shipaddress, shipcity, shipregion, shippostalcode, shipcountry orders orderid = @orderid -- find id of duplicated order declare @neworderid int; select @neworderid = @@identity; -- duplicate order details insert "order details" (orderid, productid, unitprice, quantity, discount) select @neworderid, productid, unitprice, quantity, discount "order details" orderid = @orderid this works duplicating child table "order details". need ability duplicate child

jquery/ ruby on rails - changing the height of a div dynamically -

in app have page user can see reviews listed 1 under other. each review has 'edit' link: <div id ="edit_link"> <%= link_to i18n.t('user.review.edit.edit'), edit_review_path(review), :remote => true, :class => "edit_review_link" %> </div> it loads editable review on same page other reviews, , user can change it. it loads code in edit.js.erb file: $('#review_<%=@review.id%>').html("<%= escape_javascript(render 'edit') %>") now i'm trying change height of review editing when loads. ideas how this? i did try in edit.js.erb file: $('#review_<%=@review.id%>').html("<%= escape_javascript(render 'edit') %>") $('#review_<%= review.id %>').animate({height:'250px'}, 350); //this method increases height 250px, @ .35 seconds but 500 (internal server error) error. i did try this, pasting within _review.html.e

javascript - How to make my stylesheet switch, stick -

i have written code change stylesheets between normal 1 , accessible version. in theory works, refresh page goes default version. know need store cookie of sort , i've tried couple of scripts i've found on google, none work. if has idea of need in order selected stylesheet stick throughout site until other requested, appreciated. code far: <link type="text/css" href="style.css" rel="stylesheet" title="normal" /> <link type="text/css" href="css/accessible.css" rel="alternate stylesheet" title="accessible" /> <form> <input type="submit" onclick="switch_style('normal');return false;" name="theme" value="" id="normal" title="view site in it's original format"> <input type="submit" onclick="switch_style('accessible');return false;" name="theme" value=&q

form for - What are some possible reasons that you would get an undefined method 'TheModelName_path' error using a form_for in rails 3? -

i can't figure out why have error knowledge set should work. this error get: nomethoderror @ /short/new undefined method `shorts_path' #<#:0x007fbc441426e0> my model short not shorts when run rake routes there no shorts_path i'm not sure helper coming from. don't understand why form_for giving me error when @short defined in def new section of controller. can please explain me? thank in advance this controller looks like class shortcontroller < applicationcontroller def show @short = short.find(params[:id].to_i(36)) respond_to |format| #redirect directly url stored long in database format.html { redirect_to @short.long} end end def new @short = short.new respond_to |format| format.html # new.html.erb end end def create @short = short.new(params[:short]) respond_to |format| if @short.save

c# - ASP.NET TcpClient intranet -

i'm developing application in asp.net using visual basic, have connect server in private network. application must working network (in future can work on internet, too), have problem tcpclient on asp.net: if connect server using instance of ipaddress client = new tcpclient client.connect(new ipaddress("192.168.1.12"), 6001) the socket try connect 176.64.116.11 (that's not public ip address...), else, if connect server string contains local ip address client = new tcpclient client.connect("192.168.1.12", 6001) the socket connects succesfully nothing responds command (with networkstream.write , read ) try of these in windows application , work succesfully. thanks (i made mistake in english? ahaha, sorry :d) ps. if post me code in c# don't worry, can translate it tcpclient has various overloads, can give string containing ip address or ipaddress object. also, use ipaddress ipaddress = ipaddress.parse("192.168.1.12"

'Method' vs 'Dynamic Property' in Eloquent ORM with Laravel? -

i want count number of posts belongs tag. should use method or dynamic property? <?php class tag extends eloquent { public function posts() { return $this->belongstomany('post'); } public function postscount() { return count($this->posts); } public function getpostscountattribute() { return count($this->posts); } } so in template should use dynamic property: {{ $tag->postcount }} or method: {{ $tag->postcount() }} excerpt documentation of laravel 4 regarding eloquent's dynamic properties (accessor) in relationships (bold mine): eloquent allows access relations via dynamic properties. eloquent automatically load relationship you , , smart enough know whether call (for one-to-many relationships) or first (for one-to-one relationships) method. accessible via dynamic property same name relation. that said, using method defined database relationship or dynamic prope

python - How can I remove need for these checking functions to be global -

i using python test rest api. response message json , want check each field. have created check_json function , check against checker dictionary. checker dictionary has string key name of key in json value tuple (a pair) first bool parameter, whether item mandatory , second parameter either object direct compare or function add more involved checking functionality. i make check this: r= check_json(myjson, checker) where r result in format: 'field': true or false - dependent on whether check passed or failed the code little messay lots of global functions. 1 idea include checking functions in check_json. have been told use closures. how? here code: # check nested json import json import collections import functools import datetime #this json session myjson = { "accessed": "wed, 31 jul 2013 13:03:38 gmt", "created": "wed, 31 jul 2013 13:03:38 gmt", "dnurls": [ "http://135.86.180.69:

c# - SignalR how to call 2 different method in 1 Hub? -

so have 2 methods in 1 hub: public class chathub : hub { public void sendmessage(string name, string message) { clients.all.addmessage(name, message); } public void sendannounce(string name) { clients.others.addmessage(name); } } how use 2 methods in 1 hub in client side javascript? i have in javascript, for sendmessage(string name, string message) hub method: var message = $("#txtmessage").val(); var userid = $("#lblusername").html(); chat.client.addmessage = function (frm, msg) { $messages.append("[" + frm + "] " + msg); } invoke: chat.server.sendmessage(userid, input); for sendannounce(string name) hub method: chat.client.addmessage = function (frm) { $announcement.append("<div>test</div>"); } invoke: var userid = $("#txtuser

php - How to make object available throughout symfony2 app without repeating the query? -

how can share object across views in symfony? i implemented class serializable in entity, store object in sessions. however, since entity contains abstract methods need implement serializable method in class, believe last resort. until then, i'd find alternative solution other storing object in temporary table in database (it same not doing because need call database in every controller displays view) this scenario: i have 2 files: layout.html.twig , sidebar.html.twig i have method inside defaultcontroller called buildsidebar() looks follows public function buildsidebar($userid = 0) { $projects = $this->getdoctrine()->getrepository('superbundle:projects')->findby(array('userid' => $userid), array('crateddate' => desc), 10); return $this->render( 'superbundle:sidebar.html.twig', array('projects' => $projects) ); } then in layout.html.twig file have following block o

c# - How can I intercept the click on add Attachement button in Outlook 2010 -

i need build visual studion addin intercept click on standard button "add attachement" in outlook 2010. give me tips achieve ? check out mailitem.beforeattachmentadd event here link: http://msdn.microsoft.com/en-us/library/office/ff869219(v=office.14).aspx the link provides several events can hook related attachments.

java - Two string's which (I think) are identical do not return true when checking if the same -

this question has answer here: how compare strings in java? 23 answers i have 2 strings, 1 inputted user , 1 name of thread. inputted name should same thread. verify have program output system.out.println("ds:" + deamonmain.threadnamefinal + "cn:" +getname()); which prints ds:thread-66cn:thread-66 now these appear same string. however, when have test validity of using boolean factchecker = deamonmain.threadnamefinal == getname(); system.out.println(factchecker); it prints false... why this? have getname()? how string different , why so? you need use string.equals compare string equality, not == sign. as in: boolean factchecker = deamonmain.threadnamefinal.equals(getname()); the == operator checks reference equality, while equals method checks equality of string values. see here older thread on matter.

php - Storing the login time in a mysql database -

i'm trying store login time in mysql database. want is..that when user logs in..the script should store current time in table "user" having column "last_seen". last_seen of datetime datatype. here's code i've written(it's little part of login script..it works after user has enter username , password, , matched in database. :- $_session['username']=$username; $_session['logged']=1; $date = date('y-m-d h:i:s'); $query = "insert user (last_seen) values ('" . $date . "') user_name = '" . $username . "'"; mysql_query($query, $db) or die (mysql_error($db)); header('refresh: 5; url = main.php'); echo "login successful, redirecting..."; die(); this throws me error :- have error in sql syntax; check manual corresponds mysql server version right syntax use near 'where user_name = 'test'' @ line 5 (t

django - Latin1/UTF-8 Encoding Problems in AngularJS -

i have python 2.7 django + angularjs app. there's input field feeds data model , data sent server using angular's $http. when input field contains character "é", django doesn't it. when use "★é" django has no problem it. seems me star character being outside latin1 charset forces encoding utf-8, while when non-latin character "é", angular sends data latin1, confuses python code. the error message django is: unicodedecodeerror: 'utf8' codec can't decode byte 0xe9 in position 0: invalid continuation byte telling simplejson.loads() function on server read data using iso-8859-1 (latin1) encoding worked fine when input string contained é in , no star, proves data coming browser latin1 unless forced utf-8 non-latin1 characters, star. is there way tell angular send data using utf-8? the angular code sends data server: $http({ url: $scope.dataurl, method: 'post', data: json.stringify({recipe: recipe}),

ruby on rails - How do I split the value returned by created_at? -

i trying split value returned created_at method. i taking object ( item ) , getting time created at. don't want whole result , interested in day, month , year. how can work? <% @items_in_basket.each |item| %> <% splliter = item.created_at.split(" ") %> <% time = @splliter[0] %> i result: undefined method 'split' wed, 31 jul 2013 16:44:37 utc +00:00:time created_at returns instance of activesupport::timewithzone can call day , month , or year on parts of date. example: <% @items_in_basket.each |item| %> day: <%= item.created_at.day %> month: <%= item.created_at.month %> year: <%= item.created_at.year %> <% end %> this approach more reliable parsing string format returned to_s .

Jquery - How can I dynamically add a clickable element after redraw -

i have seen other posts on topic change elements on redraw. have list of items, want click on 1 , delete via ajax , redraw same list , have clickable. click after redraw isn't working. following code redraws list fine, once. 'listto' items no longer clickable. thought 'on' supposed handle this. how can make work? $('.listto').on('click',function() { var tmp = $(this).attr('id').substr(1).split("|"); $.ajax({url: '/contact/removefromlist/'+tmp[0]+'/'+tmp[1], success: function(data) { redrawtolist(data,tmp[1]) } }); }); function redrawtolist(data,item) { var dat = json.parse(data); var str = ""; $.each(dat, function(index, rel) { str += '<div id="t'+index+'|'+item+'" class="listto">'+rel+'</div>'; }); $('#tolist').html(str); } change handler : $('#to

javascript - Making a single-page blog work with search engines -

i trying create blog full posts on single page. ideally, static html page. the big problem linking these posts, search engines. not want create separate pages each post. on 1 page, can use url hashes /index.html#post-title link specific posts, right? however, seems search engines ignore these hashes , therefore can't link or index specific posts. sucks blog. so, ideas on how solve that? thought making separate pages each post while making same page - prefer cleaner way. this set create problem seo. there 1 page indexed. when user looking post 546 have lot of scrolling. you have hard time ranking single page bunch of words in comparison ranking each post topic. thus, favourite solution problem have each post on own url, , put content on main page via ajax! this give same experience if on 1 page, deliver different landing pages google.

How to generate random data in SQL server -

i want create stored procedure insert random data in 'video' table. have generated 30,000 record data userprofile table. note: username fk element in video table. create table userprofile ( username varchar(45) not null , userpassword varchar(45) not null , email varchar(45) not null , fname varchar(45) not null , lname varchar(45) not null , birthdate date , genger varchar(10) not null , zipcode int , image varchar(50) , primary key(username) ); go create table video ( videoid int not null default 1000 , username varchar(45) not null , videoname varchar(160) not null , uploadtime date , totalviews int , thumbnail varchar(100) , primary key(videoid), foreign key(username) references userprofile(username) ); go it's not difficult generate random data, in sql for example, random username userprofile table. begin -- random row table declare @username varchar(50) select @user

jquery - Error in displaying hidden div tag -

i have created web application , in index page there's search button. when user click on search button want display message using jquery fadeout effect. when refresh or reload index page hidden div tag displaying , after display index page. how can prevent this. here code , please me solve this? <!-- starting unavelable page--> <div id="hidden_div" class="hidden_div"> <div class="inner_div"><h2> these services coming soon!</h2></div> </div> <!-- end--> <script type="text/javascript"> $(document).ready(function(){ // when page loads #content_1 fades in on 4 seconds $('#hidden_div').hide(); // clicking show button fades in content_2 hides content_1 $('#search_botton').click(function(){ $('#hidden_div').fadein(1000); }); $('#hidden_div').click(function(){ $('#hidden_div').fadeout(1000); }); // end document ready }); </script>

go - Golang: Best way to read from a hashmap w/ mutex -

this continuation here: golang: shared communication in async http server assuming have hashmap w/ locking: //create async hashmap inter request communication type state struct { *sync.mutex // inherits locking methods asyncresponses map[string]string // map ids values } var state = &state{&sync.mutex{}, map[string]string{}} functions write place lock. question is, best / fastest way have function check value without blocking writes hashmap? i'd know instant value present on it. myval = state.asyncresponses[myid] reading shared map without blocking writers definition of data race. actually, semantically data race even when writers blocked during read ! because finish reading value , unblock writers - value may not exists in map anymore. anyway, it's not proper syncing bottleneck in many programs. non-blocking lock af {rw,}mutex in order of < 20 nsecs on middle powered cpus. suggest postpone optimization not after making program correct,

caching - mondrian dimension cache not getting flushed -

i trying flush mondrian dimension cache following code - org.olap4j.metadata.schema olapschema = olapconnection.getolapschema(); namedlist<org.olap4j.metadata.cube> cubelist = olapschema.getcubes(); org.olap4j.metadata.member m = null; for(org.olap4j.metadata.cube cube: cubelist) { m = cube.lookupmember(identifiernode.parseidentifier( "[time].[2013].[jul2013]").getsegmentlist()); final cachecontrol cachecontrol = olapconnection.getcachecontrol(null); cachecontrol.memberset regiontime = cachecontrol.creatememberset(mondrian.olap.member)m, false); cachecontrol.flush(regiontime); } but code throwing runtime error "mondrianolap4jmember , mondrian.olap.member incompatible" looks need following flush cache - unwrap member object returned lookupmember function using olap wrapper class - m = cube.lookupmember(identifiernode.parseidentifier( "[time].[2013].[jul2013]").getsegmentlist());

Joomla toolbar for save, publish etc not appearing in admin -

i have installed joomla 3.1.4 on local pc. seems fine , installed successfully. when go admin through firefox not show admin toolbar in backend after making changes cannot save, publish etc. when go site through chrome seems work , toolbar appears. cannot workout stopping firefox displaying toolbar. had installed site number of times firefox seems remember previous usage. i've noticed strangeness latest release, also. may admin template bug. try scrolling page when you're ready save. update: checked 2 of j3! sites, , seem ok. maybe cache issue?

facebook - Invisible characters - ASCII -

are there invisible characters? have checked google invisible characters , ended many answers i'm not sure those. can on stack overflow tell me more this? also have checked profile on facebook , found user didn't have name profile? how can possible? database issue? hacking or something? when searched on internet, found 200d ascii value invisible character. true? how character represented renderer, server may strip out characters before sending document. you can have untitled youtube videos https://www.youtube.com/watch?v=dmbvw8upbra using unicode character zero width non-joiner (u+200c) , or &zwnj; in html. code block below should contain character: ‌‌

c# - Is there a simple way to a list of input event handler hooks subscribed to setwindowshookex? -

wasn't useful method mentioned at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx beyond c# simple, wondering if there any way list of subscribed event handlers. after few more searches question, looks hans p.'s comment describes it

android - Setting up a Mac as a wifi hotspot to run mobile broadband test cases -

i need set environment can simulate mobile network internet connectivity ios , android devices don't have mobile data plans. thinking use mac set wifi hotspot , use ipfw throttle data connection simulate 3g network. i've managed mac set through "internet sharing" settings in system preferences. can connect both iphone 4 , samsung galaxy s3 fine , pull web pages no problem. however, i'm having trouble ipfw side of it. put linux script set pipes, when run program smartphones can no longer connect internet. think might routing issue, i'm not sure i'm missing. here's script looks like: ipfw del pipe 1 ipfw del pipe 2 ipfw -q -f flush ipfw -q -f pipe flush bw_down=780 [ ! -z $1 ] && bw_down=$1 bw_up=330 [ ! -z $2 ] && bw_up=$2 if [ "$1" == "off" ]; echo "disabling bw limit" exit else echo "download = ${bw_down}kbyte/s, upload = ${bw_up}kbyte/s" ipfw add p

javascript - AngularJS - Need some combination of $routeChangeStart and $locationChangeStart -

my problem similar 1 found here: angularjs - cancel route change event in short, i'm using $routechangestart , trying change current route using $location. when do, console shows me original page still loads , overwritten new page. the solution provided use $locationchangestart instead of $routechangestart, should work preventing redirect. unfortunately, i'm using additional data in $routeprovider need access while changing route (i use track page restrictions). here's example... $routeprovider. when('/login', { controller: 'loginctrl', templateurl: '/app/partial/login.html', access: false}). when('/home', { controller: 'homectrl', templateurl: '/app/partial/home.html', access: true}). otherwise({ redirectto: '/login' }); $rootscope.$on('$routechangestart', function(event, next, current) { if(next.access){ //do stuff } else{ $location.path("/login"

linux - OSError: [Errno 12] Cannot allocate memory from python subprocess.call -

i've read several similar posts on issue none seem me directly. if duplicate post, please direct me thread containing solution! i'm saving bunch of images , calling ffmpeg on them subprocess.call. number of times collections of different images. i'm doing: from subprocess import call video in videos: call(['ffmpeg', ..., '-i', video, video+'.mp4')]) in isolation works fine. however, when have other processing done before these calls (not within loop, literally holding values in memory before loop starts), crashes memory error after having made several of videos (actually while making last one). according this comment , subprocess.call forks/clones current process, seems mean requests memory allocation equal how have in memory, seems way overkill want in calling ffmpeg. how can call ffmpeg within python without asking allocate unnecessary amounts of memory? while true subprocess.call fork process, , child process have own memory

javascript - smoothdivscroll - only scroll on click -

i using smootdivscroll displaying products on website. products load large div scrolls left , right using smootdivscroll script. have setup arrows on left , right scroll when hovered or clicked. i want disable mouseover scrolling , allow scrolling when arrows clicked. actual page smoothdiv scroll demo page regards. i don't think has feature built-in. make use of public method : http://www.smoothdivscroll.com/publicmethods.html#move disable hotspotscrolling in options , bind click event listeners arrows trigger move() method.

c++ - Does an lvalue argument prefer an lvalue reference parameter over a universal reference? -

while playing universal references, came across instance clang , gcc disagree on overload resolution. #include <iostream> struct foo {}; template<typename t> void bar(t&) { std::cout << "void bar(t&)\n"; } template<typename t> void bar(t&&) { std::cout << "void bar(t&&)\n"; } int main() { foo f; bar(f); // ambiguous on gcc, ok on clang } gcc reports call above ambiguous. however, clang selects t& overload , compiles successfully. which compiler wrong, , why? edit: tested same code on vs2013 preview, , agrees clang; except intellisense, on gcc's side :-) the "universal reference" deduces parameter foo& . first template deduces parameter foo& . c++ has partial ordering rule function templates makes t& more specialized t&& . hence first template must chosen in example code.

vb.net - Accessing RadListBox Items in Code-Behind -

i have following radlistbox: <telerik:radlistbox id="attachmentsradlistbox" checkboxes ="true" runat="server" /> it located in radwindow, therefore populating through following code called when radwidnow becomes visible: attachmentsradlistbox.datasource = attachdt attachmentsradlistbox.datatextfield = "documentpath" attachmentsradlistbox.datavaluefield = "documentid" attachmentsradlistbox.databind() each item radlistboxitem in attachmentsradlistbox.items item.checked = true next so far good, radlistbox populated , items checked. now, there save button on radwindow when pressed before closing window trying read checked items in attachmentsradlistbox (since user might have changed status of checked items). every effort on reading items has failed, example on save button click have following: dim test integer = attachmentsradlistbox.items.count // 0 each item radlistboxitem in attachmentsradlistbox.items //

android - Is that possible to show a context menu clicking the listview without longpress -

i searched many stackoverflow reference didn't find no 1 related question.is possible show context menu clicking listview items without longpress single click. you can try alert dialog type. should efficient this.

Apache Kafka Consumer group and Simple Consumer -

i new kafka, i've understood sofar regarding consumer there 2 types of implementation. 1) the high level consumer/consumer group 2) simple consumer the important part high level abstraction used when kafka doesn't care handling offset while simple consumer provides better control on offset management. confuse me if want run consumer in multithreaded environment , want have control on offset.if use consumer group mean must read last offset stored in zookeeper? option have. for part, high-level consumer api not let control offset directly. when consumer group first created, can tell whether start oldest or newest message kafka has stored using auto.offset.reset property. you can control when high-level consumer commits new offsets zookeeper setting auto.commit.enable false. since high-level consumer stores offsets in zookeeper, app access zookeeper directly , manipulate offsets - outside of high-level consumer api. your question little confusing can use

hibernate - Detached object reattached with cascade=CascadeType.MERGE + @Version = Staleobjectexception -

i have understood marking method cascade=cascadetype.merge lead detached entities reattached may involve roundtrip database public class pollvote{ @manytoone(cascade=cascadetype.merge,fetch=fetchtype.lazy,optional=true) @joincolumn(name="fk_userid",nullable=true,updatable=false) public user getuser() { return user; } in case, user class has @version property public class user{ @column @version @jsonignore public date getlastupdate() { return lastupdate; } however, in instances, i'm getting staleobjectstateexception. realize must occurring because user object i'm passing take session , may therefore stale. in case largely irrelevant because needed id of user object save pollvote. my first question is: on cascade=cascadetype.merge: if pass in stale object @version attribute, shouldn't hibernate refresh object database in stead of throw staleobjectstateexception? my second question is: why staleobjectstateexception thrown when needed id, immut

c++ - Construct container with initializer list of iterators -

it's possible construct vector iterator range, this: std::vector<std::string> vec(std::istream_iterator<std::string>{std::cin}, std::istream_iterator<std::string>{}); but can compile , run code using c++11 uniform initialization syntax (note bracers), this: std::vector<std::string> vec{std::istream_iterator<std::string>{std::cin}, std::istream_iterator<std::string>{}}; what's going on here? i know constructor taking initializer list gets priority on other forms of construction . shouldn't compiler resolve constructor taking initializer list containing 2 elements of std::istream_iterator ? should error std::istream_iterator can't converted vectors value type std::string , right? from §13.3.2/1 ([over.match.list]) when objects of non-aggregate class type t list-initialized (8.5.4), overload resolution selects constructor in 2 phases: — initia

displaying php mysql query result with one to many relationship -

heres sample table: info table info_id name 1 john 2 peter ------------------------ details table details_id log date 1 test log john 2013-08-01 1 log john 2013-08-02 2 test log peter 2013-08-02 here's sample query: select info.info_id, info.name, details.details_no, details.log, details.date info join details on details.details_id = info.info_id group info.info_id and here's display want achieve: john 1 test log john 2013-08-01 1 test log john 2013-08-02 peter 2 test log peter 213-08-02 i have tried using foreach loop , execute foreach loop inside first loop. please guys you going have take data , make array want. $data = array(); foreach ($result $item) { $key = $item['name']; // or $item['info_id'] if (!isset($data[$k

c# - Visual Studio 2010 suddenly can't see namespace? -

my c# winforms solution has 2 projects. dll main project i'm working on, , executable winforms call "sandbox" can compile/run/debug dll in 1 go. i'm working in .net 4.0 both projects. everything working fine until added seemingly innocent code, , reference system.web in dll. sandbox project can't see namespace of dll project. didn't change believe should have affected this. if delete project reference dll sandbox references , re-add it, red underlines disappear , colour coding comes classes etc; as try build solution, whole thing falls apart again. when right-click dll project in sandbox's references , view in object browser, can see namespace , stuff in there. i have feeling might sort of bug? is sort of vs2010 bug? had same issue few months ago , fix @ time making whole new project , re-importing files. time, however, have bajillion files , last resort! edit: after panickedly going through , undoing changes, trying find caused problems,

javascript - Wookmark script making my Tumblr theme also scroll to the left -

i started using wookmark script , it's making tumblr theme overflow scrolling left when should scroll vertically. have now. http://lt-neon.tumblr.com/ and code on site. http://pastebin.com/aztpxx8c is there anyway can solve way tumblr theme scrolls vertically instead of horizontally? just clarify, issue isn't related wookmark. there 2 elements on page pushing page width , creating scroll. the first div#search . remove left: 770px replace float: right . the second #content . again if remove left: 150px scroll disappears. i not 100% sure why using left: position elements, may helpful: http://alistapart.com/article/css-positioning-101

javascript - Avoiding need to call _.bindAll in backbone -

from reading appears when extending backbone.js class such model, common pattern call _.bindall in constructor follows (see https://raw.github.com/eschwartz/backbone.googlemaps/master/lib/backbone.googlemaps.js ): googlemaps.location = backbone.model.extend({ constructor: function() { _.bindall(this, 'select', 'deselect', 'toggleselect', 'getlatlng', 'getlatlng'); // etcetera i understand why gets done, need explicitly passing method names _.bindall seems maintenance issue -- if add new methods, have remember add them argument _.bindall well. earlier today posted verbose solution here: https://stackoverflow.com/a/17977852/34806 however, shouldn't following simple technique altogether avoid need call _.bindall? , is, instead of customary way of assigning "custom" methods, instead attach them "this" within constructor: constructor: function() { this.foo = function() {}; this.bar = function()

ios - Error calling action for button in Objective C -

i creating app in objective c, , receiving runtime error when press button in app. code creates buttons. yes have use coded version, before asks. extend = [uibutton buttonwithtype:uibuttontyperoundedrect]; //3 [extend setframe:cgrectmake(100, 50, 75, 50 )]; [extend settitle:@"extend" forstate:uicontrolstatenormal]; [extend addtarget:self action:@selector(extendpressed:) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:extend]; [self.view bringsubviewtofront:extend]; retract = [uibutton buttonwithtype:uibuttontyperoundedrect]; //3 [retract setframe:cgrectmake(100, 110, 75, 50 )]; [retract settitle:@"retract" forstate:uicontrolstatenormal]; [extend addtarget:self action:@selector(retractpressed:) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:retract]; [self.view bringsubviewtofront:retract]; and here actions. - (ibaction)extendpressed:(uibutton *)sender{ nslog(@"extend"); } - (ibaction)retractpress

jquery - Just refresh the div after login or logout -

i working on web project. in layout page, have div login/logout <div id="login"> @if (websecurity.isauthenticated) { //// show id , logout option } else { <form method="post"> //// input boxes id , pass <input type="submit" value="log in" id="submit"/> </form> } </div> so, after user login, want refresh div without reload whole page, , div show id , logout option. i searched online, , people use .reload ajax. in cases, there new stuff put in .load(), , case want refresh div without new stuff. can use .load() without put in () div refreshed? thanks! zeyu

ios - How to draw a non-rectangle UILabel with paragraph truncation at the end? -

Image
i need show body of text similar 1 shown below , limited red non-rectangular area. rob's answer this question pretty answers question well, need truncate @ tail of paragraph when text long. extra question: possible set minimum font size similar uilabel? try using nsstring::sizewithfont:constrainedtosize method documented here . can specify fontsize , maximum size text. you can calculate minimum font size using nsstring::sizewithfont:minfontsize:actualfontsize:forwidth:linebreakmode: method.

android - Tabs over menu instead of menu over tabs -

Image
i've got little problem program. i'd set menu on tabs. i'm using abs library tabs menu. here's example how looks atm: any ideas? ask me code fragments if need solve problem.

Centering an element inside of a DIV using HTML/CSS -

i working on periodic table, , although got mass , number placed want them to, element symbol won't budge. tried everything: converting <p> <span> <div> , using display: block , setting margin: 0 auto , using text-align: center , still won't budge. here's html: <div id = "a1" class="element alkalimetal"> <p> <span id = "anumber">118</span> <span id = "amass">9.008</span> </p> <br> <div id = "symbol">h</div> </div> <div id = "a2" class = "element noblegas"> </div> here's css: #anumber{ font-family:arvo; top: 0.1em; position:relative; vertical-align:super; font-size:1.5em; float:left; padding-left:0.2em; } #symbol{ width: 5em; font-family: avenirc