Posts

Showing posts from July, 2014

git - How to see contents of remote (dirs and files) before cloning locally? -

this question has answer here: browse , display files in git repo without cloning 6 answers i new git , frustrated lack of functions used other vcss. 1 such feature able see directory structure of remote without having cloned locally . imagine wanted see if path existed on remote did not have space locally have cloned. me seems basic function , can't see why wouldn't readily available in both command line plain git egit in eclipse. excluded add shroud of mysterious difference others vcss? there no way preview repository without cloning. git dvcs, d stands distributed. looking non-local repo against git ideology. online wrappers github or bitbucket scripts using corresponding apis can accomplish want though.

R check if parameters are specified: general approach -

i include in r functions general approach check if parameters have been specified. using missing() don't want specify parameter names. want make work inside arbitrary function. more specific, want able copy/paste code in function have without changing , check if parameters specified. 1 example following function: tempf <- function(a,b){ argg <- as.list((environment())) print(argg) } tempf(a=1, b=2) try function: missing_args <- function() { calling_function <- sys.function(1) all_args <- names(formals(calling_function)) matched_call <- match.call( calling_function, sys.call(1), expand.dots = false ) passed_args <- names(as.list(matched_call)[-1]) setdiff(all_args, passed_args) } example: f <- function(a, b, ...) { missing_args() } f() ## [1] "a" "b" "..." f(1) ## [1] "b" "..." f(1, 2) ## [1] "..." f(b = 2) ## [1] "a" ".

Python Kernel died when using Gurobi in Enthought Canopy on Win 7 -

i trying use gurobi python solve mixed integer optimization problem, every time run code wrote according gurobi tutorial, message popped up, saying: "the kernel has died, restart it? if not restart kernel, able save notebook, running code nor work until notebook reopened." i used enthought canopy python 2.7 , gurobipy gurobi on win 7. here small trial optimization problem tried solve, , message above showed after run it: import gurobipy import numpy gurobipy import * def minvol(n1,solution): model=model() x=model.addvar(lb=0.0,ub=1.0,vtype=grb.continuous) y=model.addvar(lb=0.0,ub=1.0,vtype=grb.continuous) model.update() varibles=model.getvars() model.setobjective(2*x+y,grb.maximize) model.update() model.optimize() if model.status==grb.optimal: s=model.getattr('s',varibles) in range(n1): solution[i]=s[i] return true else: return false n1=2 solution=[0]*(n1) success=minvol(n1,solution)

javascript - Sending Email via PHP Not Working -

i have site running on windows azure contains simple contact form people in touch. unfortunately, form isn't work right now... i have index.php file contains form: <div class="form">name="name" placeholder="name" id="contactname" /> <input type="text" name="email" placeholder="email" id="contactemail" /> <textarea name="message" placeholder="message" id="contactmessage"></textarea> <button>contact</button> </div> i have js file this: if ($('#contact').is(":visible")) { $("#contact button").click(function() { var name = $("#contactname").val(); var message = $("#contactmessage").val(); var email = $("#contactemail").val(); var emailreg = /^[a-za-z0-9._+-]+@[a-za-z0-9-]+\.[a-za-z]{2,4}(\.[a-za-z]{2,3})?(\.[a-za-z]{2,3})?$/;

jquery button event function to target button by ID -

