Posts

Showing posts from May, 2011

c# - Visual Studio: Opening a solution on a different machine loses already opened files -

visual studio 2013 sp2 (all versions share same problem). if reopen solution in visual studio on same machine, ide has persistence, namely was, when exited vs. see same files open , in same order. if go different machine , open same file (say solution saved in cloud, on flash drive, or on central server inclusive of user based temporary files), presented clean interface. basically, there no files open. in clean, no trace of previous settings. as mentioned, suo , other user specific files saved locally moved. question: there way visual studio open project on new machine continue left off , not have open files again?

Javascript Object: Map of Functions. How to return default value -

sorry title of question, don't found better one. introduction my goal create object, , associate every params function. simple! var canidothis = { one: function(a, b, c){}, two: function(a){}, three: function(){} } i want call canidothis in way if(canidothis['one'](x, y, z)) { // somthing } if(canidothis['two'](w)) { // somthing } if(canidothis['three']()) { // somthing } if have var can "one", "two" or "three" can use canidothis in way // myvariable can equalso "one" or "two" or "three" var myvarable; if(canidothis[myvarable]()) { // somthing } my problem i'd manage myvarable value. if call canidothis['four']() uncaught typeerror: undefined not function my question is there way prevent default behaviour of uncaught typeerror , return default value? cute if canidothis['four']() interpretated false or undefined ...

Continuous Delivery for FUSE OSS and Github -

i set continuous delivery cycle open source application. based on linux's filesystem in userspace (fuse). tried set on cloudbees' jenkins , provided decent free accounts, did not have root access, problematic project has many dependencies. went on use travis ci , works great testing internal apis, since have root access install dependencies. not support fuse , cannot run tests on filesystem directly. according experience travis ci, continuous delivery approach prevent many bugs being released , identify problems more quickly. is there service similar travis ci, integrates github, allows root access, , supports fuse? [edit] vi. suggests run user mode linux on travis-ci machine, emulate fuse. summarize progress achieved vi.s help: for setting uml more memory, network access , access file system execute: /usr/bin/linux.uml init=script_to_run.sh rootfstype=hostfs rw eth0=slirp mem=2g inside user script, call: # enable fuse module. insmod /usr/lib/uml/modules/`una...

asp.net - DateTime format not match to expected format in SQL SERVER 2012 -

after hours of searching solution problem ask best answer : building project in asp.net 2013 , date datetimepicker (jquery script) set format - dd/mm/yy , convert datetime object in c# format in c# : dd/mm/yyyy hh:mm:ss , send function insert sql server databse expected mm/dd/yyyy hh:mm:ss format insert faild , throw error - the conversion of varchar data type datetime data type resulted in out-of-range value. hope quick solving problem ! thanks, shaul.

ios - Disabling a control with Pixate Freestyle -

