Posts

Showing posts from April, 2012

android - Picasso fails to decode some images: skia decode returned false -

update: seems question boils down images correctly decoded, while don't. if convert non-working jpeg s png s, work. none of images taken directly jpeg s either nikon d5000 , panasonic lumix or sony experia phone can decoded. i using picasso fill listview in android app. am, however, running error --- decoder->decode returned false images use, works fine other pictures run across around web. therefore, believe has images, not sure. error arises in skia library used picasso (as far know). for example, this image works fine, while this not, , latter need work. other pictures need use taken same camera , edited gimp in same way, resulting in images first one, none of them work. hence, suspect has images rather decoder. a few questions pops up: is possible metadata can in process? metadata similar in pictures. could encoded images makes encoder go crazy? if so, , how can investigate it? end of file missing or anything? is possible enable more debugging ,

android - ImageButton Based On If Condition -

i have implemented imagebutton changes images based on 3 conditions, 1 of condition set follows: if (local().equals(remote)) { ib.setimageresource(r.drawable.sync_green); } else { ib.setimageresource(r.drawable.sync_red); } this works after few seconds app crashes following log: 06-20 11:58:27.734: e/androidruntime(2278): fatal exception: thread-160 06-20 11:58:27.734: e/androidruntime(2278): process: com.twostarii.asyncdownload, pid: 2278 06-20 11:58:27.734: e/androidruntime(2278): android.view.viewrootimpl$calledfromwrongthreadexception: original thread created view hierarchy can touch views. 06-20 11:58:27.734: e/androidruntime(2278): @ android.view.viewrootimpl.checkthread(viewrootimpl.java:6247) 06-20 11:58:27.734: e/androidruntime(2278): @ android.view.viewrootimpl.invalidatechildinparent(viewrootimpl.java:902) 06-20 11:58:27.734: e/androidruntime(2278): @ android.view.viewgroup.invalidatechild(viewgroup.java:4637) 06-20 11:58:27.734: e/androidrunti

html - Custom navbar color when hovering under Bootstrap -