i have page full of divs contain 1 button each submit function successfully. however trying isolate buttons id , trigger addition of class , message 2 spots within div (input value & #msgsc). however, event not triggering @ all. , think may missing something. how can change/add class , message sibling input tag , #msgsc of particular button clicked (and not of inputs in divs on page simultaneously)? <form id="hello" target="someplace" action="#" method="post"> <table> <tr> <td> <select name="os0"> <option value="item1">item1</option> <option value="item2">item2</option> <option value="item3">item3</option> <option value="item1">item4</option> </select> <

java - Return Min/Abs of 3 numbers -

i'm working on assignment i'm supposed return smallest of 3 values (absolute values, program states). worked when there 2 values needed returned, added 3rd one, started saying "cannot find symbol" @ math.min inside method. :( can't see problem is? public class threeseven_rasmusds { //start of smallerabsval public static int smallerabsval(int a, int b, int c) { int val = (math.min(math.abs(a), math.abs(b), math.abs(c))); return val; } //end of smallerabsval public static void main(string[] args) { int val = smallerabsval(6, -9, -3); system.out.println(val); } //end of main } //end of class the math.min lib method accepts 2 parameters. if want min of 3 values, need this: math.min( a, math.min(b, c) ); in context: int val = math.min(math.abs(a), math.min(math.abs(b), math.abs(c)));

mysql - SQL date format convert? [dd.mm.yy to YYYY-MM-DD] -

is there mysql function convert date format dd.mm.yy yyyy-mm-dd? for example, 03.09.13 -> 2013-09-03 . since input string in form 03.09.13 , i'll assume (since today september 3, 2013) it's dd-mm-yy. can convert date using str_to_date : str_to_date(myval, '%d.%m.%y') then can format string using date_format : date_format(str_to_date(myval, '%d.%m.%y'), '%y-%m-%d') note year %y (lowercase "y") in str_to_date , %y (uppercase "y") in date_format . lowercase version two-digit years , uppercase four-digit years.

ios - Break in animation. -

hello people in application wanted animation. animation has 160 frames , wanted last 10 sec , make loop. for created array frames , uiimageview. uiimageview *animimageview; ... nsarray *arrayanim = [[nsarray alloc] initwithobjects:[uiimage imagenamed:@"image0001"],...,nil]; animimageview.animationimages=arrayanim; animimageview.animationduration=10; [animimageview startanimating]; this results , animation @ moment startanimating application breaked 7 seconds. there way avoid delay? you're using memory. 640 x 1136 x 4bpp = 2908160 bytes of memory per image. 160 images that's 465 mb of ram (more 3gs has!) without knowing animation looks like, suggest try build animation dynamically using uiviews , animating subviews in real time rather using pre-rendered frames.

nsxmlparser - NSXML parser, where does the program flow go? -

i used nsxml parser parse soap response xml recieved web service. in root method, nsurlconnection *theconnection = [[nsurlconnection alloc] initwithrequest:therequest delegate:self]; i used code send soap request, therequest variable has soap request. after data recieved , -(void)connectiondidfinishloading:(nsurlconnection *)connection{ //codes recieve webdata xmlparser = [[nsxmlparser alloc] initwithdata: _webdata]; [_xmlparser setdelegate: self]; [_xmlparser setshouldresolveexternalentities: yes]; [_xmlparser parse]; } now, program flows didstartelement , didfinishdocument methods. root method needs return result obtained after parsing xml , when checked program flow using breakpoints, parsing methods doesnot end before return statement called in code , hence not able return parsed values. how solve this? nsxmlparser works synchronous. when [_xmlparser parse] returns, parsing done (or aborted error).

php - file_get_contents issue timeout? -

i wanted make website contact servers whenever have ask data sent want when can't connect 1 server tries next. have @file_get_contents heard timeout doesn't work? how handle when happen. i heard timeout doesn't work? you can set timeout file_get_contents() 3rd parameter $context ( context options , parameters ) : $context = stream_context_create(['http' => ['timeout' => 5]]); $html = file_get_contents('http://bit.ly/6wgjo', false, $context); also how handle when happen. check file_get_contents returns false . use curl : you can magic curl. set option curlopt_timeout maximum number of seconds allow curl functions execute. see other options here .

Javascript, CSS: displaying a hidden div not working? -

i know question that's been asked hundred times can't figure out why it's not working on me site. javascript: <script> function show(boxid){ document.getelementbyid(boxid).style.visibility="visible"; } function hide(boxid){ document.getelementbyid(boxid).style.visibility="hidden"; } </script> html (php generated): echo '<div id="selectedbookingactionlink">'; echo '<a href="#" onclick="show(cancelpopup)">cancel</a>'; echo '</div>'; echo '<div id="cancelpopup">'; echo '<div class="question">cancel?</div>'; echo '<div class="answer">yes</div>'; echo '<div class="answer">no</div>'; echo '</div>'; css: #cancelpopup { width: 260px; height: 80px; visibility: hidden; } as can see, i'm trying cha

embed - Embedded Excels in PowerPoint Issue -

i experiencing issue powerpoint 2010. have created 3 part chart in excel , trying export powerpoint. whenever try paste special excel embed given no option paste embed. use work seamlessly me have been having issue every time log powerpoint. please advise. select data/chart want in excel. rightclick , choose copy or pick copy ribbon (excel , ppt seem bit wobbly when use ctrl+c don't waste time it). switch ppt, click downward triangle under paste, , hover on 4 icons see there. can choose between linking/embedding , keeping source or destination formatting.

Catch exception in Scala constructor -

what scala equivalent of java code, somemethodthatmightthrowexception defined elsewhere? class myclass { string a; string b; myclass() { try { this.a = somemethodthatmightthrowexception(); this.b = somemethodthatmightthrowexception(); } { system.out.println("done"); } } } class myclass { private val (a, b) = try { (somemethodthatmightthrowexception(), somemethodthatmightthrowexception()) } { println("done") } } try expression in scala, can use it's value. tuples , pattern matching can use statement more 1 value. alternatively use same code in java: class myclass { private var a: string = _ private var b: string = _ try { = somemethodthatmightthrowexception() b = somemethodthatmightthrowexception() } { println("done") } }

.net - Load something other than the root node of an XML file using ReadXML -

i'm trying load xml file embedded database (sqlite) using .net. best way i've found read data datatable/dataset , use dataadapter update datatable database table. the problem is, xml file have work has data isn't in root node. there's root node (tables), subnode (tablexxx) , of data in subnode. when use readxml (for dataset object), reads in single record (containing name of subnode table). want ignore root node , treat first subnode if root node. how go doing this? (or, if there's easier way load xml file database, i'd interested in hearing well, although i'm guessing i'll still need work around root node issue). watyf string xml = "<tables><table1><col1>xyz</col1></table1></tables>"; dataset ds = new dataset(); ds.readxml(xdocument.parse(xml).root.element("table1").createreader()); var value = ds.tables[0].rows[0]["col1"].tostring(); //<-- xyz edit xdocum

binary decision diagram - How to successfully run cudd library in window -

is there binary decision diagram (bdd) available in windows.i tried run cudd in vc++6.0..which mention link http://web.cecs.pdx.edu/~alanmi/research/soft/softports.htm but isn't working properly.i compiler error while running sample code i compiled cudd windows, using mingw not microsoft environment. goal compiler since use dev-c ide. i did first try using cygwin, no luck. second try msys, environment run unix commands come mingw windows. note cudd uses couple of posix libraries (such ). luckily used in 2 secondary functions: cpu stats , kind of fork didn't understood. since didn't need those, commented portion of code (in util/cpu_stats.c ). then need write makefile mingw in order link library! if need it, can send library compiled.

sanitization - How to make a string safe for an href attribute using PHP? -

would encoding quotation marks , removing eventual javascript: prefixes enough? p.s. safe enough defeat xss attacks is. you can use php function validate urls $url = "http://google.com"; if (filter_var($url, filter_validate_url)) { echo "url valid"; } else { echo "url invalid"; }

java - Conditionally adding extra else if statements -

the following called every level of app (a game) pseudo code example public void checkcollisions(){ if (somecondition) else if (somecondition2) something2 else if (somecondition3) something3 } it's called so: maingame.checkcollisions(); however, in selected levels, need throw in additional condition, instead of duplicating whole method like.......... public void checkcollisions2(){ if (somecondition) else if (somecondition2) something2 else if (somecondition3) something3 else if (somecondition4) something4 } and calling like.......... maingame.checkcollisions2(); i need find way more efficiently (i'm sure there one) way can think of taking in boolean , either carrying out 4th condition (or not) depending on value of boolean is, doesn't seem great way of doing either (say, example if want add more conditions in future). this has 'else if' statement c

c# - Use field of class that implements Singleton pattern in another class -

i have class a implements singleton pattern , contains object obj : public sealed class { static instance=null; static readonly object padlock = new object(); public object obj; a() { acquireobj(); } public static instance { { if (instance==null) { lock (padlock) { if (instance==null) { instance = new a(); } } } return instance; } } private void acquireobj() { obj = new object(); } } now have class b need keep instance of a.obj object until it's alive. public class b { // once class instantiated, class b should have public a.obj // field available share. // best way/practice of putting obj here? } thank you. just make this: class b { public object obj { {

c++ - setuid bit on, yet program can't open a superuser file -

i have file superuser.cpp created superuser access permissions 770 . now, superuser creates file setuiddemonstration.cpp in superuser.cpp opened using open("superuser.cpp", o_rdonly). .cpp , object file of setuiddemonstration.cpp have permissions rwxrwxr-x . now, questions are:- when ran program setuiddemonstration, in both normal , superuser mode not open superuser.cpp. why? @ least, superuser mode should have succeeded in opening it. now, sudo chmod 4775 setuiddemonstration . should allow program open superuser.cpp in normal mode because euid of superuser during execution setuid bit has been set when sudo chmod 4775 setuiddemonstration had been run. couldn't. also, when printed euid while running normal mode, printed 1000 , not 0 . why? update: pointing out mistake. have removed '/' file path , work superuser. after sudo chmod 4775 setuiddemonstration, normal mode run program falis open file. pls explain. because /superuser.cpp name of

ios - What does the "and" keyword mean in Objective-C? -

i typing comment in xcode, forgot leading // . noticed and highlighted keyword. did bit of googling, can't seem figure out (or if it's real keyword). what mean? it's synonym && . see iso646.h .

php - Laravel 4 setting up model using the IoC container -

i watched video , wanted change laravel controllers had dependencies managed laravel's ioc container. video talks creating interface model , implementing interface specific data source used. my question is: when implementing interface class extends eloquent , binding class controller accessible $this->model , should create interfaces , implementations eloquent models may returned when calling methods such $this->model->find($id) ? should there different classes model , modelrepository? put way: how do new model when model in $this->model . generally, yes, people doing pattern (the repository pattern) have interface have methods defined app use: interface somethinginterface { public function find($id); public function all(); public function paged($offset, $limit); } then create implementation of this. if you're using eloquent, can make eloquent implementation use illuminate\database\model; class eloquentsomething { prote

c++ - What happens to statically allocated memory after its scope ends? -

void printarray() { int a[4] = {4,3,1,5}; for(int i=0; i<4; i++) cout<<a[i]; } what happens memory allocated pointer variable 'a' , 4-integer block pointed 'a' after function's call completed? memory of block , pointer variable de-allocated or create sort of memory leak? a not static variable automatic variable, draft c99 standard section 6.2.4 storage durations of objects paragraph 4 says: an object identifier declared no linkage , without storage-class specifier static has automatic storage duration. in paragraphs 3 describes lifetime of static lifetime of program , in paragraph 5 says: for such object not have variable length array type, lifetime extends entry block associated until execution of block ends in way. [...] so in other words automatic variable it's lifetime extends it's scope, in case a s scope function printarray , storage associated released after scope exited. for c++ relevan

c++ - Mapping int and string values to Map<Integer, List<String>> -

in program sort of result: 2:one 3:ff 3:rr 6:fg i want send data using send() method in socket can word occurrence , word @ receiving socket. i think map<integer, list<string>> better option. my code snippet: (std::map < int, std::vector < std::string > >::iterator hit = three_highest.begin(); hit != three_highest.end(); ++hit) { //std::cout << hit->first << ":"; (std::vector < std::string >::iterator vit = (*hit).second.begin(); vit != (*hit).second.end(); vit++) { std::cout << hit->first << ":"; std::cout << *vit << "\n"; } } hit->first gives occurrence[int val], *vit gives string. how can store : map<integer, list<string>> each iteration? you construct lists , insert them map. std::map<int, std::list<std::string> > map_to_string_list; (auto list_it = three_highest.begin(); list_i

ASP.NET / MVC4 Connection String to SQL Server 2008 error -

i working through asp.net mvc4 tutorial asp.net. second tutorial in getting database connection errors. here error: an error occurred while getting provider information database. can caused entity >framework using incorrect connection string. check inner exceptions details , ensure >the connection string correct. here connection strings. first 1 generated template, 2nd copied verbatim tutorial. running sql server 2008, not express. may problem. database created automatically application well. not have login / password aware of local db. <add name="defaultconnection" connectionstring="data source=.\sqlexpress;initial catalog=aspnet-mvcmovie-20130830102032;integrated security=sspi" providername="system.data.sqlclient" /> <add name="moviedbcontext" connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|\movies.mdf;integrated security=true" providername="

javascript - Getting data from angular factory using BreezeJs -

i'm working on implementing angular factory project i'm working on. i've gotten routing working: artlogmain.js var artlog = angular.module('artlog', ['nggrid', 'ui.bootstrap']); artlog.config(function ($locationprovider, $routeprovider) { $locationprovider.html5mode(true); $routeprovider.when("/artlog", { controller: "artlogctrl", templateurl: "/templates/artlog/index.html" }); $routeprovider.when("/artlog/:id", { controller: "artlogeditctrl", templateurl: "/templates/artlog/edit.html" }); $routeprovider.when("/artlog/dashboard", { controller: "artlogdashboardctrl", templateurl: "/templates/artlog/dashboard.html" }); $routeprovider.otherwise("/"); }); next setup factory: artlogdataservice artlog.factory("artlogdataservice", function ($q) { bre

ruby - ERROR: While executing gem ... (Gem::FilePermissionError) -

i have checked other similar answers , none mine, neither did of solutions work me. gem environment , sudo gem environment give same result: rubygems environment: - rubygems version: 1.5.3 - ruby version: 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux] - installation directory: /usr/local/lib/ruby/gems/1.8 - ruby executable: /usr/local/bin/ruby - executable directory: /usr/local/bin - rubygems platforms: - ruby - x86_64-linux - gem paths: - /usr/local/lib/ruby/gems/1.8 - /home/ava/.gem/ruby/1.8 - gem configuration: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - remote sources: - http://rubygems.org/ rvm -v : rvm 1.22.3 ruby -v : ruby 1.8.7 osx 10.8.4 echo $path /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/ava/.rvm/bin:/home/ava/bin gem install <gem-name> gives error: while executing

python - Why I am getting TypeError on production server where I am trying to save data in the session? -

environment: request method: request url: django_server_running_on_apache django version: 1.3.3 python version: 2.7.3 traceback: file "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 178. response = middleware_method(request, response) file "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/middleware.py" in process_response 36. request.session.save() file "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/file.py" in save 121. os.write(output_file_fd, self.encode(session_data)) file "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/base.py" in encode 93. pickled = pickle.dumps(session_dict, pickle.highest_protocol) exception type: typeerror @ / exception value: expected string or unicode object, nonetype found it recommended store scalar objects in session. pickel fai

javascript - DurandalJs Plugin Views? -

i developing application using durandaljs, version 1.2.0. have unique requirement in need support plugin view concept. elaborate, application should able load views on-demand after being deployed. this becomes challenging after optimization. when run optimizer, merged , "compiled" 1 file. not sure if possible (without code) have in place load views dynamically. scenario 1: profile details view not exist application admin uploads profile details view+viewmodel scenario 2: product details view exists app admin wants override existing view functionality app admin uploads new product details view+viewmodel is possible?

Currency rounding inconsistencies in Dojo.currency -

im working dojo.currency format. there seems inconstancies on how rounds, im trying find if im doing wrong: dojo.currency.format("66.315",{currency:"usd"}) "$66.31" dojo.currency.format("669.315",{currency:"usd"}) "$669.32" in above example both prices rounded 32 cents, reason end 2 different amounts. looks dojo.currency using dojo.number.round under covers, , dojo.number.round uses javascript tofixed. known have floating point problem. using math.round(number*math.pow(10,places))/math.pow(10,places) instead

.net - Entity Framework Code First Migrations thinks there is a change that shouldn't be there -

i have website , windows service both reference same project entity framework data context. each time start windows service, entity framework runs automatic migration changes 1 of database columns not null null (no other changes made). property column marked [required], , website (which points exact same version of exact same dll model), thinks database should not null column. i tried disabling automatic migrations and, expected, service crashed because said data model had pending changes needed applied. edit i've found out bit more info... seems happening because have both [required] , [allowhtml] attributes on property. when removed [allowhtml] attribute, didn't happen. so, question comes down to: 1) expected behavior [allowhtml] not work [required], , 2) how possible happen when web service uses code, , not when website uses code? seems web service ignores [required] when sees [allowhtml]. i'm using ef 5. i had exact problems... pending changes had ad

c# - ListView CheckedItems find item by name -

i need check if item particular name exists in checkeditems collection of listview. so far i've tried: listviewitem item = new listviewitem(itemname); if (listview1.checkeditems.indexof(item) >= 0) return true; and listviewitem item = new listviewitem(itemname); if (listview1.checkeditems.contains(item)) return true; neither of worked. there way without looping through checkeditems , checking them 1 one? you can benefit linq purpose: bool itemchecked = listview1.checkeditems.oftype<listviewitem>() .any(i => i.text == itemtext); //you can retrieve item itemtext using firstordefault() var checkeditem = listview1.checkeditems.oftype<listviewitem>() .firstordefault(i=>i.text == itemtext); if(checkeditem != null) { //do work...} you can use containskey determine if item (with name being itemname ) checked: bool itemchecked = listview1.checkeditems.containskey

"Cannot import name Popen" in IronPython 2.7.3 -

i'm having weird problem where, though "clr.addreference('ironpython.stdlib')" @ top of ironpython code (i have built copy of stdlib readily findable), unable access popen. multithreaded application, many threads (ten, right now) trying access script @ same time. i don't have problem accessing ironpython @ console. 2013-09-03 17:10:11.5197 error pythonscriptengineproviderlib.pythonscriptengineprovider.executecompiledcodeinternal not execute python code. ironpython.runtime.exceptions.importexception: cannot import name popen @ ironpython.runtime.importer.importfrom(codecontext context, object from, string name) @ microsoft.scripting.interpreter.funccallinstruction`4.run(interpretedframe frame) @ microsoft.scripting.interpreter.interpreter.run(interpretedframe frame) @ microsoft.scripting.interpreter.lightlambda.run2[t0,t1,tret](t0 arg0, t1 arg1) @ ironpython.compiler.pythonscriptcode.runworker(codecontext ctx) @ ironpython.compiler.run

python - Thread error: can't start new thread -

here's mwe of larger code i'm using. performs monte carlo integration on kde ( kernel density estimate ) values located below threshold (the integration method suggested on @ question: integrate 2d kernel density estimate ) iteratively number of points in list , returns list made of these results. import numpy np scipy import stats multiprocessing import pool import threading # define kde integration function. def kde_integration(m_list): # put of values m_list 2 new lists. m1, m2 = [], [] item in m_list: # x data. m1.append(item[0]) # y data. m2.append(item[1]) # define limits. xmin, xmax = min(m1), max(m1) ymin, ymax = min(m2), max(m2) # perform kernel density estimate on data: x, y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) # list returned @ end of function. out_list = [] # iterate through points in list , calculate

python 3.x - Stop uwsgi performing harakiri (seriously) -

i've been trying track down problem uwsgi uwsgi process kills itself. the oh-so-helpful log files say... f*ck !!! must kill myself (pid: 9984 app_id: 0)... a little googling led me this line in source code ... void harakiri() { uwsgi_log("\nf*ck !!! must kill myself (pid: %d app_id: %d)...\n", uwsgi.mypid, uwsgi.wsgi_req->app_id); //some other stuff exit(0); } whether dies or not varies seems (from googling) tied how long request takes. in instance, request streaming dynamically generated pdf. generation happens in background once it's complete, new request comes in retrieve it. pdf can potentially quite large (worst-case, 50-60mb) - depending on connection - speed explains why requests might reach timeout threshold. how can configure uwsgi either never time out or have extremely high timeouts? app being used on private networks , i'd rather slow , succeeded died. harakiri voluntary enable --harakiri, default there no such f

Encrypt XOR in Delphi / Decrypt in PHP -

ok guys, few days ago translated simple xor function in delphi php , working fine. today when tried again unknown reason, it's broken. i'm doing is: first base64 encode in string, xor it. send php on post method, , in php 'unxor' , decode base64. function in delphi(i'm using encodebase64 encddecd unit): function encryptstr(input: ansistring; seed: integer): ansistring; var : integer; output : ansistring; begin input:= encodebase64(bytesof(utf8encode(input)), length(bytesof(utf8encode(input)))); output := ''; := 1 length(input) output := output + ansichar(ord(input[i]) xor (seed)); result:= output; end; ok, send way on indy http(don't know if matters, can useful) procedure tform1.dopost; var http: tidhttp; lpost: tstringlist; begin http:= tidhttp.create(nil); lpost:= tstringlist.create; http.request.useragent:='mozilla/5.0 (compatible; msie 10.0; windows nt 6.1; trident/6.0)'; lpost.add('pname=

ember.js - Filter a list of objects using computed properties? -

short context - using ember , ember-data present list of events user. events aggregated in api endpoint, , each has "kind" property notes type event (announcement, etc). events filtered @ api level user (so have query on user_id user's list of events. i need display these events on single page, break them kind. there's fixed list of kinds, can call them , b. my intuition set model in eventsroute so: model: function () { return this.store.find('events', {user_id: $.cookie('user_id')}); } and make various event types filters on eventscontroller: announcements: function() { return this.get('model').filterby('kind', 'announcement'); }.property(), this works, @ least in test cases. i'm not sure it's right way go things, though. haven't quite grokked difference between properties (which seem set on controller) , model (which route sets). so, questions are: is right way go creating filtered sublists of

Scroll pagination (search system), Jquery. Javascript -

does know scroll pagination system data search system? tried adapt scrollpagination.js didn't get. tutorial or me? example .. upon entering site, pagination run normal when search, make paging according data entered. tutorial on how in jquery or plugin , sorry english xd i have done in past setting api accept page-number , results-per-page parameters, using jquery $.get('url?page=2&resultsperpage=10', function(data){ appendresults(data) }); i trigger on scroll when reaches bottom.

linear algebra - C# SolverFoundation find maximum combination of lengths -

i have list of brackets need find combination of them 4 brackets, best fits length. these brackets , example need find out combination of these closest without going on 120 inches. <?xml version="1.0" encoding="utf-8" ?> <brackets> <bracket> <partnumber>f0402583</partnumber> <length>42.09</length> </bracket> <bracket> <partnumber>f0402604</partnumber> <length>32.36</length> </bracket> <bracket> <partnumber>f0403826</partnumber> <length>46.77</length> </bracket> <bracket> <partnumber>f0402566</partnumber> <length>44.17</length> </bracket> <bracket> <partnumber>f0402289</partnumber> <length>20.55</length> </bracket> <bracket> <partnumber>f0402612</partnumber> <length>18.46</le

ios6 - iOS inapp payments - what is the right way to confirm to the user when they have made a purchase? -

i confused how , when tell user completed purchase successfully. got application rejected during app review process reason: 1. launch app 2. tap on learn benefits of subscription 3. tap on subscribe 4. tap on confirm , enter itunes password 5. no further action occurs and not sure when , how tell user entered info correctly since confirmed on itunes server. i have iaphelper class looks this: // // iaphelper.m // businessplan // // created macoslion on 8/12/13. // // // 1 #import "iaphelper.h" #import <storekit/storekit.h> // 2 //@interface iaphelper () <skproductsrequestdelegate> @interface iaphelper () <skproductsrequestdelegate, skpaymenttransactionobserver> @end @implementation iaphelper { // 3 skproductsrequest * _productsrequest; // 4 requestproductscompletionhandler _completionhandler; nsset * _productidentifiers; nsmutableset * _purchasedproductidentifiers; } - (id)initwithproductidentifiers:(nsset *)pro

rest - Choosing the right OAuth2 grant type for PHP web app -

i'm building typical web app product. have corresponding mobile apps in future. i'm building ground rest api, secured using oauth2. i've got oauth2 working, , i'm able connect using various grant types. what i'm little confused grant types use actual web app. here's had in mind: public api access before user logs web app, api access required things user registration , password resets. thinking of using client_credientials grant type. simple client id , secret validation in return access token. however, seems totally unnecessary request access token every single public request or each session. seems make more sense generate 1 access token web app use. yet, seems go against how oauth designed work. example, access tokens expire. right way of doing this? private user api access next, user login web app planning on using password grant type (resource owner password credentials). approach allows me save user_id access token—so know user logged in

php - Active Record must have domain logic? -

i started time working yii framework , saw things "do not let me sleep." here talk doubts how yii users use active record. i saw many people add business rules of application directly in active record, same generated gii . believe misinterpretation of active record , violation of srp . early on, srp easier apply. activerecord classes handle persistence, associations , not else. bit-by-bit, grow. objects inherently responsible persistence become de facto owner of business logic well. , year or 2 later have user class on 500 lines of code, , hundreds of methods in it’s public interface. callback hell ensues. when talked people , view criticized. when asked: and when need regenerate active record full of business rules through gii do? rewrite? copy , paste? that's great, congratulations! got answer, silence. so, i: what doing in order reach little better architecture generate active records in folder /ar. , inside /models folder add domain model. by w

python mechanize yahoo mail -

Image
i trying use python / mechanize login yahoo mail. new mechanize, there have, why saying no form named "login" import mechanize url = "https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym" import re import mechanize br = mechanize.browser() br.open(url) br.select_form(name="login") br.close() screen shot below of yahoo mail website. thanks you can form's names with for form in br.forms(): print form.name since there few forms on page, name should obvious. otherwise, can form id similarly; should able with br.select_form(nr=0) or br.select_form(nr=1) since forms may not have name.

c - Hadamard matrix code -

i'm trying construct hadamard matrix of dimensions n*n, , print it. code compiles when run it doesn't part asking n input. ideas wrong it? #include <stdio.h> void main(void) { int i, n; scanf("input n value: %d", &n); char **h = (char**) calloc(n, sizeof(char*)); ( = 0; < n; i++ ) { h[i] = (char*) calloc(n, sizeof(char)); } int ii, xx, yy; h[0][0]='1'; for(ii=2; ii<=n; ii*=2) { //top right quadrant. for(xx=0; xx<(ii/2); ++xx) { for(yy=(ii/2); yy<ii; ++yy){ h[xx][yy]=h[xx]yy-(ii/2)]; } } //bottom left quadrant. for(yy=0; yy<(ii/2); ++yy) { for(xx=(ii/2); xx<ii; ++xx) { h[xx][yy]=h[xx-(ii/2)][yy]; } } //bottom right quadrant, inverse of other quadrants. for(xx=(ii/2); xx<ii; ++xx) { for(yy=(ii/2); yy<ii; ++yy) { h[xx][yy]=h[xx-(ii/2)][yy-(ii/2)]; if(h[xx][yy]==

Trying to understand haskell's code -

here haskell code compiles: class category categ method1 :: categ a method2 :: categ b -> categ b c -> categ c but don't understand meaning: what's categ ? how can defined: through data or class ? maybe function ? what a , b , c ? since not specified as class category categ b c method1 :: categ a method2 :: categ b -> categ b c -> categ c this code shouldn't compile, should it? class category categ this type class declaration, it declares type class called category . categ variable used refer type implementing category in associated functions. later fill when say instance category foo .... then wherever categ used in type class methods, substitute foo , define methods. read out loud "a type categ category if has following methods" now methods: method1 :: categ a method2 :: categ b -> categ b c -> categ c declares 2 functions type implementing category must implement. first 1 no

javascript - Jquery name space functional process is not understandable -

i searching across web jquery.namespace process. got answer in stack overflow example script.. jquery.namespace = function() { var a=arguments, o=null, i, j, d; (i=0; i<a.length; i=i+1) { d=a[i].split("."); o=window; (j=0; j<d.length; j=j+1) { o[d[j]]=o[d[j]] || {}; o=o[d[j]]; console.log(o); } } // console.log(o); //object {} return o; }; // definition jquery.namespace( 'jquery.debug' ); jquery.debug.test1 = function() { alert( 'test1 function' ); }; jquery.debug.test2 = function() { alert( 'test2 function' ); }; // usage jquery.debug.test1(); jquery.debug.test2(); it has 2 parts, once "jquery.namespace" - function , declaring new methods name space. unable understand "jquery.namespace" function here.. tried understand line line, couldn't process function here.. any 1 explain me function, how that's

javascript - 2 different js file in same html -

what want achieve call external .js file .aspx, first thing generate tooltip function in master page, go .aspx call external .js file, doesnt work. in .aspx, cant alert homepage.js, 1 can tell me mistake? master page <script type="text/javascript" > function showtooltip() { //do based on data passing in } homepage.aspx <script type="text/javascript" src="http://[servername]/scripts/homepage.js"></script> homepage.js <script type="text/javascript" > alert("homepage.js"); var datamenu = { lbl1: "fruit", lbl2: "auto mobile" } </script> make sure document ready before script called. $(function(){ alert("homepage.js"); }); var datamenu = { lbl1: "fruit", lbl2: "auto mobile" } make sure path file correct , looks have os path in src..give relative path

d3.js - svg map wont display with d3 & geoJSON -

i'm attempting create dynamic map d3. converted shapefile geojson, tried create svg image , bind geojson data using d3. visible on page blank or white svg image (700 x 700). how reveal map? code shown below: $(function() { var canvas = d3.select("body").append("svg") .attr("width", 700) .attr("height", 700) d3.json("nysd.geojson", function(data) { var group = canvas.selectall("g") .data(data.features) .enter() .append("g") var projection = d3.geo.mercator().scale(5000).translate([0,1980]); var path = d3.geo.path().projection(projection); var areas = group.append("path") .attr("d", path) .attr("class", "area") .attr("fill", steelblue); }); });

how can i make my text appear along side my featured image instead of below it in my wordpress posts -

im constructing articles section on test.smartphonesource.org , featured image appearing along post excerpts seems loading articles excerpt below image text appear alongside image , flow naturally in post's body im going shortening excerpts , adding read more button achieve effect similar website http://healthcave.com/ cant seem find styles or code causing happen here code page template calling thumbnail images , content <?php get_header(); ?> <div id="breadcrumb"> <?php breadcrumbs(); ?> </div> <?php include(templatepath."/customrightsidebar.php");?> <div id="kontenutama"> <div class="postingan2"> <?php if (have_posts()) : while (have_posts()) : the_post();?> <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php if (function_exists(

Printing pdf file from network shared printer in android -

i have pdf file stored on sd card named "test.pdf". have opened file in application using following code: b.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub file file = new file(environment.getexternalstoragedirectory().getabsolutepath() +"/"+ "test.pdf"); intent target = new intent(intent.action_view); target.setdataandtype(uri.fromfile(file),"application/pdf"); target.setflags(intent.flag_activity_no_history); intent intent = intent.createchooser(target, "open file"); try { startactivity(intent); } catch (activitynotfoundexception e) { // instruct user install pdf reader here, or toast.maketext(getapplicationcontext(), "not found", toast.length_short).show(); } } }); pdf displayed inside application. want print pd

python - MemoryError when read a file larger than 2G -

a single file size greater 2g. call open(f, "rb").read() memoryerror. call open(f, "rb").read(1<<30) ok how can eliminate 2g limit? have enough memory -- 16g what using memory mapped files ( mmap )? there's example in documentation on python.org . adapted below. with open(f, "rb") fi: # memory-map file, size 0 means whole file mm = mmap.mmap(fi.fileno(), 0) # stuff mm.close()