i have uibutton following css button { size: 50 100; color: #ff0000; } but want disable button based on style maybe: button { size: 50 100; color: #ff0000; enabled: true; } does know how accomplish or add extension method enable this? i don't think there enabled or disabled pseudo-classes available uibutton . potentially instead detect button state , assign styleclass dynamically this: #import <pixatefreestyle/pixatefreestyle.h> uibutton *button = [uibutton new]; if(button.enabled){ button.styleclass = @"mybutton"; }else{ button.styleclass = @"mybuttondisabled"; } ...and css be: .mybutton { /* default button styles */ } .mybuttondisabled { /* disabled button styles */ } i hope helps. luck.

asp.net - .NET Localization Satellite Assemblies -

we have website project being localized 30+ languages. the project split pll, bll & dal. we have on hundred .resx files located in various different folders in base language (english). we use separate system localization spits out language files in correct format/directory automatically. once finished there thousands of files import visual studio project! this become nightmare manage :( is there way compile localized files separately satellite assemblies , copy them project later? i want work english files in main vs project , not see localized files. you can create project houses localized resource files - build these satellite assemblies , copy them main project. for example: create new project in existing solution eg: myapp.localized then change assembly name match name of main application (myapp) , change default namespace (c#) or root namespace (visual basic) match default or root namespace of main application (myapp). now when build myapp.l...

what is wrong with this code of nltk python -

def ethos(file): f = open(file) raw = f.read() tokens = nltk.word_tokenize(raw) words_to_match = ['love' , 'good' , 'excellent' , 'perfect' , 'brilliant' , 'easy' , 'well' , 'made' , 'impressive' , 'great'] matching_tokens = [] tokens in tokens: if tokens in words_to_match: matching_tokens.append(tokens) return matching_tokens i not able understand why code not able return list, returning 1 token/word, after execution your return statement in loop, means function returns tokens in words_to_match true. correct problem, move return out of loop, this: (for simplicity removed part of opening file. it's test. you'll have let method read file) import nltk def ethos(): raw = 'i love made products' tokens = nltk.word_tokenize(raw) words_to_match = ['love' , 'good' , 'excellent' , 'per...

ember.js - How do I set up polymorphic relationships using ember-data -

so lets recipe has several ingredients of differing amounts. recipe model var recipe = ds.model.extend({ name: ds.attr('string'), ingredients: ds.hasmany('ingredient') }); ingredient model var ingredient = ds.model.extend({ name: ds.attr('string'), recipes: ds.hasmany('recipe'), // amount? }); so amount of each ingredient depend on recipe. on own ingredient not have amount. how go modeling data? right using fixtureadapter until finish building interface. using ember 1.5.1 , ember-data 1.0.0-beta.7+canary.b45e23ba . to answer first question: define model so app.comment = ds.model.extend({ message: ds.belongsto('message', { polymorphic: true }) }); and property needs additional property propertytype, defining relationship type { "message": 12, "messagetype": "post" } https://github.com/emberjs/data/blob/master/transition.md#polymorphic-relationships...

Angularjs directive that resizes only width of the canvas -

how can write directive changes width of canvas? actually going pretty simple. below simple directive resize element's width. var ag = angular.module('ag', []); var resizex = function() { return { restrict: 'a', scope: { resizex: '=' }, link: function postlink(scope, element, attrs) { scope.$watch('resizex', function(value) { element.css('width', value + 'px'); }); } }; }; ag.directive('resizex', resizex); just link resizex directive scope model in element. here working example: http://plnkr.co/edit/avsautazqqybb5vczgob?p=preview let me know if works you.

java - sane representation of lists in XML and JSON using MoXY -

i need expose jax-rs resource in xml , json, part of include passing in (potentially large) lists of integers. i'm using moxy jaxb / json provider. the problem run cannot figure out how expose list of integers works in both xml , json. if use @xmllist @xmlelement(name = "values", type = integer.class) protected list<integer> values; then json (un)marshaled ... "values" : "0 1 2 4" ... which undesirable when dealing large numbers of numbers. if @xmllist annotation omitted, json dealt properly, xml ... <values>0 1 2 4</values> ... is parsed [124] instead of [0, 1, 2, 4]. by using @xmlelementwrapper (and telling moxy "usewrapperasarrayname") @xmlelementwrapper(name = "values", required = true) @xmlelement(name = "value") protected list<object> values = new arraylist<object>(); good json achieved ... "values" : [0, 1, 2, 4] ... but imposes tedious xml for...

html - Solution for touch-friendly NESTED nav menus? -

a common problem run when building responsive websites how make multi-level nav menu (3 or more levels) works touch devices. i've seen lot of plugins , techniques, of them fall flat because don't allow 2nd-level page act both link page , parent of children in sub-sub-menu. techniques address having arrow icon exposes children menu items while clicking on parent page name goes actual page... on mobile devices these icons small targets , hence hard use. there other solutions problem (either jquery or javascript plugins, or straight-up css/js code)? i have 'starting point' of sorts use responsive web projects this. i'm not sure if it's need, allows multi-level dropdown menus in desktop view. in mobile view, jquery automatically creates off-canvas menu. code: https://github.com/kthornbloom/responsive_template demo: http://rwd.kthornbloom.com/ hope helps!

ios - Appium Error: start point is not within the bounds of the screen -

i'm trying run automated tests of web app on ios using appium (via saucelabs) , getting problem relatively simple test case detailed below. i following error in appium log: info: [instserver] got result instruments: {"status":17,"value":"start point not within bounds of screen"} 2014-05-29t17:21:01.282z - info: responding client error: {"status":17,"value":{"message":"an error occurred while executing user supplied javascript.","origvalue":"start point not within bounds of screen"},"sessionid":"47322525-37e0-4f4b-a236-224906d0135c"} looking @ screenshots, element in question appear on screen. i've tried scrolling element before attempting click using: ((ijavascriptexecutor)driver).executescript("arguments[0].scrollintoview();", driver.findelement(by.id(elementid))); and scrolling via javascript doesn't appear make difference. seems set of c...

c# - How to display a set of images in windows phone 8,8.1 -

how can display set of scrollable images have in bitmap format or in list< bitmapimage > , allow user select 1 of them. i have bitmapimage in list, here code snippet page.xaml <phone:longlistselector x:name="imagelist" scrollviewer.horizontalscrollbarvisibility="auto"> <phone:longlistselector.itemtemplate> <datatemplate> <image source="{binding bitmapimage}"/> </datatemplate> </phone:longlistselector.itemtemplate> </phone:longlistselector> page.cs code - displayimageslist = phoneapplicationservice.current.state["pro_images"] list<bitmapimage>; imagelist.itemssource = displayimageslist; i adding answer other got helped :) your list list of bitmapimage class have use directly binding. in case trying bind property if bitmapimage type not present anywhere...

jquery - Angularjs - setting value of list item -

as angular newbie have simple question... i can reset value in input using ng-model="mytextbox" , using $scope.mytextbox = ''; in controller how can reset/clear text isn't angular model such list item. i have: <li my-draggable="#sortable" ng-bind-html="quicklookhtml"></li> and html gets injected list item. question: how can use angular target list item , clear value? you bind html $scope.quicklookhtml $scope.quicklookhtml = ""

c++ - Multiple inheritance and generic program -

i reading "modern c++ design: generic programming , design patterns applied" andrei alex., started. @ page 6, has following critcism of multiple inheritance: the problems assembling separate features using multiple inheritance follows: ... type information. base classes not have enough type information carry out tasks. example, imagine try implement deep copy smart pointer class deriving deepcopy base class. interface deepcopy have? must create objects of type doesn't know yet. i wondering if particular critique flawed. interface driven design has base class pure virtual class , child class implements interfaces. take deepcopy example, this: struct deepcopy { virtual void copy(deepcopy *src) = 0; }; class myclass : public deepcopy, public anotherintf { public: virtual void copy(deepcopy *src); }; in example, myclass implementer , real class. maybe miss point of andrei's critique here. ...

Set/Get SystemTime in Java /C# -

i have code in java systemtime: private static simpledateformat sdf = new simpledateformat("yyyy-mm-dd hh.mm.ss"); //gets time of boardtime object in milliseconds public long getms() { return super.gettimeinmillis(); } //sets time of boardtime object in milliseconds public void setms(long ms) { super.settimeinmillis(ms); } i tried convert c#: first part, used datetimeformatinfo class: private static datetimeformatinfo sdf = new datetimeformatinfo(); for getting system time in milliseconds used timespan: long milliseconds = datetime.now.ticks / timespan.tickspermillisecond; i not know if have done until correct or not can not find c# equivalent settime. this have done until now: private static datetimeformatinfo sdf = new datetimeformatinfo(); public long getms(){ long milliseconds = datetime.now.ticks / timespan.tickspermillisecond; return milliseconds; } public void setms(long ms){ } thanks ...

Angular service word overloaded: rename one service and another SERVICE on angularjs.org API doc -

as most, trying learn differentiates different service providers in angularjs, {service values, service factories, service services, , service providers}. may have read service services , thought 1 crazy. not. angular developers ones crazy, , notated on api on providers here , stating note: yes, have called 1 of our service recipes 'service'. regret , know we'll somehow punished our mis-deed. it's named 1 of our offspring 'child'. boy, mess teachers. well, misdeed isn't clear enough. in cases, know 1 talking about, because written grammatically singular service , in many other cases, pluralized, , don't know service talking about, services, or service services. i propose api documentation differentiates these 2 terms 1 being caps, ie service or services , other service or services or if @ beginning of sentence, service , or services . agree too. problem can't initiate pull request api, don't know words in documentation which...

html - Bootstrap 3: Form "required" not working in mobile devices -

i'm working on form styled bootstrap , connected google docs doing little hack. form works great when test in browser , developer tools emulators. if leave blank space, small pop tells me fill space before continuing , doesn't post information spreadsheet nor advancing greeting page (expected behavior). however when test in iphone , other mobile devices doesn't work. can leave blank spaces , ignores "required" condition , takes me greeting pages. as can see that's problem. want form behave behaves on browser. ideas? <!-- form --> <div class="col-lg-6 form-container" style="margin-top: 20px; margin-left:-20px"> <script type="text/javascript">var submitted=false;</script> <iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted) {window.location='thank-you.html';}"></iframe> <form class=...

While-Loop Use in Python -

when come 2nd while loop while x == 2: it's still repeating whole script though x /= 1 (not if "n" is entered). let enter "y" on prompt "is correct?" shouldn't x become 3 stops both first , 2nd loop? this obvious i'm pretty new. # -*- coding: utf-8 -*- import time x = 1 while x == 1: print "what's name?" name = raw_input("name: ") print "how old you?" age = raw_input("age: ") print "so %r years old , name %r. correct?" % (age, name) correct = raw_input("(y/n): ") while x == 2: if correct == "y": x = 3 # x = 3 skips whiles, not working time.sleep(1) elif correct == "n": time.sleep(1) x = 1 # x = 1 --> 1st while still in action else: print "invalid input \n\t loading..." x = 2 #...

angularjs - Detect closing $modal by backdrop -

i'm using angularjs angularui-bootstrap. there way detect when modal being closed clicking on backdrop? trying change boolean based on closing of modal. sure, easy detect closing esc / clicking on backdrop. if such event takes place result promise rejected. so, can run whatever logic want adding error handler result promise returned $modal.open({...}) method. you can see in action in plunker forked demo page ( http://angular-ui.github.io/bootstrap/ ): http://plnkr.co/edit/qjbjkb7but5vfinvpyrf?p=preview $log.info('modal dismissed at: ' + new date()); code executed on modal's dismiss.

javascript - Using Jurassic to precompile a JsRender template server-side -

i'm attempting precompile jsrender templates class library written in c#, using jurassic script engine execute jsrender. here code: var engine = new jurassic.scriptengine(); engine.execute(jsrendercontents); var precompiledtemplate = engine.callglobalfunction<string>(string.concat("$.templates(\"", template, "\");")); i've taken javascript function call, $.templates() , this page states that $.templates(markuporselector) returns: compiled template object and sample html template simply <li>{{:name}}</li> however, code produces exception: '$.templates("<li>{{:name}}</li>");' not function. now, i'm not 100% clear whether can use $ operator without jquery being present. author includes jquery in several of examples, states jquery not required. so what's going wrong? documentation out of date version of jsrender taken github on same day posted question? (i'm aw...

crash - Weird Qt behavior crashing my application -

normally when have problem in qt, due me not understanding problem illogical. i have function handle hotkey's event: bool mainwidget::nativeevent(const qbytearray& eventtype, void* message, long* result) { msg* msg = reinterpret_cast<msg*>(message); if (msg->message == wm_hotkey) { qdebug() << "it works"; // if remove line, app crashes. togglevisibility(false); } } it works if remove qdebug() line, app crashes starts running. nothing gets displayed. code in constructor runs seems crashes gets function. in constructor of main widget, have line register hotkey: if (!registerhotkey(hwnd(this->winid()), 1, mod_control | mod_shift | 0x4000, 0x41)) qdebug() << ("hotkey failed"); adding other line instead of qdebug doesn't make difference. (e.g delete msg). removing line 'togglevisility' doesn't make difference rules out function. if move qdebug line before if statement not ...

iphone - Strange behavior with message composer on iOS 7 -

Image
i'm working on app sends email , texts user's contact list. i have view controller presents either mfmessagecomposeviewcontroller or mfmailcomposeviewcontroller , proper delegates setup. however, ui appears in composer seems offset , incorrect. here's code present message composer: if ([mfmessagecomposeviewcontroller cansendtext]) { mfmessagecomposeviewcontroller *composer = [[mfmessagecomposeviewcontroller alloc] init]; composer.messagecomposedelegate = self; composer.recipients = [nsarray arraywithobject:[self unformattedphonenumber:number]]; [self presentviewcontroller:composer animated:yes completion:nil]; } pretty simple stuff. however, when modal view controller presented, looks this: the contact picker text field (where can type in users name or number), appears briefly against black background, animates hidden behind navigation bar. stranger, contact text field starts first responder, can still type it, , here result when start searc...

c++ - Pointer Arithmetic, Pass by Reference -

i got following question past exam paper: consider following source code: using namespace std; int main() { char dest[20]; printf( "%s\n", altcopy( dest, "demo" ) ); printf( "%s\n", altcopy( dest, "demo2" ) ); printf( "%s\n", altcopy( dest, "longer" ) ); printf( "%s\n", altcopy( dest, "even longer" ) ); printf( "%s\n", altcopy( dest, "and long string" ) ); } provide implementation function called altcopy() uses pointer arithmetic copy alternate characters of c-type string destination (i.e. first, third, fifth etc character). answer must not use [] operator access array index. above code output following: dm dm2 lne ee ogr adaral ogsrn and have attempted follows: using namespace std; char* altcopy (char* dest, const char* str) { char* p = dest; const char* q = str; ( int n=0; n<=20; n++ ) { *p = *q; p++; q++; q++; } retur...

Ruby reorder an array based on the contents of a subset array -

i have array ordered hash[:points] original = [{a: "bill", points: 4}, {b: "will", points: 3}, {c: "gill", points: 2}, {d: "pill", points: 1}] i want change order of it's elements based on order of subset array, ordered hash[:points] . subset = [{c: "gill", points: 2}, {b: "will", points: 1}] the subset's elements contained in original. subset's length , order come @ random. may have two, three, or 4 elements, in order. i want incorporate order of subset original array. can done reordering original, or recreating original in correct order. either do. don't want merge them. keys , values in subset not important, order of elements. for example, above subset should produce this. # bill , pill retain original position # gill , swap places per ordering of subset [{a: "bill", points: 4}, {c: "gill", points: 2}, {b: "will", points: 3}, {d: "{pill}", points: 1...

java - Right side of my RichFaces pickList not populating with default values -

i wondering if please help. experiencing challenge. when in backing bean works fine: private string [] testright; private string [] testleft; (with getters , setters) public void initalizeleftrightside2() { this.testleft = new string[5]; this.testright = new string[2]; testleft[0] = "module1"; testleft[1] = "module2"; testleft[2] = "module3"; testleft[3] = "module4"; testleft[4] = "module5"; testright[0] = "module2"; testright[1] = "module4"; } but when module objects right side not populated: private list<modules> allmodules; private list<modules> forselectedrole; public void initalizeleftrightside3(long selectedroleid) { this.allmodules = modrole.getallmodules(); roles therole = modrole.getmodulelistbyroleid(selectedroleid); this.forselectedrole = therole.getmodules...

Notepad++ changing written format of text -

hey guys have bunch of information on 1 notepad jumbled , hoping guys me put , make in form of: a,b,c,d a,b,c,d where a,b,c,d can variables such name,fav food,skin colour,hair colour. or along lines. right these variables in form of: a b <sp> c <sp> d <sp> <sp> (and starts again in same format) the <sp> 's stand space, didn't know how else annotate them comes empty line space... is there way of converting other format? in notepad++ go replace, , set extended mode. first replace \n \n (there whitespace in middle!) , replace lines space commas on same line. then replace \n\n \n remove empty lines left. and replace \n,' with \n` remove leading commas. lastly replace ,\n \n remove trailing commas

r - knitr makes multiple figures instead of adding just lines() to axes -

Image
i have simple rnw file: \documentclass[10pt,a4paper]{article} \usepackage[latin1]{inputenc} \begin{document} <<mychunk, echo=false, cache=false, fig.keep='all'>>= plot(rnorm(100),rnorm(100)) lines(c(-1,1),c(-1,1)) @ \end{document} the r chunk plot(rnorm(100),rnorm(100)) lines(c(-1,1),c(-1,1)) should give 1 figure. instead, output tex \includegraphics[width=\maxwidth]{figure/mychunk1} \includegraphics[width=\maxwidth]{figure/mychunk2} with 2 separate figures , this doesn't happen in instances of plot , lines, depending on arguments, code i've given reproduces problem. should have second figure. you've set fig.keep="all" , , getting expected setting! described in the online documentation , option "keep[s] plots (low-level plot changes may produce new plots)". try instead fig.keep="high" (the default, can leaving out fig.keep argument) or fig.keep="last" , depending on want.

java - Solr SearchComponent get all documents -

i'm writing solr plugin (searchcomponent) , want iterate on documents found query. part of code in process method: // searcher search document solrindexsearcher searcher = rb.req.getsearcher(); // getting list of documents found query doclist docs = rb.getresults().doclist; // return if no results found query if (docs == null || docs.size() == 0) { return; } // iterator documents returned dociterator iterator = docs.iterator(); // iterate on documents , count occurrences (int = 0; < docs.size(); i++) { try { // getting current document id int docid = iterator.nextdoc(); // fetch document searcher document doc = searcher.doc(docid); // stuff } catch (exception e) { logger.error(e.getmessage()); } } for found method can iterate on documents returned i.e. if 1300 documents found query , return 20, iterate on 20 method now. ...

multidimensional array - SSAS - "Count" measure with multiple members -

i new ssas , i'm having trouble "count of rows" measure. i'm doing named queries mysql database , have created 2 logical tables in dsv. first table called "person" , has primary key of "person guid". second called "role" , has primary key of "role guid" , foreign key of "person guid". acting dimension table , has attribute of "role name". what want able select role dimension table , have show me number of people in role, using "count of records" measure person table. problem is, people can hold multiple roles, , way structured in "role" table there separate row each role person might have...in other words, "person guid", how mapped measure group, duplicated many times. this not working in ssas - doesn't seem giving me accurate count. appears considering role of first instance of particular person guid. i know must looking @ wrong way...any offer appreciated. unde...

python - Fast, elegant way to calculate empirical/sample covariogram -

Image
does know method calculate empirical/sample covariogram, if possible in python? this screenshot of book contains definition of covariagram: if understood correctly, given lag/width h, i'm supposed pair of points separated h (or less h), multiply values , each of these points, calculate mean, in case, defined m(x_i). however, according definition of m(x_{i}), if want compute m(x1), need obtain average of values located within distance h x1. looks intensive computation. first of all, understanding correctly? if so, way compute assuming 2 dimensional space? tried code in python (using numpy , pandas), takes couple of seconds , i'm not sure correct, why refrain posting code here. here attempt of naive implementation: from scipy.spatial.distance import pdist, squareform distances = squareform(pdist(np.array(coordinates))) # coordinates nx2 array z = np.array(z) # z values cutoff = np.max(distances)/3.0 # arbitrary cutoff width = cutoff/15.0 widths = np.arange(0, cutof...

Why does my socket connection between two python scripts break if one of them is launched with Popen? -

so have 2 simple python scripts communicate on socket. right both running on same windows pc. here's controller.py: import socket import time import sys subprocess import popen, create_new_console host = '192.168.1.107' # remote host port = 50557 # same port used server s = socket.socket(socket.af_inet, socket.sock_stream) try: s.connect((host, port)) except: popen([sys.executable, 'driver.py'], creationflags=create_new_console) time.sleep(0.2); s.connect((host, port)) s.send(sys.argv[1]) data = s.recv(1024) s.close() print 'received', repr(data) and here's driver.py: import socket host = '' # symbolic name meaning local host port = 50557 # arbitrary non-privileged port s = socket.socket(socket.af_inet, socket.sock_stream) s.bind((host, port)) s.listen(1) while 1: print 'waiting controller connection.' conn, addr =...

imagemagick - Printing a pdf as an image inside of a pdf -

i'm creating web app , using php fpdf script creates , print out pdf. prints out on pdf images uploaded app, no problem. however, needs same thing uploaded pdf , problem lies. how can print pdf image inside of pdf using fpdf? i have heard of imagemagick don't think option because software , don't know run it. you can use fpdi import page of existing pdf document , place fpdf onto newly created page: <?php require_once('fpdf.php'); require_once('fpdi.php'); $pdf = new fpdi(); // load document , total page count $pagecount = $pdf->setsourcefile("the/document/you/want/to/import/a/page/from.pdf"); // import first page $tplidx = $pdf->importpage(1); // add page $pdf->addpage(); // use imported page on x=10, y=10 , width of 90 $pdf->usetemplate($tplidx, 10, 10, 90); // output pdf document $pdf->output();

objective c - How do I rotate an image drawn directly to an NSView with DrawRect in an OSX app? -

i'm writing osx app in xcode using objective-c. have window, nsview inside it, , nsview supposed use data nsmutablearray containing nsnumbers draw corresponding images on grid such images drawn @ 0,0; 32,0; 64,0 . . . 0,32; 32,32; etc. accordingly array's count grid's w*h, in case 21*21 or 441. you left click "place" image, means updating array based on clicked , calling setneedsdisplay:yes redraws reflect updated array. far, can draw images based on array properly. when right click, though, supposed rotate image in particular grid slot amount. problem having here figuring out how draw rotated images, in proper locations. should rotate center points, relative coordinates of 16,16 (all images 32x32 pixels in size). is, code is: - (void)drawrect:(nsrect)dirtyrect { [super drawrect:dirtyrect]; //black background [[nscolor blackcolor] setfill]; nsrectfill(dirtyrect); // drawing code here. nsrect recttodraw = cgrectmake(0,0,32,32); ...

c# - what type should i specify for lambda expression in method call -

see small code , tell me type should use in method call method((i => i>7)); public void method(which type should specify here?) { // stuff } it seems type func<int, bool> . also, additional parenthesis around lambda useless.

php - Conditionally Strip Characters From String -

i trying strip characters ['-] string, not when string starts "'t'. code @ present: $name = "'-'-''t van t der reidjen--'-'-"; $name = preg_replace( '~(^|\s)[-\']+(?!t )(\s|$)~', ' ', $name ); desired results: "'-'-''t van t der reidjen--'-'-" => "'t van t der reidjen" "van 't der reidjen--'-'-" => "van t der reidjen" "-van - der -'- reidjen-" => "van der reidjen" i.e. leave "'t" @ beginning of string, if prefixed number of [-'] characters, if "'t" found anywhere other beginning of string "'" removed. how this: /([-]+)|((?!'t)['])/g online demo the expresion above separated - , ' since tricky 1 ' using ahead excluded 't text. (?!'t) : negative ahead - excludes 't matches. note : these charac...

Apache is not serving static files from Django app -

i don't know what's wrong in virtualhost django project question no matter modification on file stills output same in error log apache , not load css or js files, can see apache looking static , media file in root web folder: /var/www [fri may 30 00:58:08 2014] [error] [client 192.168.1.145] file not exist: /var/www/static, referer: http://192.168.1.143/dgp/login/ i set virtual host file follows: wsgipythonpath /var/www/dgp_python2_7/bin/python2.7:/var/www/dgp_python2_7/lib/python2.7/site-packages wsgiscriptalias /dgp /var/www/dgp/dgp/dgp/wsgi.py <virtualhost 127.0.0.1:80> servername www.dgp.dev serveralias dgp.dev aliasmatch ^/([^/]*\.css) /var/www/dgp/dgp/static/$1 alias /media/ /var/www/dgp/dgp/media/ alias /static/ /var/www/dgp/dgp/static/ alias /images/ /var/www/dgp/dgp/images/ <directory /var/www/dgp/dgp/static/> order deny,allow allow </directory> <directory /var/www/dgp/dg...

Python3x - Write a python script to run other python scripts? -

i have number of python scripts automate using python's datetime , schedule module. they numerous consider breaking apart , adding 1 large file. what easiest way write python script open , run these other python scripts? i have browsed similar questions none offered concrete answer find. help. a minimally demonstrative example in file called "child.py", write file current directory: with open('test', 'w') f: f.write('hello world') then, in file called "parent.py", execute "child.py" script: import subprocess subprocess.call(['python', 'child.py']) now, command line, can type (assuming both "parent.py" , "child.py" in current directory): python parent.py in next instant, should see file called "test" in current directory. open up. see? well, hello world of course! the above example makes child of current process (meaning inherits environment ...

Why do Ruby procs/blocks with splat arguments behave differently than methods and lambdas? -

why ruby (2.0) procs/blocks splat arguments behave differently methods , lambdas? def foo (ids, *args) p ids end foo([1,2,3]) # => [1, 2, 3] bar = lambda |ids, *args| p ids end bar.call([1,2,3]) # => [1, 2, 3] baz = proc |ids, *args| p ids end baz.call([1,2,3]) # => 1 def qux (ids, *args) yield ids, *args end qux([1,2,3]) { |ids, *args| p ids } # => 1 here's confirmation of behavior, without explanation: http://makandracards.com/makandra/20641-careful-when-calling-a-ruby-block-with-an-array there 2 types of proc objects: lambda handles argument list in same way normal method, , proc use "tricks" ( proc#lambda? ). proc splat array if it's argument, ignore arguments, assign nil missing ones. can partially mimic proc behavior lambda using destructuring: ->((x, y)) { [x, y] }[1] #=> [1, nil] ->((x, y)) { [x, y] }[[1, 2]] #=> [1, 2] ->((x, y)) { [x, y] }[[1, 2, 3]] #=> [1, 2] ->((x, y)) { [x, ...

Magento Custom Category for New Products -

help: create custom category new products setted new date , new date. write code in custom layout update: <reference name="content"> <block type="catalog/product_new" name="product_new" template="catalog/product/list.phtml"></block> </reference> i see displaying new products there problems: there note message: "there no products matching selection." new products populated in category toolbar sort dropdown when select attributes no changes such sort name or sort price please note create new.php located in core local folder , there sort function ->addattributetosort('news_from_date', 'desc') try below code ,i hope show sort order <reference name="content"> <blocktype="catalog/product_new" name="product_new" template="catalog/product/list.phtml"> <block type="catalog/product_list_t...

java - How to Fetch Owner Mobile number from SMS Inbox/Sent -

i have tried retrieve information sms inbox/outbox of device. mobile number i.e. sender's mobile number not seem stored. trying number can capture mobile number outbox , allow user use register on app, considering near accurate mobile number user using on device. don't have type mobile in app registration. please let me know if there way find mobile number sms inbox/sent code here: public void readsms (activity mainactivity) { uri insmsuri = uri.parse ("content://sms/inbox"); system.out.println ( "the uri :: " + insmsuri); cursor c = mainactivity.getcontentresolver().query(insmsuri, null, null, null, "date desc"); if (c!= null) { stringbuilder sb = new stringbuilder (); while (c.movetonext ()) { system.out.println ("content:" + c.getstring (c.getcolumnindex ("body"))); for(int i=0; i<c.getcolumncount();i++) { system.out.prin...