Posts

Showing posts from April, 2012

Ability to toggle all animations/transitions/fades in jQuery? -

i have application uses jquery transition/fade/animate elements within ui (ie panel slide out side when toggled visible). give user option toggle of 'effects' via checkbox, depending on how set workflow of application. so instead of hidden state > effect/transition > visible state hidden state > visible state based on whether transitions enabled (most via checkbox). is possible without rewriting of hidden/visible states based on checkbox? there form of select-all remove effect? you can globally turn off jquery animations changing value of: jquery.fx.off as in: // disable jquery animations jump end state jquery.fx.off = true; jquery doc here .

ruby - Rails blog using Mongoid - Auto generate Short URL on post creation -

i have simple blog engine using rails , mongoid orm. i have 2 models in blog, 'article' , 'url'. article model contains of post content, , url class generator function takes slug of article , creates short url it. e.g. my-sample-blog-post -> ai3n etc. etc. the problem having problems linking two. can't embed url class in article class either. my question is, can generate short url on fly, post created, inside article model? article model uses mongoid::slug give me nice post slugs, need short urls each post. any on appreciated. i think use after create callback generate short url , store in field inside article model. something this: class article field :title slug :title field :short_url after_create :generate_short_url def generate_short_url self.short_url = shorten_it(self.slug) # assuming implement shorten_it self.save end end

c++ - CreateProcess handling -

i use windows api createprocess function. in msdn manual it, have found if function succeeds, sure call closehandle function close hprocess , hthread handles when finished them. otherwise, when child process exits, system cannot clean process structures child process because parent process still has open handles child process. so should this? the situation process started , there no track of life. force me make thread, process created , thread wait using, example waitforsingleobject , until process dead, handles released? you don't have wait child process finish, have closehandle when you no longer need handle. the reason may want keep handle process after process has finished. may want check return status, example. long have handle it, windows can't clean after it. but if don't care anymore child does, close handle , move on. if care, call waitforsingleobject , give handle got createprocess . or call registerwaitforsingleobject (again p...

string - Get time that program ran (Python) -

im writing python script , im going make last updated: , time lst updated im not sure how here , example code from pil import imagedraw import ctypes, time import urllib import manipulate import datetime font_size = 50 font_color = "red" font = imagefont.load_default() img = image.open('bg.bmp') draw = imagedraw.draw(img) time = datetime.datetime.now() draw.text((650, 450),' current grades' ) draw.text((650, 500), 'period 1: geography -----------------------------') draw.text((650, 550), 'period 2: francais-------------------------------') draw.text((650, 600), 'period 3: science--------------------------------') draw.text((650, 650), 'period 4: p.e------------------------------------') draw.text((650, 700), 'period 5: algebra 9------------------------------') draw.text((650, 750), 'period 6: la-------------------------------------') draw.text((650, 800), 'last updated:...

java - arraylists of longitude and latitude pass them in php and insert them to mysql,how? -

i have 2 arraylists (longitude elements , latitude elements) want pass them in php script , in mysql(wamp). for (int = 0; < latitude_mysql.size(); i++) { namevaluepairs.add(new basicnamevaluepair("latitude_mysql",latitude_mysql.get(i))); namevaluepairs.add(new basicnamevaluepair("longitude_mysql",longitude_mysql.get(i))); }//by way send them in php script,but m not sure if appropriate in php writing don t know how continue: if ($stmt = $mysqli->prepare("insert route(latitude,longitude,trek_id_r) values (?, ? , ? )")) { /* set our params */ $lati[] = $_post['latitude_mysql[]']; $longi[] = $_post['longitude_mysql[]']; and then??? i need latitude , longitude inserted respectively, i.e: if values are: longitude_mysql: 30.24 , 50.24 latitude_mysql: 23.43 , 24.56 trek_id_r= 2 in mysql in table route need result: longitude | latitude | trek_id_r 30,24 | 23,43 | 2 50,24 | 24,5...

c - Why is the address operator (&) important for an array being passed through a function? -

i having trouble understanding how & operator works , importance. i found example online: #include <stdio.h> void main() { int = 10; printf("\nvalue of n : %d" ,n); printf("\nvalue of &n : %u", &n); } output : value of n : 10 value of &n : 1002 firstly, why &n print out 2 numbers? secondly, why important? n variable. represents value. &n reference n. represents address in memory n store. as why important: when pass array in c, function expecting pointer. (ie: int* opposed int). if pass 'n' function, complain when compiling because types don't match (n=int, function expects int*). if pass in &n, passing in address 'n' function expects.

Javascript Date "Invalid Date" in IE when copying very old dates -

code: var x = new date(date.utc(0, 0, 0)); x.setutcfullyear(0); // in firefox, writes "date {sat dec 30 0000 16:00:00 gmt-0800 (pacific standard time)}" // in ie, writes "log: sat dec 30 16:00:00 pst 1 b.c." console.log(x); // create copy of x var y = new date(x); // in firefox, writes "date {sat dec 30 0000 16:00:00 gmt-0800 (pacific standard time)}" // in ie, writes "log: invalid date" console.log(y); this seems happen old dates my question(s) : invalid here, , why ie? how can move past problem , create copy of date? it seems when date object passed date constructor in ie, it's evaluated other time value (probably calls tostring ). to force evaluate time value, can do: new date(x.gettime()); or new date(+x); or expression makes date return time value rather string. when single value passed date constructor , it's converted primitive. specification doesn't whether should converted string or number...

c# - ASP.NET equivalent of JSP include -

in jsp can share html code using include: <jsp:include page="subsection.jsp" > for life of me, can't tell how in asp.net should including shared html. use template control, isn't same thing. use site master page , content placeholders, not same , requires different approach developing pages. am out of luck or there function in asp.net similar jsp's include? you have enable server can use include html files. <!-- #include file="static/menu.html" --> instructions enable ssi in iis7 available @ http://tech.mikeal.com/ for dynamic content, there built-in method of templating called masterpages, should used instead.

ruby on rails - Why is ActiveRecord/PostgreSQL not finding my data in the database? -

Image
i'm sure simple i'm overlooking since i've been dealing strange issue few days i'm asking help. here apps setup , issue: a rails 3.2.13 app pg gem , following db scheme: create_table "clients", :force => true |t| t.string "uuid" t.string "private_key" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end add_index "clients", ["private_key"], :name => "index_clients_on_private_key" add_index "clients", ["uuid"], :name => "index_clients_on_uuid" i have 2 rows in "clients" database. pictured below: the issue when perform simple "select * clients;" using rubymine database console rows pictured in screen shot above. when perform "select * clients id = 11;" row, there. however, issue when try perform "select * clients private_key = "mkrbnuzbqzutmzvdri0...

python - Add dictionary values where keys match -

i have list of dictionaries following: a=[{'a':1},{'b':2},{'c':3},{'a':-2},{'b':4}] i need loop through list , add values keys match. result should this: a=[{'a':-1},{'b':6},{'c':3}] help doing appreciated. i able implement like a = [{'a':1},{'b':2},{'c':3},{'a':-2},{'b':4}] b = {} x in a: k,v = x.popitem() # check if key in our output dict if k in b.keys(): b[k] += v # if not, create else: b[k] = v which outputs b = {'a': -1, 'b': 6, 'c': 3}

c# - How to return subscribers from one user from youtube api? -

i'm having hard time trying find in poor official documentation , in community any directions? it seems isn't possible before version 3.0 experimental api. if you're using v3 api, can channels list , set mysubscribers filter true . set properties want retrieve in part parameter (such contentdetails includes information such subscriber's google+ id). filter authorized need have permission the user call method.