i fail find right css syntax custom navbar links when hovering. navbar follows: <ul class="nav navbar-nav navbar-right"> <li><%= link_to "home", root_path %></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> account | <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><%= link_to "user", current_user %></li> <li><%= link_to "update", edit_user_path(current_user) %></li> </ul> <li><%= link_to "logout", logout_path, method: "delete" %></li> i manage correct hovering effect on dropdown menu with .dropdown:hover { background:#3b3535; color: #ece6e6; } i want have same effect on links "home" , "logout&q

Django template - How to match model datefield with a date in date generator? -

Image
in models.py task can have multiple employer use manytomanyfield in views.py got date generator - return range of 2 weeks current day. so here template <table> <thead> <tr> <th>{% trans 'employer_id' %}</th> {% in date_range %} <th>{{ }}</th> {% endfor %} </tr> </thead> <tbody> {% employer in employers %} <tr> <td>{{ employer.employer_id }}</td> {% t in employer.task_set.all %} <td>{{ t }}</td> {% empty %} <td>0</td> {% endfor %} </tr> {% endfor %} </tbody> </table> what need when create task , assign employers, should show me in html table start_date of task of each em

compact framework - Padarn OpennetCF Socket Connection is Closed -

i'm evaluating padarn project , i'm trying implement simple example. need padarn win ce 5.0 or 6.0 web project , bought license configuration part : static void main(string[] args) { m_padarnserver = new webserver(); m_padarnserver.start(); } and render function: protected override void render(htmltextwriter writer) { if (response.isclientconnected) { response.write("ok"); response.flush(); writer.flush(); } } and config file : <?xml version="1.0" encoding="utf-8" ?> <configuration> <configsections> <section name="webserver" type="opennetcf.web.configuration.serverconfigurationhandler, opennetcf.web" /> <section name ="httpruntime" type ="opennetcf.web.configuration.httpruntimeconfigurationhandler, opennetcf.web"/> &l

c - One wire protocol in SIM800 through bit banging -

is possible implement one wire protocol in sim800 through bit banging ? time required change direction of pin (as input or output) 1.5 microsecond , time required change state of pin (as low or high) 1.5 microsecond. the dallas/maxim 1-wire(tm) protocol self-clocking; deliberately designed make easy implement in way. using hardware timer idea - removing deal of software overhead, low-precision rc oscillator accurate enough. 1-wire(tm) self-clocking assume timings suggest minimum timings, not required timing; protocol has wide tolerances actual bit timing, , inter-bit timing merely requires line high >1us, may length. needs long enough able detect definite edge - on input-capture timer or edge triggered interrupt example - software poll line, if application needs other work done @ same time, 1us pulse may missed. it not clear me definition of timings suggest are, if refer duration of edge, 1.5us suggest not software issue - down slew-rate of i/o pin largely f

ipad - An app that just reads a bar code -

i want develop app reads bar code. don't want go off website or shop or anything. read it! must run on ipad air. have seen zbar , few other suggestions want sure 1 should use/how start. can has done type of thing please? start sample code here describes ios native code detection , usage: http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx when you've progressed needing doesn't accomplish, have vocabulary better describe need, you've tried, , how has failed you.

python - How monkey_patch(time=True) affects eventlet.spawn? -

normally, when using greenthread, can write code as: def myfun(): print "in func" eventlet.spawn(myfunc) eventlet.sleep(0) #then myfunc() triggered thread. but after use money_patch(time=true) , can change code as: eventlet.monkey_patch(time=true) eventlet.spawn(myfunc) # myfunc called why dont need call eventlet.sleep(0) time? and after write own sleep function: def my_sleep(seconds): print "oh, god, own..." and set sleep attr of built-in time module my_sleep func, find my_sleep func called many times lot of outputs. can see 1 debug-thread in eclipse, did not call my_sleep func. so, conclusion is, sleep function called continually default, , think authors of eventlet know this, developed monkey_patch() function. rigth? # according answer of @temoto, cpython cannot reproduce same result. thinks should add message introduce how find interesting thing.(why did not add message @ first time, cause input many words in not easy, , eng

olap cube - MDX dimension usage in CASE statment -

i want check number of month , according divide number. problem code defaults else statement. can spot issue? thanks. create member currentcube.[measures].[sbbd] case [date].[calendar month number of year] when 2 [measures].[sb]/28 when 4 [measures].[sb]/30 when 6 [measures].[sb]/30 when 9 [measures].[sb]/30 when 11 [measures].[sb]/30 else [measures].[sb]/31 end, format_string = "standard", visible = 1 , associated_measure_group = 'lb'; try comparing member's value in condition of case statement. comparing member [date].[calendar month number of year] not seen numeric expression in mdx , , comparing numeric expression (2, 4,...). maybe following works better: create member currentcube.[measures].[sbbd] case [date].[calendar month number of year].currentmember.member_value when 2 [measures].[sb]/28 when 4 [measures].[sb]/30 when 6 [measures].[sb]/3

c++ - Compile Curl Visual Studio - unresolved external symbol -

i need use static library of libcurl , found this github rep generate libraries. now, i'm trying compile simple piece of code use curl using static library, libcurl_a.lib, without success. at first, miss -dcurl_staticlib flag , got undefined reference errors: undefined reference `curl_easy_init' undefined reference `curl_easy_setopt' undefined reference `curl_easy_setopt' undefined reference `curl_easy_perform' undefined reference `curl_easy_strerror' undefined reference `curl_easy_cleanup' the flag solve it, got these ones: unresolved external symbol __imp__strtoll unresolved external symbol __imp__strtoll unresolved external symbol __imp__strtoll unresolved external symbol __imp__strtoll referenced in function _curl_ftp_parselist unresolved external symbol __imp__strtoll unresolved external symbol __imp__strtoll unresolved external symbol __imp__strtoll unresolved external symbol __imp__strtoll unresolved external symbol __imp__gettickcount6

video.js - How do you get the list of existing markers on the videojs-markers plugin? -

i feel silly question apologize, have little experience javascripting in general. i have application want allow users annotate (mark) video, using https://github.com/spchuang/videojs-markers plugin videojs, , looks need. but after allowing user add markers, want record them on database, need able raw markers structure (i.e. time , text each mark). the code below shows have. recordmarks function having trouble with. want marks in order me post them on database via ajax //load marker plugin myplayer.markers({ ... markers: [ ] }); function marktime() { currenttime = gettime('mark'); myplayer.markers.add([{ time: currenttime, text: currenttime, overlaytext: 'tag', class: 'special-blue' }]); console.log('marked: ' + currenttime) } function recordmarks() { console.log(myplayer.markers.markers); // shows undefined // try way for(var =0; < myplayer.markers.length; i++)

RVM Ruby on Rails source ~/.rvm/scripts/rvm no such location -

i trying install ruby on rails rvm on ubuntu, when run command: source ~/.rvm/scripts/rvm i error: bash: /home/user/.rvm/scripts/rvm: no such file or directory i tried to: gpg --keyserver hkp://keys.gnupg.net --recv-keys d39dc0e3 and [[ -s "$home/.rvm/scripts/rvm" ]] && . "$home/.rvm/scripts/rvm" it didn't help. ideas? please, try: $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409b6b1796c275462a1703113804bb82d39dc0e3 and $\curl -ssl https://get.rvm.io | bash -s stable from http://rvm.io/

c# - Unable to do consecutive database inserts -

i'm attempting 2 sql inserts consecutively 2 different tables. the first table insert works fine. uses select scope_identity() pull index number store in variable registree_index . works ok. i try insert registree_index , other variables second table. not write second table @ all. no error message either. initially thought error had reusing old query , connection string variables, created new ones. has not helped. does have thoughts on this? code follows... private void writetodatabase() { guid newguid = guid.newguid(); string yearstring = datetime.now.year.tostring(); string twodigityear = yearstring.substring(yearstring.length-2); string dateandguid = twodigityear + "-" + datetime.now.month.tostring() + "-" + datetime.now.day.tostring() + "-" + datetime.now.hour.tostring() + "-" + datetime.now.minute.tostring() + "-" + datetime.now.second.tostring() + "-" + newguid; string connec

haskell - Writing lazy curried in scala with multiple parameters -

i'm writing code game exercise learn scala after getting acquainted haskell. started adt follows: sealed class circle(x: double, y: double, r: double) case class playercircle (x: double, y: double, r: double) extends circle(x, y, r) case class aicircle (x: double, y: double, r: double) extends circle(x, y, r) i'm trying write lazy, curried val follows (in haskell pseudocode): addtoplayer :: playercircle -> circle -> playercircle addtoplayer (playercircle px py pr) (aicircle _ _ cr) = playercircle px py (pr + cr) addtoplayer player _ = player i have following: def addtoplayer (wcircle : circle) : playercircle = wcircle match { case aicircle (_, _, wr) => copy(this.x, this.y, this.r + wr) case _ => } what necessary make function curried , lazy? edit: i've googled answer haven't found article of use please me one. here's curried function example: def addtoplayer(c: circle, p: player) = ... actual code... def addtoplaye

c# - EF LINQ - Return entities that contain an entire collection -

i trying troubleshoot following linq query: public jsonresult searchnodesbytags(string[] tags) { var nodes = _dbcontext.nodes. where(n => n.tags.all(t => tags.contains(t.displayname))) .select(n => new {n.nodenativeid, n.nodename, n.nodeclass.classname}) .tolist(); return json(nodes); } the query returning single node not associated tag. want do, return nodes have tags. .where(n => n.tags.all(t => tags.contains(t.displayname))) the way constructed, you're going end node s every tag in node.tags has name in tags whitelist, includes node s no tags. you might want use answer here on subsets: _dbcontext.nodes .where(n => !tags.except(n.tags.select(t => t.displayname)).any()) .select(... set1.except(set2) contains elements of set1 aren't in set2 !set1.except(set2).any() == true if set2 includes every element of set1 edit it pointed out in comments using e

mysql - Insert selected value to table from another table multiple times -

i have sql table name 'old' one: old_col1 old_col2 title news post blablabla1 title weather post blablabla2 and want insert table 'new' has columns: title , post the values of old_col2 table old. table new should this: title post news blablabla1 weather blablabla2 i tried fill column title query: insert new (title) select old_col1 old old_col1 = 'title' you can try below. see example http://sqlfiddle.com/#!9/14841/4 select a.old_col2, b.old_col2 old join old b on a.old_col2 <> b.old_col2;

regex - Python: 'q)+' is not recognized as an internal or external command -

python newbie here. i have program named zeroormore.py it reads regular expression (regex) stdin. i invoke program this: python zeroormode.py (ab)*(p|q)+ that results in error message: 'q)+' not recognized internal or external command, operable program or batch file. i discovered if enclose regex in double quotes: python zeroormode.py "(ab)*(p|q)+" then there no error. is there way accomplish without wrapping regex in double quotes? here's how program inputs regex: regex = sys.argv[1] this isn't python; it's cmd. regex you're giving python being interpreted command prompt first. pipe ( | ) batch command piping input following program. basically, cmd reading command line so: python zeroormode.py (ab)*(p | q)+ it's trying take result of running zeroormode.py (i think meant more?) (ab)*(p , piping output (nonexistent) program q)+ . there isn't of solution this, unfortunately. escape pipe so: pytho

sql - rewrite query to remove inner query in tsql to optimize -

i trying optimize following query, according execution plan, sort in inner query has high cost. following query re-written easy read , performs well? select cl.col1, cl.col2 claim cl (nolock) inner join member mem (nolock) on mem.memid=cl.memid left join payvacation pv (nolock) on cl.claimid = pv.claimid , pv.paymentid = (select top 1 payvacation.paymentid payvacation (nolock), payment (nolock) payvoucher.claimid = cl.claimid , payvacation.paymentid = payment.paymentid order payment.paystatusdate desc) ;with cte ( select cl.col1, cl.col2, cl.claimid claim cl (nolock) inner join member mem (nolock) on mem.memid=cl.memid left join payvacation pv (nolock) on cl.claimid = pv.claimid ), cte2 ( select payvacation.paymentid , payvacation.claimid ,row_number() on (partition payvacation.cl

visual studio 2013 - Install VM Virtual Box as Windows Phone Emulator -

i have vm virtual box running windows phone emulator. how visual studio 2013 community edition use test windows phone app? apparently 1 supposed use device emulator manager register emulators , ought accessible tools menu not there.

javascript - Using `react-bootstrap` with `npm` -

i want creat project using npm , , want use react-bootstrap inside it. have package.json following dependencies. { "name": "simple-webapp", "version": "0.0.1", "description": "", "scripts": { "build": "gulp build", "watch": "gulp watch --color", "test": "echo \"this project doesn't have tests.\" && exit 0" }, "author": "", "license": "isc", "devdependencies": { "gulp": "3.8.11", "qwest": "^1.5.12", "react": "0.13.2", "syrup": "0.1.14", "bootstrap": "3.3.5", "react-bootstrap": "0.13.3", "react-router": "0.13.3" } } when run npm install get: npm warn package.json simple-webapp@0.0.1

Simple Chrome Extension : Open an url in a new tab -

i'm looking create "new tab" extension panda or product hunt extension : user can open new tab website inside, hidden url. i've generated package awesome extensionizr , here manifest.json : manifest.json { "name": "my app", "version": "0.0.1", "manifest_version": 2, "description": "my awesome app", "homepage_url": "http://myapp.com", "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", "128": "icons/icon128.png" }, "default_locale": "en", "background": { "scripts": [ "src/bg/background.js" ], "persistent": false }, "permissions": [ "tabs", "http://myapp.com/*" ] } my background.js come this answer , problem seems similar. background.j

java - What are the conditions for Serializable? -

suppose have java class, myclass , not inherited class. myclass implements serializable . can myclass serializable no other conditions? depend on objects myclass contain, , if these objects serializable themselves? for example in class below, if mappedoodle2 not implement serializable , exception when mappedoodle serialized? import java.io.serializable; public class mappedoodle implements serializable { private static final long serialversionuid = -1760231235147491826l; private string text; private int value; private mappedoodle2 mm = new mappedoodle2(); public mappedoodle(string text, int value) { this.text = text; this.value = value; } public string gettext() { return text; } public int getvalue() { return value; } @override public string tostring() { return text + ", " + value; } } to serialize object, i'm assuming using objectoutputstream . here's

excel - How to move to next blank cell? -

i have data on multiple sheets in workbook want copied 1 sheet in same workbook. when run macro, start deleting current data in "ipage data export" sheet , replacing data other sheets. i want process occur 1 column @ time since may not bring on everything. right trying learn how 1 column. i able copy of contents of column 1 sheet, when moves next sheet, overwrites existing data. in end, 1 sheets worth of data copied. here 4 problems: how make clear data on sheet before running routine? how can make start each copy function @ bottom of row (i.e. after last cell value)? have tried many of suggestions on , other boards without success. admit not experienced in this. how can make copy particular column (currently seems default a. how can concatenate multiple columns during paste function? i.e. if want insert: a2&", "b2 instead of a2 sub combinedata() dim sht worksheet each sht in activeworkbook.worksheets

c++ - what is the meaning of **ptr in c -

this question has answer here: in c, variable declaration 2 asterisks (**) mean? 5 answers i know *ptr pointer variable called ptr does **ptr mean pointer pointer? if true, meaning of pointer pointer? any pointers (pun intended) appreciated. it depends on context. in declaration, x **ptr declares object pointer pointer x . outside of declaration, **ptr dereferences both pointers, yielding value. remember pointer object holds address of object. pointer pointer that: object holds address of object, happens pointer.

python - How to build custom pandas.tseries.offsets class? -

Image
i want find way build custom pandas.tseries.offsets class @ 1 second frequency trading hours. main requirement here time offset object smart enough know next second of '2015-06-18 16:00:00' '2015-06-19 09:30:00 or 09:30:01', , time delta computed these 2 time stamps 1s (custom offset 1s, similar bday(1) business day frequency) instead of duration of closing hours. the reason when plotting pd.series intraday data across few trading days, see simulated example below, there lots of 'step line' (linear interpolation) between close , next day open prices represent time duration of closing hours. there way rid of this? i've @ source codes of pandas.tseries.offsets , find pd.tseries.offsets.businesshour , pd.tseries.offsets.businessmixin may don't know how use those. import pandas pd import numpy np pandas.tseries.holiday import usfederalholidaycalendar pandas.tseries.offsets import custombusinessday # set 'constant' object shared codes i

javascript - MutationObserver not working -

consider following code: var mutationobserver = window.mutationobserver || window.webkitmutationobserver || window.mozmutationobserver; var observer = new mutationobserver(function(mutations) { mutations.foreach(function(mutation) { console.log(mutation.target.nodename); }); }); observer.observe(document, { attributes: true, childlist: true, characterdata: true }); <div> <ol contenteditable oninput=""> <li>press enter</li> </ol> </div> which slight modification of this . interacting jsbin version page not produce log. wrong? notice if substitute line observer.observe(document, { with observer.observe(document.queryselector('ol'), { the script turns on working... it doesn't appear work because not mutating observing. neither changing attributes ( attributes: true ) of document node (which understandable, since document doesn't have attrib

xcode6 - Xcode build post script for build failed -

how can detect build failed status in post action script xcode edit scheme section different targets? i planning send sms me if build failed in ci. thanks in advance. post build scripts (specified in xcode project file) executed if build passes, not when fails. if want handle case should use continuous integration solution (ex: https://fastlane.tools/ ) or service ( https://bitrise.io/ - cto here), or write script calls xcode's command line tool xcodebuild returns error code if can't perform given action (build, archive, test, ...), can handle case way want in script.

Combine multiple NetCDF files into timeseries multidimensional array python -

i using data multiple netcdf files (in folder on computer). each file holds data entire usa, time period of 5 years. locations referenced based on index of x , y coordinate. trying create time series multiple locations(grid cells), compiling 5 year periods 20 year period (this combining 4 files). right able extract data files 1 location , compile array using numpy append. however, extract data multiple locations, placing matrix rows locations , columns contain time series precipitation data. think have create list or dictionary, not sure how allocate data list/dictionary within loop. i new python , netcdf, forgive me if easy solution. have been using code guide, haven't figured out how format i'd do: python reading multiple netcdf rainfall files of variable size here code: import glob netcdf4 import dataset import numpy np # define x & y index grid cell of interest # pittsburgh 37,89 yindex = 37 #first number xindex = 89 #second number # path path = '

c++ - How to check the state of signal in Qt? -

this question has answer here: managing asynchronous communication: how examine response received in thread 1 answer the following win32 code checks if event signaled or not without waiting on it. handle = createevent(null, true, false, null); bool signaled = waitforsingleobjectex(handle, 0, true) != wait_timeout; what equivalent in qt? what trying accomplish: i have 2 threads listener , sender (which sends commands). when user clicks button, operations sends series of commands need verify response first command received (and examine it) before send following command. thought synchronize them around mutex or something..the receiver signal mutex when data received , send can wait on it. looking convenient way in qt accomplish this. using qtcpserver derived class , listen() method listen on port. there none, because signals stateless concept. in qt,

html - JavaScript objects: 'addEventListener is not a function' -

i create array of javascript objects called elements , loop through in order draw every 1 on canvas hooking few event handlers it. however, error stating 'uncaught typeerror: elements[i].addeventlistener not function' here code: $(document).ready(ondocumentready); function ondocumentready() { var color_normal = '#005a84'; var color_selected = '#00f2f2'; var color_mouseover = '#5ba621'; var canvas = document.getelementbyid("mapcanvas"); var context = canvas.getcontext('2d'); var data = @html.raw(json.encode(model.dieprintlist)); var elem = canvas, left = elem.offsetleft, top = elem.offsettop, context = elem.getcontext('2d'), elements = []; (var = 0; < data.length; i++) { elements.push({ color: '#0489b1', width: 15, height: 15, row: data[i].row, col: data[i].col,

javascript - Unable to setRawMode in a nodejs script -

initially tried set raw mode using tty.setrawmode(true) log told me deprecated , should using process.stdin.setrawmode(true) command giving me typeerror: object #<socket> has no method 'setrawmode' cant seem find else in way of raw mode documentation suggests other apporoaches know how working? i using version 0.10.25 so turns out nodemon uses child_process, because of writing process.stdin.setrawmode(true); in script run nodemon result in typeerror: object #<socket> has no method 'setrawmode' .

javascript - Adding multiple divs or renders in ReactJs -

i'm having trouble in wanting create multiples of same html render in class. example, have div might this [header goes here, input field] [dropdown] [textarea] [submit] [add field] on add field, clone view , able add many again. here's have far: var updateform = react.createclass({ handlesubmit : function(e) { e.preventdefault(); var title = react.finddomnode(this.refs.title).value.trim(); var date = react.finddomnode(this.refs.date).value.trim(); var body = react.finddomnode(this.refs.body).value.trim(); if(!title||!date || !body ) { return; } this.props.onsubmit({title:title, date : date, body : body}); react.finddomnode(this.refs.title).value = ''; react.finddomnode(this.refs.date).value = ''; react.finddomnode(this.refs.body).value = ''; //react.finddomnode(this.refs.sub).value = ''; }, render: function() { return( <div id

python - Multi Threading Makes Process Slower -

this question has answer here: python multi-threading slower serial? 3 answers i have following task make faster via multi threading (python3). import threading, time q = [] def fill_list(): global q while true: q.append(1) if len(q) >= 1000000000: return the first main not utilize multithreading: t1 = time.clock() fill_list() tend = time.clock() - t1 print(tend) and results in 145 seconds of run time. the second invokes 2 threads: t1 = time.clock() thread1 = threading.thread(target=fill_list, args=()) thread2 = threading.thread(target=fill_list, args=()) thread1.start() thread2.start() thread1.join() thread2.join() tend = time.clock() - t1 print(tend) this takes 152 seconds complete. finally, added third thread. t1 = time.clock() thread1 = threading.thread(target=fill_list, args=()) thread2 = threading.th

html - Prevent jQuery slideUp jump with margins -

i have overlay set via top:50% left:50% and calculated margin-top , margin-left position in middle of screen. i want slide rid of it, starts going crazy because of margins. check out fiddle has same results. can do? can't rid of margins unless there's better way position in middle of screen. https://jsfiddle.net/edjrdy61/1/ if want prevent jump margin, must force margin since jquery slideup() change margin @ runtime. try this: .foo { width:100px; height:100px; background:green; margin-top:100px !important; } but if want better way align middle-center of screen, use absolute or fixed position. example: .foo { width:100px; height:100px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background:green; }

sas - What's wrong with these macro parameters? -

i have following simplified version of piece of code working on: %macro test(var); %if &var = 'sub prime' %then %do; %let var2 = 'sub_prime'; %put &var2; %end; %mend; %test(sub%str( )prime); basically point of if var = 'sub prime' var2 should = 'sub_prime'. appears though var not equal 'sub prime'. can tell me doing wrong? thanks macro variables not use quotations. %macro test(var); %if &var = %str(sub prime) %then %do; %let var2 = sub_prime; %put &=var2; %end; %mend; %test(sub%str( )prime); you'd better off using %str around whole thing, though, rather inserting %str in space. %test(%str(sub prime));

What is the best way to configure route restriction in PHP Laravel 5? -

i'm new laravel 5 middleware - , added new user type == dev application. need set route restriction user type - in term of can/can't access. so create devmiddleware.php <?php namespace app\http\middleware; use app\article; use closure, view ; use illuminate\contracts\auth\guard; class devmiddleware { /** * guard implementation. * * @var guard */ protected $auth; /** * create new filter instance. * * @param guard $auth * @return void */ public function __construct(guard $auth) { $this->auth = $auth; } /** * handle incoming request. * * @param \illuminate\http\request $request * @param \closure $next * @return mixed */ public function handle($request, closure $next) { if ($this->auth->getuser()->type !== "dev") { return view::make('errors.404'); } return $next($request)

Catching an Exception and rethrowing in C# - can it keep its type? -

we have business-critical bit of legacy code, , methods relatively large , code mess. without test framework , being critical our debugging abilities limited. logging messages not useful - "object not set instance of object"... somewhere in 500 lines of code call other methods. because method body 1 big try/catch specific exceptions being caught. i want propose address better error logging want minimise impact on method. need carry on normal, because business critical. such, people scared touch need check understanding before put idea forward. say, cannot make change , test myself without writing test harness. don't have time due firefighting, , being last thing on friday. i think way insert smaller try/catch blocks inside method body catch exceptions, log useful information, rethrow specific catch handlers below. public int somefunc() { try { // many lines of code // want wrap call gives problems try { brittl

Ruby on Rails Mongodb Mongoid virtual memory usage -

i use ruby on rails application mongodb , mongoid process data. during run time application executes millions of queries , keep terminal window rails server running open watch processes. after program finish running consumption of memory using terminal consuming 13gb. if start program run again - consumption of memory keep grow , @ end 26gb. tried same in production without using terminal , free virtual memory dropped 0. coming normal after closing terminal in development or rebooting linux instance in production. guessing memory used mongodb. question - how make application or mongodb reset memory automatically each time after program finish run without closing terminal or rebooting linux instance? or how set mongodb not use memory?

html - responsive images max-width property in newsletter email -

i designed responsive email several elements, each 1 main image. to prevent images breaks in iphone resolution , higher, have: img { max-width: 320px !important; height: auto !important; } but then, images smaller 320px scale width. fixed with: img { max-width: 100% !important; width: auto !important; height: auto !important; } this works main images, business logo resizes 100% of parent container. how best of each solution? html coding emails pain see chart: https://www.campaignmonitor.com/css/ (you might have scroll down page, it's there) there little no consistency between email clients recognize. recommend coding simple page 'squishes' nicely.

Ruby Net::Http split write and read operation for non-blocking -

i'm new ruby , i'm looking @ using net::http class post data , read in response once i'm ready it. ideally i'd able split code 2 functions, 1 connects , writes request, , second called reading response. is possible without third-party libraries, or using sockets? checking ruby docs sounds should do-able.

javascript - addThis smart api layer add a link -

Image
i add new button link custom url on addthis slidebar generated using addthis smart layer api (you can have @ documentation here ) i add custom service link precise page. possible? here sample of code use generate side bar. addthis.layers({ 'theme': 'transparent', 'share': { 'position': 'left', 'services': 'facebook,twitter,google_plusone_share,pinterest_share,print,more' } }); is possible? although it's not particularly helpful hear, don't think can accomplished addthis smartlayers api @ time. may have found differently though, in case i'm curious hear how figured out it. after perusing docs , playing solid amount of time can't figure out way insert new option services on of layers ( share , follow , what's next , or recommendation layers). way think adding service of smartlayers work submit addthis officially approved. on bottom of this page can submi