ruby on rails - Associating a new object with an existing object with has_many through -

i have 2 classes users , projects. user can own many projects , project can owned many users. however, project must have @ least 1 user while user not necessary have have project. this have: class project < activerecord::base attr_accessible :prj_id, :name has_many :ownerships, foreign_key: "project_id", dependent: :destroy has_many :users, through: :ownerships end class user < activerecord::base attr_accessible :first_name, :last_name, :email, :password, :password_confirmation has_many :ownerships, foreign_key: "user_id", dependent: :destroy has_many :projects, through: :ownerships validates :first_name, presence: true, length: { maximum: 25 } validates :last_name, presence: true, length: { maximum: 25 } valid_email_regex = /\a[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, format: { with: valid_email_regex }, uniqueness: { case_sensitive: false } validates :password, presence: ...

(Python) Parsing tab delimited strings with newline characters -

i trying read file tab delimited fields may contain newline characters , maintain field has newlines. current implementation creates new fields each "\n". i have tried csv module , splitting on "\t" no success on i'm looking for. following sample line given file: *field_1 \t field_2 \t field_3 \n additional text \n more text \t field_4* i generate list of 4 elements data above. *["field_1", "field_2", "field3 \n additional text \n more text", "field_4"]* any thoughts or suggestions helpful. did try splitting on tab this? data = 'field_1 \t field_2 \t field_3 \n additional text \n more text \t field_4' print data.split('\t')

javascript - Working with a timer and progress bar in JS -

i trying create simple script user clicks button , progress bar fills 100% (i know exciting right?) so have snippet set timer: this.updatebar = setinterval(function () { that.update(); }, 50); the problem having writing method progress bar fills up. quite having logic errors i'm in deep can't see them. have incomplete doesn't me off ground start. progressbar.prototype.update = function () { if(this.bar.style.width == "0%") { this.bar.style.width = "20%"; } } thank you! inside progressbar constructor, add: this.progress = 0; then change update function to: progressbar.prototype.update = function () { this.progress++; this.bar.style.width = this.progress + "%"; }

Linear least squares in scipy - accuracy of QR factorization vs other methods -

i have tried solving linear least squares problem ax = b in scipy using following methods: x = numpy.linalg.inv(a.t.dot(a)).dot(a.t).dot(b) #usually not recommended and x = numpy.linalg.lstsq(a, b) both give identical results. tried manually using qr algorithm ie: qmat, rmat = la.qr(a) bpr = dot(qmat.t,b) n=len(bpr) x = np.zeros(n) in xrange(n-1, -1,-1): x[i] = bpr[i] j in xrange(i+1, n): x[i] -= rmat[i, j]*x[j] x[i] /= rmat[i,i] this method, however, gives inaccurate results (errors on order of 1e-2). have made n00b mistake code or maths? or, issue method, or scipy itself? my numpy version 1.6.1 (the mkl compiled version http://www.lfd.uci.edu/~gohlke/pythonlibs/ ), python 2.7.3 on x86_64. if using binaries, qr factorization computed intel mkl, , correct. for me above code gives solutions within 1e-12 of correct result, random matrices. matrixes did test with, , how measure error? there cases in least squares problem ill-conditioned...

c - Data type of command line args -

i'm struggling convert executable program function can call within main routine. written, executable looks this: int main(int argc, char* argv[]){ //do stuff if(setxattr(argv[4], tmpstr, argv[3], strlen(argv[3]), 0)){ perror("setxattr error"); exit(exit_failure); } //do more stuff } i can call follows , works successfully: ./set_attributes -s encrypted 1 ~/text.txt but want move function embedded in program. part failing strlen(argv[3]) . new function looks this: int set_encr_attr(char* fpath, int value) { char* userstr = null; /* check value set either 0 or 1 */ if (!( (value == 0) || (value == 1) )) { return -1; } //do stuff (including malloc(userstr) strcpy(userstr, xattr_user_prefix); /* set attribute */ if(setxattr(fpath, userstr, value, 1, 0)){ perror("setxattr error"); exit(exit_failure); } return exit_success; } as can see, i've r...

java - getComponentAt() not finding a component? -

i using jframe set game of solitaire, using cards extend jlabel can dragged around screen. however, 1 of requirements able double click card , snaps 4 stacks of aces. not problem. causing problems set in array, aces go spot corresponds suit of ace, have spots rearrange if card dragged there. if double clicked, aces must go first spot (from left) second, , on. had planned use getcomponentat() find out @ first spot , if place ace there, if not move on second , on. reason though, if hard code in parameters getcomponentat() spots know have component, still returning null. this relevant portion of code: container contentpane = getcontentpane(); contentpane.setlayout(null); ... for(int = 0; < 4; i++) { aces[i] = new card(); aces[i].setbounds((i * 75) + 475, 25, 75, 100); contentpane.add(aces[i]); aces[i].setborder(borderfactory.createlineborder(color.black, 3)); aces[i].setsuit(i + 1); } system.out.println(contentpane.getcomponentat(475, 25)); this retur...

desire2learn - Valence pagination of get requests -

i've got several questions pagination. can pagination forced? can pagination controlled (eg request pages of 200 records)? if answers 1 & 2 no, threshold when pagination happens? is pagination stable (same number of records on same entity either paginated or not paginated)? thanks, vlad pagination forced when gets used on particular api call: no matter how many records finds, call alway returns data in pages. cannot request pagination on calls not default paginate. call either paginates or not. you cannot request change size of data pages; number of records returned in each page in paged set fixed each call using pages (in theory page size can vary each such call, in practice, (currently) not). there no threshold: either data in call returned in paged result set, or not. if number of matching results less page size, call should still return single data page within paged result set structure, property set indicate no further data pages available. yes...

web api - WebAPI get not converting properly to model binding object -

i"m using webapi mvc4, doing http looks this: api_version=2&products=[{"id":97497,"name":"ipad"}]&pageno=1 the signature of action controller maps call is: [httpget] public string get([fromuri] productrequest request){ ... } the problem productrequest object passed action method above contains nulls products, while other values ok. so seems has trouble converting products=[{"id":97497,"name":"ipad"}] right object type, defined as: public ienumerable<products> products { get; set;} in productrequest model , products class looks like: public int id { get; set; } public string name { get; set; } as, additional information, when using same call post instead of get, works fine, object converted properly. so, doing wrong, how can http convert query parameters model passed in? i think confused between http post , http that's why did product null. have @ what's difference betw...

redirect - PHP: Login using external file -

i having issue using external login file. go external login php page , validate form. once form has been validated redirect previous page , start session. issue having session not start (i.e. not change login form log out button). code down below. in advance. index.php <? session_start(); include('phpfunctions/databaseconnect.php'); include('phpfunctions/reusablefunctions.php'); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <title>unnamed classifieds site</title> <script type="text/javascript" src="js/formvalidation.js"></script> </head> <body> <div class="wrappe...

python - Using Flask-OpenID in App Engine -

i trying out flask-openid in app engine. flask-openid uses 'store' save authentication information. if mention '/some/path' save data, doesn't work in app engine, read-only. for flask-openid work, have write own 'store' uses app engine's datastore or cloud storage. have not idea on how write store. there document available, can follow. helpful if input on writing 'store' using flask , app engine. disclaimer: not author of framework, using everyday. can start gae-init working example using flask-oauth authentication. login , other goodies provided out of box, , can overview , educate @ docs still under construction.

java - "cannot find symbol " error in oop pig game -

i doing oop pig game. in encounter error: " cannot find symbol class name" . can please me finding it. public class player { protected string name; scorekeeper sk; // sk = new scorekeeper(); public player(string name) { this.name = name; //scorekeeper sk = new scorekeeper(); sk = new scorekeeper(); } public player(){ } public int getscore() { return sk.getgametotal; } public string getname() { return name; } public int incscore(int rollvalue) { sk.addtoroundtotal(rollvalue); return sk.getroundtotal; } public int setscore() { return sk.resetroundtable(); } } this class create object class scorekeeper , other class is public class scorekeeper { int gametotal = 0; int roundtotal = 0; public scorekeeper() { //gametotal = 0; //roundtotal = 0; } public void addtogametotal() { ...

extjs4 - ExtJs from submit with fileupload filed on Different domain -

i have form submit method on i'm submitting form different domain. form includes fileupload field . due fileupload field i'm not able take response third party domain. have checked on localhost works on different domain gives error resource interpreted document transferred mime type application/json: "url". and unsafe javascript attempt access frame url "url-1" frame url "url-2". domains, protocols , ports must match. thanks in advance.

map - How to sort result from foursquare place api according to distance? -

i fetching nearby restaurants foursquare api, getting json contains details of restaurants.it has "distance=xx" .how can result least distance on first index of array ? i found - "intent=match" .but dont know how give in below url please me.thanks in advance https://api.foursquare.com/v2/venues/search?radius=500&ll=10.00915,76.318738&limit=50&client_id=client_id&v=yyyymmdd&client_secret=client_secret&categoryid=4d4b7105d754a06374d81259 intent=match sensitive location , query pass in, , it's used find exact matches of you're looking (e.g., joe's coffeeshop right at precise lat/lon). may or may not you're looking for, use adding parameter api call, how added categoryid . in general, using intent=checkin (which call defaults to) should sufficient depending on exact requirements. returns results sorted distance takes account how check in there first result not strictly closest.

Calling the Javascript functions inside C# for a 64 bit project -

i trying call javascript function "eval" inside c# code (to utilise string operators parser). used following code: https://stackoverflow.com/a/12431435/712700 it crashes though following message--- : exception details: system.runtime.interopservices.comexception: retrieving com class factory component clsid {0e59f1d5-1fbe-11d0-8ff2-00a0d10038bc} failed due following error: 80040154 class not registered (exception hresult: 0x80040154 (regdb_e_classnotreg)). i believe problem because project/machine 64 bit. not want change project 32 bit, there clsid can use make work 64 bit? or there approach utilise "eval" function javascript within c# code? you referring following code type scripttype = type.gettypefromclsid(guid.parse("0e59f1d5-1fbe-11d0-8ff2-00a0d10038bc")); dynamic obj = activator.createinstance(scripttype, false); obj.language = "javascript"; var res = obj.eval("a=3; 2*a+32-math.sin(6)"); the abo...

c# - ANTLR3 Reduce memory usage -

i have written parser in antlr3. targets both java , csharp3. both using lot of memory @ parse time. files parsing have size between 5 , 40 mb. memory usage far beyond that, iirc correctly .net memory profiler showed peak of on 600mb. grammar file has 500 lines. need output generated injected code in grammar. not need lexer tokens in memory or ast. is there can do? antlr4 address memory usage issues?

javascript - Rowunselect without ctrl+click -

is there possibility unselect row without hold control key,only clickin on it? mean, if click on selected row, should unselect, without having hold control key. i have tested primefaces 3.4.2: xhtml page: <script type="text/javascript"> function test(xhr, status, args){ if(args.unselecttest % 2 == 1){ stest.unselectallrows(); } } </script> <p:datatable widgetvar="stest" selectionmode="single" selection="#{tabview.car}" <p:ajax event="rowselect" oncomplete="test(xhr, status, args);" /> bean: private int count = 0; public car getcar() { return car; } public void setcar(car car) { if (car.equals(this.car)) { count++; requestcontext reqctx = requestcontext.getcurrentinstance(); reqctx.addcallbackparam("unselecttest...

Experience with using google closure library in AIR? -

i try closure library in air application. using objects goog.editor, goog.events , goog.dom. in older book i'm reading google closure says it's using eval in functions. haven't tried using uncompiled code in air yet suspect not work because eval isn't allowed in privileged code. plan compile code used in air application. the application made of html page code using air specific things save , copy clipboard. not have actionscript or swf files. has tried using closure library in air applications? if there things out for? the closure library uses eval in it's json parser, jsondatasource, , moduleloader otherwise not (afaik) use eval in core libraries standard components. long avoid cases not expect issue, i'm not familiar how air restricts usage of that.

Strange CLR error while handling Nullable types in Oxygene .net -

i'm writing program in oxygene .net there seems problem how handling nullable types namespace ruler; interface uses system, system.drawing, system.collections, system.collections.generic, system.windows.forms, system.componentmodel; type /// <summary> /// summary description settings. /// </summary> settings = public partial class(system.windows.forms.form) private method settings_shown(sender: system.object; e: system.eventargs); method getlowerbound : system.nullable<double>; method setlowerbound(lowerbound:system.nullable<double>); method settings_load(sender: system.object; e: system.eventargs); method btnok_click(sender: system.object; e: system.eventargs); protected method dispose(adisposing: boolean); override; public property lowerbound : system.nullable<double> read getlowerbound write setlowerbound; constructor; end; implementation {$region construction ,...

.net - Add listbox items in form 1 from form 2 button pushed in c# -

i have form (form1) has listbox , button. on clicking button, opens form (form2). in form have texbox , button. on clicking button, whatever entered in textbox, should have go listbox in form1. please me find out solution. step 1 : set modifiers property of listbox public step 2 : in button click of form1, put form2 fm2 = new form2(this); fm2.showdialog(); step 3: in form2, put following declaration @ top level private form1 _fm1; add constructor : public form2(form1 fm1) { _fm1 = fm1; initializecomponent(); } step 4: in button click of form2 , put following lines: _fm1.listbox1.items.add(textbox1.text); this.close(); //close form2 hope helps.

ios - Factory class - stop init -

i want create factory class create objects me (of specific class). the factory class have class methods. there way can stop alloc init being called on class? yes can, define init @ interface as - (id) init __unavailable;

Javascript Error : $ is not a function -

i facing weird problem here : in firebug see error : $ not function _handleevent() in pro.js e = load var handlers = this.events[e.type], el = $(this); the full function defined follows : _handleevent : function(e) { var returnvalue = true; e = e || event._fixevent(window.event); var handlers = this.events[e.type], el = $(this); (var in handlers) { el.$$handleevent = handlers[i]; if (el.$$handleevent(e) === false) returnvalue = false; } return returnvalue; } can guys kindly me out here , figure out why error being thrown here. it's not related jquery, guess. note : gives error : $(this ) not function in ie i think you've either not loaded jquery correctly or executing code before inclusion of jquery. or might using jquery's noconflict -mode, http://api.jquery.com/jquery.noconflict/ , in case you'd need replace $() jquery() . also, make sure execute code either @ document load or, better, when jquery loaded: $(document).re...

asp.net - What happens to the ViewState when I click back on the browser? -

i'm curious know happens viewstate on browse button. does stay or page make new request? viewstate remains no more .net implementation once render html , become normal hidden field sitting in html of page. when browse button , in of time page cache of browser , there no request server. there no way viewstate update without refreshing page , because @ end of day viewstate nothing hidden field .

html - centering problems with bootstrap framework -

i'm noticing when attempt center image, right on page. causing that? seems there margin added left of image. <head> <meta charset="utf-8"> <title>test</title> <link rel="stylesheet" href="http://flip.hr/css/bootstrap.min.css"> </head> <body> <div class="container"> <img src="dovelow.jpg" alt="dove"> </div> </body> the margin-left: auto; on containter causing that. you should this: .container { width: inherit; text-align: center; background-color: pink; } img { width: 100px; height: 100px; } see http://jsfiddle.net/yuhjq/1/

php - AJAX call success but data not retrieved at server -

i have ajax call passes data php file, createtest2.php, below. but createtest2.php file throws error "notice: undefined index: aaa in c:\xampp\htdocs\testproj\test\createtest2.php on line 2 i have no clue how fix it. caller.php $(document).ready(function(){ $("#button_submit").click(function() { $.ajax({ type:"post", url:"createtest2.php", data:{aaa : "unit_test"}, success:function() { alert("success"); } }); }); }); createtest2.php $test_name = $_post['aaa']; if using $test_name = $_post['aaa']; have call ajax $(document).ready(function(){ $("#button_submit").click(function() { $.ajax({ type:"post", url:"createtest2.php", data:"aaa=unit_test", success:function() { alert("success"); } }); }); }); the main thin...

Postgresql pgAdmin COPY issue -

i have sql script creates table , populates copy stdin command. the issue facing here sql runs fine command line pgadmin gives me syntax error. here code. copy ui_geoip_city (id, country_code, region_code, city_name) stdin; 1 ad 07 andorra la vella 2 ad 05 anyѓs 3 ad 04 arinsal 4 ad 02 canillo 5 ad 03 encamp ..... the error error: syntax error @ or near "1" line 156: 1 ad 07 andorra la vella ^

sharepoint - Javascript: Extract part of URL, clean it, and use it within html embed code for a flash container -

sorry in advance, lots of answers on site relate parts of query, though failing connect dots. appreciated (happy buy virtual beers, etc) i'm looking take url, , extract part of string left of "&folderctid", , right of "rootfolder=", e.g: this: http://mysite.com/project1/forms/allitems.aspx?rootfolder=%2fproject1%2flesson%2014&folderctid=0x01200075c0e8ac5a64724787732a3200049d3a&view= {440f5454-054d-4c68-a1e2-4a52e4fd8fcb} becomes: %2fproject1%2flesson%2014 i looking replace "%2f" "/", , add trailing "/presentation.swf", leaving me file reference - "/project1/lesson%2014/presentation.swf" finally, i'd use file reference within embed code, e.g. src=&quot/project1/lesson%2014/presentation.swf&quot is possibe? this works me theurl='http://mysite.com/project1/forms/allitems.aspx?rootfolder=%2fproject1%2flesson%2014&folderctid=0x01200075c0e8ac5a64724787732a3200049d3a...

passing generic list from jquery to c# code-behind -

i have simple webmethod , filtering reports in code-behind :- [webmethod(enablesession = true)] public static list<report> fetchreports(string reportname) { list<report> fetchedreports = datamodel.populatelinks().where(r => r.name.tolower().contains(reportname.tolower())).tolist(); return fetchedreports; } now returned jquery function:- $("#reports-textsearch").keyup(function () { var textlength = $(this).val().length; if (textlength > 2) { var args = { reportname: document.getelementbyid('reports-textsearch').value }; $.ajax({ type: "post", contenttype: "application/json; charset=utf-8", url: "dashboard.aspx/fetchreports", data: json.stringify(args), datatype: "json", success: function(r) { ...

javascript - Adding a hyperlink dynamically in html using jquery -

for (i = 0; < crowcount / 5; i++) { link = $('<a/>').attr({ href : '#', id : $(this).attr('id') + (i + 1), class: 'mylink' }); $(this).append(link + "&nbsp;"); } when appending link component not giving me link. instead showing following thing without hyperlink. [object object] [object object] [object object] problem line $(this).append(link + "&nbsp;"); line converting object string, because appending object string you can html <div>abc </div> code append for (i = 0; < 10 / 5; i++) { link = $('<a/>').attr({ href : '#', id : $(this).attr('id') + (i + 1), class: 'mylink' }); link.html(i ); $("div").append(link ); $("div").html($("div").html() + "&nbsp;" ); } jsfiddle demo

git svn - how to revert changes only for one file with git-svn? -

i've corrupted 1 file , i'd revert back. project using git-svn. how can revert 1 particular file? or better if view whole change set of file. detailed steps appreciated. git revert sha1_of_faulty_commit add changes don't commit git cherry-pick -n sha1_of_faulty_commit modify needs modified, e.g. git reset head file_that_should_not_have_been_modified commit git commit -m "to_be_merged" squash 2 commits, put meaningful comment. git rebase -i head~2 review changes, should contains modification on single file you: git show you can push svn git svn dcommit

ruby - Is there a better way to do it? ( Mongoid + TaggableWithContext ) -

is few days i'm trying learn how use mongoid , found myself faced problem: there better way this? group.find_by(name: params[:group]).subgroups.tags.each |l| puts l puts group.find_by(params[:group]).subgroups.tags_tagged_with(l).to_a end i'm using mongoid in combo mongoid_taggable_with_context the idea find tags belonging group, , each of these items tag. expected result (example): tag1: subgroup2 subgroup3 tag2: subgroup1 subgroup2 etc. thanks patience

java ee - Specifying Constraints on a field representing a Date in an entity JPA -

i have set constraint on fields "heurefin" & "heuredebut" of entity intervention, wonder how precise constraint : heurefin>heuredebut ?? here entity : public class intervention implements serializable { private static final long serialversionuid = 1l; @id @size(min = 1, max = 50) @column(name = "idintervention", length = 50) private string idintervention; @basic(optional = false) @notnull @column(name = "heuredebut", nullable = false) @temporal(temporaltype.timestamp) private date heuredebut; @basic(optional = false) @notnull @column(name = "heurefin", nullable = false) @temporal(temporaltype.timestamp) private date heurefin; } is possible, or should process constraint somewhere else ? thank in advance :) it not possible @ member level. should use class level constraints , implementing own constraint validator (which takes instance parameter of isval...

c# - Publish a web service on Visual Studio 2010 -

i created web service in c#, using visual studio 2010 ( framework .net 3.5). in debug mode works great, must publish on internet, can consume in remote (the app consume web service android app). so question is: how publish web service on internet can consume in remote? thanks in advance; work taking degree! a simple way: switch release mode, update web.config production, right click on service project , menu select publish. publish local folder. way copies files needed. copy contents of folder remote site using ftp, example, hosting provider should have given credentials. for hosters possible publish directly don't use this.

cocos2d-javascript iphone mozilla/DebugOnly.h not found -

Image
i install cocos2d-javascript , run iphone , got error mozilla/debugonly.h not found on hashtable.h file my hashtable.h code is include "mozilla/attributes.h include "mozilla/debugonly.h have idea problem ?? have update cocos2d , try install again, still not work . here error message i getting same error. doesn't seem in issue list either... update: reported on issue queue: https://code.google.com/p/cocos2d-iphone/issues/detail?id=1487 edit: in forum too: http://www.cocos2d-iphone.org/forum/topic/31640/page/8 manual fix: so, after doing git pulling , submodule updating, found debugonly.h included in cocos2d, isn;t included in project. run this: cp ~/documents/repos/cocos2d-iphone/external/javascript/spidermonkey/ios/include/mozilla/debugonly.h [project]/libs/spidermonkey/ios/include/mozilla/

node.js - Storing mapreduce results -

i'm writing application node.js, express , mongo. on each page should show information, collect mapreduce. upd: more information :) don't understand, how should process data - store collection or what? have lot of pages, on every page have sidebar results of map reduce(kind of statistic). results aren't changing often, don't need recount on every page load. , want find true way task)

c# - Check Object Exists throws Object Required Error -

i have web form data entry. page requires id passed via query string. in code behind check id has been supplied. if hasn't form (in panel) hidden , error message displayed. in html have jquery script block attaches event (downloaded date picker). window.onload = function() { new jsdatepick({ usemode: 2, target: "txtdateofincident", dateformat: "%d %m %y" }); }; if code behind hides form jquery throws error object required so in jquery trying test existance of object as per post ... window.onload = function() { if ($('#txtdateofincident').length) { new jsdatepick({ usemode: 2, target: "txtdateofincident", dateformat: "%d %m %y" }); } }; now object required error on $('#txtdateofincident').length code. any resolve appreciated. i think better if ...

java - Issue while reading tab delimited text file? -

i have tab delimited file , have read data file. col1 col2 col3 data1 data2 data3 data1 data2 data3 if values present columns no isssues. problem few columns may not contain values below. col1 col2 col3 data1 data3 data1 data2 in above data, able read first rows data col2's value empty string. second row's col3 has no data. here array index out of bounds exception. why not getting empty string second row's col3? i using code below: string datafilename = "c:\\documents , settings\\user1\\some.txt"; /** * creating buffered reader read file */ bufferedreader breader = new bufferedreader( new filereader(datafilename)); string line; /** * looping read block until lines in file read. */ while ((line = breader.readline()) != null) { /** * splitting content of tabbed separated line ...

foreach - Java list's .remove method works only for second last object inside for each loop -

i seeing weird behavior. list<string> li = new arraylist<>(); li.add("a"); li.add("b"); li.add("c"); li.add("d"); li.add("e"); for(string str:li){ if(str.equalsignorecase("d")){ li.remove(str); //removing second last in list works fine } } but if try remove other second last in list, concurrentmodificationexception. came attention while reading "oracle certified associate java se 7 programmer study guide 2012" incorrectly assumes .remove() works example of removing second last in list. in list, adding or removing considered modification. in case have made 5 modifications(additions). ‘for each’ loop works follows, 1.it gets iterator. 2.checks hasnext(). public boolean hasnext() { return cursor != size(); // cursor 0 initially. } 3.if true, gets next element using next(). public e next() { checkf...

Possible sybase sql query -

i'm trying sql after many years away. i'm new sybase well. can please suggest possible query following problem? there table called vegetables follows. | product | price | date | | beans | 1.78 | 20040903 | | beans | 1.79 | 20040902 | | potato | 1.78 | 20040902 | i need latest available prices each vegetable. intended database sybase. many thanks. you can use subquery max(date) each product , join table: select v1.product, v1.price, v1.date vegetables v1 inner join ( select product, max(date) maxdate vegetables group product ) v2 on v1.product = v2.product , v1.date = v2.maxdate; see sql fiddle demo (demo sql server syntax should valid). if version of sybase supports windowing functions, can use following: select product, price, date ( select product, price, date, row_number() over(partition product order date desc) rn vegetables ) v rn = 1; see sql fiddle demo

php - Jquery, xml, ajax filter search -

i'm stuck! got xml this: <butikerombud> <butikombud> <typ>butik</typ> <nr>1518</nr> <namn/> <address1>kungsgatan 34 c</address1> <address2/> <address3>s-441 31</address3> <address4>alingsÅs</address4> <address5>västra götalands län</address5> <telefon>0322/101 61</telefon> <butikstyp>självbetjäning</butikstyp> <tjanster>dryckesprovning</tjanster> <sokord>vÄstergÖtland;storken,kristinekyrka</sokord> <oppettider>...</oppettider> <rt90x>6427551</rt90x> <rt90y>1306408</rt90y> </butikombud> <butikombud> <typ>butik</typ> <nr>0704</nr> <namn/> <address1>storgatan 14</address1> <add...

facebook - Removing comments from the comment box widget -

as title says im little stuck admin control of comment box. i have included meta tag <meta property="fb:admins" content="[mhalpin13]" /> to become administrator doesn't seem working. can mark comments spam. weblink http://www.rubb.co.uk/teamrubb.htm this page isn't complete yet can see. any great. thank you michael i totally creeped on you, hope don't mind.. in example <meta property="fb:admins" content="{your_facebook_user_id}"/> facebook docs , {your_facebook_user_id} refers user id number. went facebook.com/mhalpin13, right clicked on add friend, copied link, , pasted below.. in you'll see profile id 51585963 , go ahead , try , let me know if works. once again, sorry creeping.. let me know if works lol https://www.facebook.com/r.php?profile_id=515859638&next=http%3a%2f%2fwww.facebook.com%2fmhalpin13&friend_or_subscriber=friend

c - Create openGL context in linux console(Raspbian) -

i want make minimal visual display in console opengl, far knowledge goes there has window system involved(glut, glfw, sdl, etc..). i've seen omxplayer build graphic environment(i assume opengl or similar, please correct me if i'm wrong) console, in order save processing power, , make movies watchable in pi. i'm wondering how it? there literature in topic? i'm interested in solutions in c/c++, language these capabilities great know about! i scavenged through source code, couldn't find clue particular task. or pointer appreciated! note : raspberry pi opengl es, not opengl. you can find examples of making console based opengl es applications in videocore sdk: /opt/vc/src/hello_pi i'm not sure mean "window system", mention sdl. can absolutely use sdl + opengl es in console. that's quake3 port (and quake2 port made) uses.

Android native debug, ndk-gdb libraries not found -

i have android application jni (and swig). application runs fine , can debug java , native code, keep having warnings gdb have no idea come from, stripped code down simple function. followed various tutorials on how that, tried on mac os x 10.6.8 , linux mint 12, i'm using eclipse (adt). that's warnings got: warning: not load shared library symbols 63 libraries, e.g. /system/bin/linker. use "info sharedlibrary" command see complete listing. need "set solib-search-path" or "set sysroot"? warning: unable find dynamic linker breakpoint function. gdb retry eventurally. meanwhile, gdb unable debug shared library initializers or resolve pending breakpoints after dlopen(). [new thread 17108] [new thread 17110] [new thread 17112] [new thread 17113] [new thread 17114] [new thread 17115] [new thread 17116] [new thread 17117] [new thread 17118] [switching thread 17106] i have no idea libraries gdb looking for, idea?? here output of info sharedl...

Android FragmentTransaction: How to generate an overlay slide in and move existing Fragement to left -

Image
i'm trying following. create new fragement b (menu), slide in right, , want move (no hide or replace!) shown fragment left. i got transaction fragment b right, fragment doesn't change position @ all. seems like, fragmentmanager doesn't know fragment exists (fragment not added dynamically, it's defined in xml). main_screen_layout-xml <relativelayout //... android:id="@+id/main_screen" tools:context=".mainactivity" <fragment android:id="@+id/map_screen" android:layout_width="fill_parent" android:layout_height="fill_parent" class="com.google.android.gms.maps.supportmapfragment" > </fragment> fragmenttransaction fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmenttransaction ft = fragmentmanager.begintransaction(); ft.add(r.id.main_screen, new menufragment(), menu_fragment); //adding fragment b ft.setcustomanimations(r.anim....

c# - How to make enemies follow the player all around the screen in XNA? -

okay, i've got code make enemies follow player in xna game, follow player until player in front of them. if player moves past enemy, stop moving towards him. instead continuously move , down player. the code i've used this: vector2 direction = player.position - goblins[i].position; direction.normalize(); vector2 velocity = direction * goblins[i].enemymovespeed; goblins[i].position += velocity; (ignore goblins bit, i've replaced graphics) not entirely sure go it, ideas? tom, hello, how you? here have 2 examples helped me lot: chase & evade ( http://xbox.create.msdn.com/en-us/education/catalog/sample/chase_evade ) microsoft sample shows how implement several simple behaviors ai, including chasing, evading, , wandering. adding field of view enemies ( http://robotfootgames.com/xna-tutorials/5-xna-platformer-starter-kit-field-of-view-for-enemies ) related number 1 sample , plaformer starter kit

Delphi DLL Dynamic Error raise to many consecutive exception -

i found source code delphi sample codes, , adding control or component inside delphi dynamic dll, can't figure out, library dllentrylib; uses sysutils, windows, dialogs, classes, mshtml, shdocvw; type tmyweb = class(twebbrowser) constructor create(aowner: tcomponent); override; end; var web: tmyweb; // initialize properties here constructor tmyweb.create(aowner: tcomponent); begin inherited create(self); end; procedure getweb; begin web := tmyweb.create(nil); web.navigate('http://mywebsite.com'); end; procedure xdllentrypoint(dwreason: dword); begin case dwreason of dll_process_attach: begin getweb; //i think error here, how work out? showmessage('attaching process'); end; dll_process_detach: showmessage('detaching process'); dll_thread_attach: messagebeep(0); dll_thread_detach: messagebeep(0); end; end; begin { first, assign procedure dllproc variable } dllproc := @xdllentrypoint; ...

c# - Creating atomic database and file system operation -

i working on asp.net mvc 3 application using c# 4.0 , sql server 2008 r2. have scenario where: several database rows inserted sql server database. an xml file built content of 1 of these rows written file system. currently database operations wrapped in transactionscope , file system write last operation before call transactionscope.complete(). i trying combine file system write database inserts single atomic operation. after reading similar post have tried using transactional ntfs (txf) , seems work ok. within team work there reluctance use due lack of evidence , experience txf. what other decent approaches/patterns can used make combined db , file system change atomic? you using sql server 2008. can use filestream storage . wrapped in transaction along database changes.

c - What is the scope of variables, declared in a "for" condition? -

void main(void){ for(int i;;); for(int i;;); } is valid c code? scope of i? c99 6.8.5.3 the statement the statement for (clause-1 ;expression-2 ;expression-3 )statement behaves follows: expression expression-2 controlling expression evaluated before each execution of loop body. expression expression-3 evaluated void expression after each execution of loop body. if clause-1is declaration, scope of variables declares remainder of declaration , entire loop, including other 2 expressions; reached in order of execution before first evaluation of controlling expression. if clause-1 expression, evaluated void expression before first evaluation of controlling expression. also note feature valid since c99. in other words, can't declare variable in first statement in for loop in c89.

joomla - Alternative layout is applied to an article but not the other -

i'm using joomla 3.x , create article override. works fine articles. when apply article, inside single article menu item, not work. update here entire override file: <?php /** * @package joomla.site * @subpackage com_content * * @copyright copyright (c) 2005 - 2013 open source matters, inc. rights reserved. * @license gnu general public license version 2 or later; see license.txt */ defined('_jexec') or die; jhtml::addincludepath(jpath_component . '/helpers'); // create shortcuts parameters. $params = $this->item->params; $images = json_decode($this->item->images); $urls = json_decode($this->item->urls); $canedit = $params->get('access-edit'); $user = jfactory::getuser(); $info = $params->get('info_block_position', 0); jhtml::_('behavior.caption'); ?> <div class="item-page<?php echo $this->pageclass_sfx?>"> <?php if ($this->params->ge...