Posts

Showing posts from September, 2015

linear regression - Trying to get confidence/prediction intervals with `predict.lm` in R, but I keep getting an error regarding my dichotomous variable -

i have dataset looks this: time size type 1 22 151 0 2 31 92 0 3 26 175 0 4 35 31 0 5 27 104 0 6 5 277 0 7 17 210 0 8 24 120 0 9 9 290 0 10 21 238 0 11 33 164 1 12 20 272 1 13 16 295 1 14 43 68 1 15 36 85 1 16 26 224 1 17 25 166 1 18 18 305 1 19 35 124 1 20 19 246 1 my aim simple: run regression , confidence/prediction intervals. i run regression so: fit.lm1<-lm(time~size+type,data=project3) i want 95% confidence intervals , 95% prediction intervals mean time when size equal 200. want cis/pis type = 0 , type = 1. code is: new_val <- data.frame(size= c(200,200),type=c(1,0)) ci<-predict(fit.lm1,newdata=new_val,interval="confidence") pi<-predict(fit.lm1,newdata=new_val,interval="prediction") i following errors: error: variable 'type' fitted type "factor" type "numeric"

orchardcms - change base url in local copy in Orchard CMS -

i want copy website (orchard 1.7.2.0) localhost, test things before on live site. ik copied database , de web directory , configured iis. in orchards database changed base url in settings_sitesettings2partrecord table. changed database connection in settings.txt now when enter new base url in browser redirected original url. how can prevent this? can't find other reference original url. thanks in advance answer. i found out went wrong. there rewrite in database originial url (for removing www in url). removed , works.

python - More Issues with overlapping labels in Tkinter -

i having problem tkinter. issue follows. i retrieve information database. wish print out based off few user selections. want print out columns a, b, c want print out columns, a, b, c, d want print out columns a, b, d, e also, when query, not know ahead of time how many results have. queries give 1. give 200. print them, this... while x < results.num_rows() : result = results.fetch_row() author = result[0][0] title = result[0][1] conference = result[0][2] year = result[0][3] location = result[0][4] label(root, text=title).grid(row=startrow,column=0,columnspan=5,sticky=w) label(root,text=author).grid(row=startrow,column=6,columnspan=1,sticky=w) label(root,text=year).grid(row=startrow,column=7,columnspan=1,sticky=w) label(root,text=conference).grid(row=startrow,column=8,columnspan=1,sticky=w)

Extract Sender IP's from emails in an Outlook (2010) Folder -

to clear, want extract sender ip's group of emails without going file | properties on every single one. there great many go through. output text file fine. i wondering if possible? perhaps there's app that! thanks time. is programming question? need extract pr_transport_message_headers property (dasl name http://schemas.microsoft.com/mapi/proptag/0x007d001f ) using mailitem.propertyaccessor.getproperty , parse data explicitly in code. ip address not guaranteed there of course.

Add an .egg to the python path in osx -

i'm working pycharm , set remote debugging pydev. ready except when want debug tells me message in pycharm console: warning: wrong debugger version. use pycharm-debugger.egg pycharm installation folder. so i'm working in virtualenv python logged on the virtualenv , set python path .egg (i copied .egg documents make easier). pythonpath="$pythonpath:./documents/pycharm-debug.egg" or pythonpath="./documents/pycharm-debug.egg:$pythonpath" this didn't work, tried other method append sys.path location of .egg didn't work either. what doing wrong? thanks in advance edit: forgot mention i'm on osx edit: ok sorry that, misunderstood. so need add path environment variable, sorry. using bash script that, this: pythonenv.sh #!/bin/bash export pythonpath="$pythonpath:./documents/pycharm-debug.egg" then call script this: source pythonenv.sh at point got env variable in shell, remember after close shell

python - can't seem to get an output from my class -

i can't seem figure out wrong code , why not getting out. can't seem figure out how expand rectangle. instructions: create method called expand takes offset value , returns copy of rectangle expanded offset in directions. >>> r = rectangle(30, 40, 100, 110) >>> print(r) rectangle(30, 40, 100, 110) >>> r1 = r.expand(offset=3) >>> print(r1) rectangle(27, 37, 106, 116) the original rectangle should not modified. >>> print(r) rectangle(30, 40, 100, 110) negative values should return shrunken rectangle. >>> r2 = r.expand(-5) >>> print(r2) rectangle(35, 45, 90, 100) this have far: class rectangle: def __init__(self, initx, inity, initw, inith): self.x = initx self.y = inity self.w = initw self.h = inith def __str__(self): return('rectangle(' + str(self.x) + ',' + str(self.y) + ','

mysql - Android Notification: GCM or Service -

i notify (create notification) user whenever receives in-app request. i'm using mysql database php - regular stuff. whenever value of user_id_req field changes 0 1 , app should create notification. able on app start notificationmanager , checking db in real-time, meaning value changes. should use gcm handle requests or service runs in background , checks database every minute? you should absolutely use gcm this, rather polling model. it bad practice make network request every minute - lead significant battery usage. moreover, unless have service hold wake-lock (which really kill battery), device go sleep , requests stop until user wakes device again. issue unless register app wake , trigger service on boot, polling stop whenever user restarts device. it happens gcm tutorials have create service . don't let confuse you. if you're showing notification user, don't need service , simple broadcastreceiver work fine.

ColdFusion Dates before a date -

i seem have brain fart here. i'm trying show users entered in database 14 days, or more, before today's date. reason either or no one, not ones need. here have. please tell me going wrong. thank you! <cfset todaysdate = #dateformat (now(), "mm-dd-yyyy")#> <cfset checkdate = #dateformat(todaysdate-14,"mm-dd-yyyy")#> <cfquery name="getuser" datasource="dns_test"> select * login dateentered <= #checkdate# </cfquery> <cfoutput> <cfloop query="getuser"> #getuser.lastname#, #getuser.firstname# <br> <cfloop> </cfoutput> you'll want use dateadd() . example: never use select * , instead use column names... investigate using <cfqueryparam> select lastname, firstname login dateentered <= <cfqueryparam value="#dateadd( 'd', -14, now() )#" cfsqltype="cf_sql_date">

xml - XPath context is not available in linked flow -

i have 2 flows 1. main-flow.xml 2. linked-flow.xml the linked flow called using vm queue. when try use xpath expression @ main flow, working fine. however, @ linked flow, xpath not available. tried after adding mule namespace definition in both flows, still not working. i have verify, xml node, whether present or not. <root> <child1>value1</child1> <child2> <child3> <child4>value4</child4> </child3> </child2> </root> need check, if node node3 present or not. to test whether node exists or not, can use boolean logic : boolean(/root/child2/child3) or if mule namespace exists : boolean(/mule:root/mule:child2/mule:child3)

php - Get data from a ManyToMany relationship with Doctrine2 -

i have following relationship n:n between teachers table , groups table, there third teachers_groups table. i want list teachers bring me groups teacher teaches (** related **), when return of teachers, $teacher->getclasses() empty. here code: teacher controller: namespace app\controllers; class teachercontroller extends controller { public function index() { $this->teachers = $this->model->getrepository()->findall(); // bring teachers, not bring groups // $teachers->getgroups() foreach ($this->teachers $teachers) { var_dump($teachers->getgroups()); die(); } } } teacher entity: namespace app\entities; use doctrine\common\collections\arraycollection arraycollection; /** * @entity * @table(name="teachers") */ class teacher { /** * @id @column(type="integer") * @generatedvalue(strategy="auto") **/ private $id; /** * @

The keyboard in my iOS app is too tall on the iPhone 6. How can I adjust the resolution of the keyboard in XCode? -

currently adjusting existing ios app ios 8 , iphone 6. keyboard on iphone 6 seems pretty tall (like whatsapp app before iphone 6 support update). can tell me have do, fix in code? it's not coding issue. app being rendered smaller screen sizes , scaled fit new larger screens (including keyboard). need include launch images in native resolutions iphone 6 , 6 plus if want render properly, need using auto-layout if want grow fit new screen sizes , take advantage of space. for iphone 6: 750 x 1334 (@2x) portrait 1334 x 750 (@2x) landscape for iphone 6 plus: 1242 x 2208 (@3x) portrait 2208 x 1242 (@3x) landscape or can go through link may you http://matthewpalmer.net/blog/2014/09/10/iphone-6-plus-launch-image-adaptive-mode/

Bootstrap dropdown / navbar-toggle in a Polymer Web Component -

i trying use bootstrap application based on polymer web components. based on question: bootstrap.js not working in polymer components can bootstrap working including within component's template can see shadow dom content. however, appears functionality dropdowns , navbar-toggle still not work. there workaround this? i created jsfiddle tries demonstrate this. global dropdown work if bootstrap js/css not included in polymer component's . component's dropdown partially styled correctly, not function if bootstrap js/css included in polymer component's . break functionality of global dropdown. http://jsfiddle.net/u72xk3kk/ <link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html"> <nav class="navbar-default" role="navigation"> <article class="container-fluid"> <header class="navbar-header"> <button type="button&

user agent - Regex to detect IE9 and below? -

i trying write regex pattern in java detect if user agent less or equal internet explorer 9. there quite few examples here: http://www.useragentstring.com/pages/internet%20explorer/ the main gist there string in user agent string called: "msie xxxx). current regex pattern this: msie ([1-9]|9) which seems work except there problems when msie 10.0 or msie 11.0 matches. ideas on how match 1-9 , no 10.0 or 11? in old versions, there dot after major version number, can use in regex : msie [1-9]\. another way write expect 1 number between 1 , 9 followed non number char : msie [1-9][^0-9]

asp.net mvc - Umbraco Template not rendering in content page -

Image
i'm creating content page in umbraco , have created document type , template. content page not show mark-up, shows empty page. please me. below code , description of steps: created template ubase @inherits umbraco.web.mvc.umbracotemplatepage @{ layout = null; } <!doctype html> <html class="no-js nonlegacyie" lang="en"> <!--<![endif]--> <head> </head> <body class="@viewbag.bodytagclass"> @renderbody() @rendersection("scripts", required: false) </body> </html> created document type content no custom property, uses ubase described below: next m creating content clicking content > create item under content > content. issue when publish , preview page not show anything. page behind mark-up doesn't have anything, not single tag. please have spent time still no luck :( edit: here content page properties:

c - How can I parse numbers from a command line argument into two arrays -

i'm trying take 2 arguments command line, char , int string of 1's , 0's of x length. want check if it's 5 1's , 0's, if i'll put them array. if it's longer 5, ten such 10011 10110; in case want parse input 2 different arrays. first digit goes a, second 1 goes b , on until have 2 arrays such = 10101, b = 01110. how can accomplish this? i've tried put(c) until eof while loop can't seem out of it. below entire program put arrays lll. #include <stdio.h> #include <stdlib.h> struct nodea { int dork; struct nodea * next; }; typedef struct nodea d1; struct nodeb { int dork; struct nodeb * next; }; typedef struct nodeb d2; struct mathop { char operation; struct mathop * next; }; typedef struct mathop dorkop; int main(int argc, char * argv[]) { char a; int b; d1 * curr = null, * head = null; dorkop * curr3 = null, * head3 = null; int = 0; int aa[8] = {0}; int ab[8] = {0}; int tempa, tempb; i

List all items from a for loop with javascript -

i'm looking way list each firstname below loop. loops through each firstname stoping @ last jack , displaying that. want display of them like: john, jane, joe var person = [{firstname:"john"}, {firstname:"jane"}, {firstname:"jack"}]; (var = 0; < person.length; i++) { document.getelementbyid("demo").innerhtml = person[i].firstname; } can advise on how this? the problem overwriting innerhtml value, instead need append values innerhtml property using '+' : var person = [{firstname:"john"}, {firstname:"jane"}, {firstname:"jack"}]; var demo = document.getelementbyid("demo"); (var = 0, len = person.length; < len; i++) { demo.innerhtml += person[i].firstname + ' '; } check out codepen . have add modifications make code more performant.

jquery - How to scroll window to at bottom of page after ajax call -

i have jquery ajax code execute fine on success give response , display on page. after displaying response on page want window scroll @ bottom position. my jquery code $("body").scrolltop( $(document).height() - $(window).height() ); but not scroll @ bottom of page. how can achieve? help. you not need jquery this. scrollto() method scrolls document specified coordinates.: window.scrollto(0,document.body.scrollheight);

mysql - Before start of result set -

i want display data 2 tables in single jsp page. getting following error. can please explain error. java.sql.sqlexception: before start of result set @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:1058) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:972) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:958) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:903) @ com.mysql.jdbc.resultsetimpl.checkrowpos(resultsetimpl.java:854) @ com.mysql.jdbc.resultsetimpl.getstringinternal(resultsetimpl.java:5772) @ com.mysql.jdbc.resultsetimpl.getstring(resultsetimpl.java:5692) @ com.mysql.jdbc.resultsetimpl.getstring(resultsetimpl.java:5732) @ jsp_servlet.__userhome._jspservice(__userhome.java:149) @ weblogic.servlet.jsp.jspbase.service(jspbase.java:35) @ weblogic.servlet.internal.stubsecurityhelper$servletserviceaction.run(stubsecurityhelper.java:280) @ weblogic.servlet.internal.stubsecurityhelper$servletserviceaction.run(stubsecurityhelper.java:2

Node.js mongodb native driver has a "Skip" limit of 23121 -

i'm using version 1.3.23 of native mongodb native node driver: https://www.npmjs.org/package/mongodb i have query around 180k of records wrote script throttles multiple paginated requests. problem is, once skip hits on 23121 response no longer returns results. if hit db directly can return results valid skip value issue seems @ mongo driver level. do need upgrade v1.4.22 (i'm holding off unless absolutely need to)? suggestions appreciated. i suggest using cursorstream large queries , suggest upgrading @ least 1.4. http://mongodb.github.io/node-mongodb-native/1.4/api-generated/cursorstream.html

App Engine Search: How can I search multiple search indexes in parallel? -

i have lot of indexes, , slow because when query comes in user, sequentially goes through each of these results , appends results. indexes = search.get_indexes(index_name_prefix=userdomain, limit=200) domain_indexes = [index index in indexes if userdomain==str(index.name).split(":")[0] ] index in indexes: response.append(responselistitem) makes slow, question whether can farm these out , them in parallel, , afterwards coalesce results , send response user? there not yet documented features make async calls in search api, datastore: https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/search/search.py#3636

android - Dagger injects {} method issue -

i know why need add injects = { firstfragment.class, downloadmanager.class, bookrefreshtask.class } in application class or module class. as injecting fragment , activity using graph.inject(this) method as undestand this. dagger consists of 2 modules: runtime module (which uses @inject annotations satisfy dependencies @ runtime) compile time module (which uses "injects = {a1.class, a2.class}" check code unsatisfied dependencies). so price need pay compile time errors handling.

mysql - How to get distinct result in Mongo DB? -

i using mongodb 2.6.5. have books collection. > db.books.find() { "_id" : "5476f8b5e4b04367d6c95010", "author" : "abc", "title" : "xyz", "isbnno" : "9781887902991", "category" : "computer" } { "_id" : "5476fae0e4b0016adffd08e4", "author" : "bcd", "title" : "uvw", "isbnno" : "9781887902991", "category" : "computer" } { "_id" : "5476fb7ce4b0016adffd08e5", "author" : "cde", "title" : "pqr", "isbnno" : "9781887902991", "category" : "biography" } i want result : { "_id" : "5476fae0e4b0016adffd08e4", "author" : "bcd", "title" : "uvw", "isbnno" : "9781887902991", "category" : "compu

asp.net - Bundling and Minification in Portable Area -

i used ' portable areas ', it's great. but now, want this: bundles.addembeddedresources<scriptbundle>("~/test/scripts", gettype().assembly, "portableareademo.test.scripts", "index.js"); i used cassette library, it's great. i want use library bundling , minification in asp.net adding javascript files project, doesn't work me! should do? sample project:

Array in Array PHP to Autoit -

i have following code block in php: $params = array( 'wskey' => '5443', 'number' => array('226340656')); i want convert above php code autoit code. tried below code local $params[2][2] = [['wskey', '5443'], ['number', '226340656']] is correct? it seams cannot create same structure on autoit because demonstrated structure represented hashmap( php's arrays hashmap ) only. , autoit has none of datatype related hashmap ( arrays only ). but try find (or write) library provides bunch of functions work variable hashmap( example )

keyboard shortcuts - Eclipse - multiline comment with asterisks doesn't work -

Image
i'm not able use ani shortcuts using comments asterisk. every key combination doesn't work. tried ctrl + / , ctrl + shift + / , ctrl + c ; of these have same output, i.e. simple comment // on every line. other shortcuts ctrl + \ , ctrl + shift + \ or ctrl + shift + f doesn't work @ all. so, how can have shortcut? these comments options open window>preferences>general>keys>type "add block comment" in search box, should see: the type "remove block comment" these settings default, if shortcut not working on machine, must missing these bindings, create them, need mark command "add block comment", click inside "binding" field , press ctrl+shift+/, press apply. same uncommenting.

java - Is it necessary to restart the server each time before running , when using JSTL? -

i have been trying use jstl write jsp pages .however noticed something,whenever make changes page , try save , run page without restarting page throws error below. java.lang.nosuchfielderror: deferredexpression @ org.apache.taglibs.standard.tag.common.core.foreachsupport.release(foreachsupport.java:178) @ org.apache.jasper.runtime.taghandlerpool.release(taghandlerpool.java:165) @ org.apache.jsp.web_002dinf.jsp.watchevent_jsp._jspdestroy(watchevent_jsp.java:42) @ org.apache.jasper.runtime.httpjspbase.destroy(httpjspbase.java:60) @ org.apache.jasper.servlet.jspservletwrapper.destroy(jspservletwrapper.java:478) @ org.apache.jasper.servlet.jspservletwrapper.getservlet(jspservletwrapper.java:166) @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:369) @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:390) @ org.apache.jasper.servlet.jspservlet.service(jspservlet.java:334) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org

clojure - lein run command raises exception -

once added 1 more namespace in (toy) project 1 exception raised after starting server: lein run i copying below project.clj file. (defproject compoj02 "0.1.0-snapshot" :description "fixme: write description" :url "http://example.com/fixme" :license {:name "eclipse public license" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"] [ring "1.3.1"] [compojure "1.2.1"] [clout "2.0.0"] [enlive "1.1.5"] [org.clojure/data.csv "0.1.2"] ;[org.clojure/data.csv] ] :main compoj02.core) the error exception in thread "main" java.io.filenotfoundexception: not locate clojure/data/csv__init.class or clojure/data/csv.clj on classpath: , compiling:(compoj02/pompaq.clj:1:1) @ clojure.lang.compiler.load(compiler.java:7142)

grails - Why don't unflushed domain objects revert to their "saved" state after discard? Can I get the "clean" version? -

confused here domain objects in intermediate states. so here's class: class foo { double price string name date creationdate = new date() static constraints = { price min: 50d creationdate nullable: false } } and test case: @testfor(foo) class foospec extends specification { void "test creation , constraints"() { when: "i create foo within constraints" foo f= new foo(price: 60d, name: "foobar") then: "it validates , saves" f.validate() f.save() when: "i make foo invalid" f.price=49d then: "it no longer validates" !f.validate() when: "i discard changes since last save" f.discard() then: "it validates again" f.validate() //test fails here } } so test fails on last validate, because f.discard() doesn'

c++ - Crypto++ pbkdf2 output is different than Rfc2898DeriveBytes (C#) and crypto.pbkdf2 (JavaScript) -

so i'm trying use pbkdf2 derive key given base64 string of 256bits. able use c#'s rfc2898derivebytes , node-crypto's pbkdf2 derive same key, however, can't same c++. i'm not sure if i'm doing wrong conversions or using functions improperly, i'll let guys @ it. c++ /* 256bit key */ string key = "y1mjycd0+o+aendy5pb58jmlms0embwgjdj2r2kw6qq="; string decodedkey; stringsource(key, true, new base64decoder(new stringsink(decodedkey))); const byte* keybyte = (const byte*) decodedkey.data(); /* generate iv */ /* autoseededrandompool prng; byte iv[aes::blocksize]; prng.generateblock(iv, sizeof(iv)); */ /* testing purposes, hardcode iv */ string iv = "5ifv54dcrq5icqbd7qhqzg=="; string decodediv; stringsource(iv, true, new base64decoder(new stringsink(decodediv))); const byte* ivbyte = (const byte *) decodediv.data(); byte derivedkey[32]; pkcs5_pbkdf2_hmac<cryptopp::sha1> pbkdf2; pbkdf2.derivekey(derivedkey, 32, 0, keyby

java - Application crashing when images with particular resolutions are selected -

i have method converts image round shape , sets in imageview. method works in of cases, misbehaves when images resolutions selected. the method: public void decodeimagefile(string imagepath, matrix m){ // need dp px algorith herer bitmap bitmap = decodesamplebitmapfromfile(imagepath, 1024, 1024); //bitmap = bitmap.createscaledbitmap(bitmap, 540, 960, true); int w = bitmap.getwidth(); int h = bitmap.getheight(); log.e("height", ""+h); log.e("width", ""+w); //to prevent crashing app not legal resolution // if (h == 1920 && w == 2160) { // bitmap = bitmap.createscaledbitmap(bitmap, 540, 960, true); // } // logic check whether resulting image has height or // width greater 0 if (bitmap.getwidth() > 0 && bitmap.getheight() > 0) { bitmap = bitmap.createbitmap(bitmap, 0, 0, bitmap.getwidth(), bitmap.ge

How to concatenate string continuously in php? -

<?php $test = ' /clothing/men/tees'; $req_url = explode('/', $test); $c = count($req_url); $ex_url = 'http://www.test.com/'; for($i=1; $c > $i; $i++){ echo '/'.'<a href="'.$ex_url.'/'.$req_url[$i].'"> <span>'.ucfirst($req_url[$i]).'</span> </a>'; //echo '<br/>'.$ex_url;....//last line } ?> output - 1 //when comment last line / clothing / men / tees output - 2 //when un-comment last line $ex_url shows / clothing http://www.test.com// men http://www.test.com// tees http://www.test.com/ 1. required output - in span - / clothing / men / tees , last element should not clickable and link should created in way http://www.test.com/clothing/men/tees -- when click on tees http://www.test.com/clothing/men -- when click on men ...respectively 2. output 2 why comes that

javascript - Money.js + LocalStorage rates -

i'm using intel xdk make conversion tool, script detects if device has internet connection, if yes use latest rate openexchangerates via json , storage in localstorage: $.getjson('https://openexchangerates.org/api/latest.json?app_id=xxxxxxxxxxxxxxxxxxxxxxxxxx',function(data) { var localdata = json.stringify(data); localstorage.setitem('convrates', localdata); // check money.js has finished loading: if ( typeof fx !== "undefined" && fx.rates ) { fx.rates = data.rates; fx.base = data.base; } else { // if not, apply fxsetup global: var fxsetup = { rates : data.rates, base : data.base } } }); this ok! when try info localstorage, nothing h

Bootstrap Modal with Chart.js linechart -

i have twitter bootstrap 3 modal window , want draw chart.js linechart in it. every time open modal canvas element has height , width of 0. if change these values chart empty. seems chart never drawn doesnt console output or errors. modal: <div class="modal fade" id="examplemodal" tabindex="-1" role="dialog" aria-labelledby="examplemodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">close</span></button> <h4 class="modal-title" id="examplemodallabel">new message</h4> </div> <div c

ios - Is it allowed to add a UITabBarItem that opens up Safari? -

i want add uitabbaritem on tabbar when clicked opens safari instead of loading corresponding tab. (not uiwebview app goes background , opens safari instead) i know how this, wondering if allowed apple. know they're ok using tabbaritem trigger other actions such opening modal in app, etc. not sure if it's ok open safari. i being cautious because don't want rejected , wait week. i don't see reason why shouldn't allowed. but : lead confusion amongst users, because not expect touching item on tabbar leads app switch. rather open webview , offer additional possibility open page in safari.

ruby on rails - show first image in css definition? -

i have inline css/ haml :css .testimonials{ background: url('/assets/#{@house.slug}.jpg'); padding: 80px 0; background-size: cover; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; background-attachment: fixed;/* ie fix */ } this shows image assets folder related house in parallax scrolling website. i use carrierwave manage images houses, , want show first image in css background definition don't have upload image assets folder anymore. - @house.attachments.each.first |a| = image_tag(a.file.url(:thumb)) how can place loop in inline css definition? thanks..remco by using style option image_tag a.file.url(:thumb), :style => "background: url(a.file.url(:thumb))" even no need image_tag div add style option background image

css - How to center the Firefox #urlbar? -

in firefox navigationbar have back/forward buttons on 1 side , menu button on other side of urlbar. i'd horizontally center urlbar on remaining space of navigationbar custom userstyle. in css, i've added following code: #urlbar { width: 800px; margin: 0 auto !important; } but doesn't work. can maybe point me in right direction? thanks! i think right way make urlbar fixed width (it's how have set on profile): #urlbar, #urlbar-container { min-width: 250px !important; max-width: 550px !important; } don't know how make urlbar centered in navbar through userchrome.css, can achieve same result classic theme restorer extension (or other lets customize navbar flexible spaces).

Ruby Regex: parsing C++ classes -

i curious parsing c++ code using regexp. have far (using ruby) allows me extract class declarations , parent classes (if any): /(struct|class)\s+([^{:\s]+)\s*[:]?([^{]+)\s*\{/ here example in rubular. notice can capture correctly "declaration" , "inheritance" parts. the point @ stuck @ capturing class body . if use following extension of original regex: /(struct|class)\s+([^{:\s]+)\s*[:]?([^{]+)\s*\{[^}]*\};/ then can capture class body only if not contain curly braces, , therefore class or function definition. @ point have tried many things none of them make better. instance, if include in regexp fact body can contain braces, capture first class declaration , subsequent classes if part of first class' body! what missing? the group capturing might help: # named v backref v /(struct|class)\s+(?<match>{((\g<match>|[^{}]*))*})/m here find matching curly bracket 1 following struct / class

Android program to connect Bluetooth devices -

i have bluetooth device called feig obid iscan - hf reader connect pc through bluetooth , send data when reads hf tag.i have paired device in android phone , generated code 00:07:80:9c:c9:b9 through andriod program how can connect device , get data device (feig) in android device.please give android source code connect , data. a few years ago tried connect using bluetooh on pc , send data terminal , bluetooh module , managed using following example: bluetooh chat example (of course need adapt needs) the example above contains server , client send , receive messages/data using bluetooh connection, show how search devices , pair them. i found example , think useful see , understand. android--bluetooth-connection-code-sample cheers

How to run a query for a map job only in Apache hive -

if write query in apache hive executes mapreduce job behind scene how can run map job in hive? thanks certain optimized queries in fact require map phase. may provide mapjoin hint in hive achieve same: recommended small secondary tables: select /*+ mapjoin(...) */ * ...

c# - Set foreground color of button -

i generated button dynamically, need change foreground color , set borderbrush. can't use code btn.foreground = brushes.yellow; vs2013 warning 'brushes not exist.' try this: include assembly 'system.windows.media' btn.foreground=new solidcolorbrush(colors.yellow);

shell - > /dev/null 2>&1 still has output in stdout -

i try following: #!/bin/bash var=$(< temp.temp) > /dev/null 2>&1 echo $var i expected no outputs whether temp.temp exists or not. when tried these command, still has outputs. on this? thanks. use this: { var=$(<temp.temp); } 2>/dev/null

javascript - Retaining "this" inside callback function -

i'm not sure if question specific backbone.js. have model following render function: render: function() { var self = this; this.$el.empty(); this.model.fetch({ success: function() { self.$el.append(self.template(self.model.attributes)); } }); return this; } as can see, inside success callback function, use variable called self . because inside callback, this set window when want set view. there way can retain original reference of this without storing in variable? is there way can retain original reference of without storing in variable? yes, reasonable use case proxy method this.model.fetch({ success: $.proxy(function() { this.$el.append(this.template(this.model.attributes)); }, this) }); alternatively can use underscore's bind method: this.model.fetch({ success: _.bind(function() { this.$el.append(this.template(this.model.attributes)); },

c# - How to properly add a foreign key from my own model to the EF Userprofile? -

my model classes first: public class person { [required, key] public int id { get; set; } [required] public string name { get; set; } [required] public string learntskillsandlevelofskills { get; set; } public string profileimage { get; set; } public string city { get; set; } public string phonenr { get; set; } [required] public string email { get; set; } public string hobbys { get; set; } public string skillstolearn { get; set; } public string stand { get; set; } public int yearsofworkexperience { get; set; } public string hobbyprojectictrelated { get; set; } public string extrainfo { get; set; } public string summary { get; set; } public int userid { get; set; } [foreignkey("userid")] public virtual userprofile profile { get; set; } } [table("userprofile")] public class userprofile { [key] [databasegeneratedattribute(databasegeneratedoption.ident

Multiple SQL Queries in C# returning a variable as a column -

i'm working on school project create registration system. chosen means of db use t-sql it's i'm familiar. i'm using below code query db public void button3_click(object sender, eventargs e) { string studentid = (textbox1.text); string querydob = "select dob,lastname,degree student studentid = " + studentid; sqlconnection con = new sqlconnection(properties.settings.default.srsconnectionstring); con.open(); sqlcommand dob = new sqlcommand(querydob, con); sqldatareader stidreader = dob.executereader(); if (stidreader.read()) { textbox2.text = stidreader["dob"].tostring(); textbox3.text = stidreader["lastname"].tostring(); textbox5.text = stidreader["degree"].tostring(); } else { messagebox.show("your id not recognised. please try again."); textbox1.clear();

php - How to know if this request triggered by a redirection in Silex? -

i have php web app silex. in url need know if page redirected, , if so, redirected url. tried $request->headers->get('referer')) has value, when request triggered click on page. tried use "url interface" fro redirection this: $app->get('/redirect/{url}', function (\silex\application $app, $url) { $url=str_replace("!","/",$url); return $app->redirect($url,302); }); and instance changed redirect /sell/insert redirection /redirect/!sell!insert . time $request->headers->get('referer')) returns first url, not /redirct . so how can know if request triggered redirection, , if so, redirected url? having example in mind, can send url parameter, , check request it, instead of checking referer. way store url in session before doing redirect, , check session in route/s expecting it. depending on trying achieve, may interesed in forwarding instead of redirecting.

javascript - Add li to ul with looking for if exists -

i'm adding thinks getting input field list. adding function works want check if string, user wants add exists. want don't know right functions use html first name: <input type="text" id="firstname"> <br> <p>other people's names:</p> <ul id="demo"></ul> <input type='button' onclick='changetext2()' value='submit' /> javascript var list = document.getelementbyid('demo'); function changetext2() { var firstname = document.getelementbyid('firstname').value; var listelement = list.getelementsbytagname("li"); // here missing code if (listelement.text not in list){ var entry = document.createelement('li'); entry.appendchild(document.createtextnode(firstname)); list.appendchild(entry); } else alert("is in !"); } edit* the code above in jsfiddle . you create array , push in

database design - data modelling and queries in cassandra -

|id| events timestamp ---------------------------------------------- |1 | inprogress 2010-03-31 15:59:42 |1 | awaiting 2010-04-31 15:59:42 |1 | resolved 2010-05-31 15:59:42 |1 | closed 2010-06-31 15:59:42 |2 | awaiting 2010-07-31 15:59:42 |2 | inprogress 2010-08-31 15:59:42 |2 | wait 2010-09-31 15:59:42 |2 | closed 2010-10-31 15:59:42 i have table in cassandra. table need extract 2 tables-one containing 1st event corresponding id , other containing last event corresponding id.thus, should 2 tables output: initial ----------------------------- inprogress awaiting final ----------------------------- closed i need know how can done in cql(cassandra query language)only or if there way i can model data in such way able obtain desired results .

java - MyBatis - ResultHandler is not invoked -

i followed example : https://code.google.com/p/mybatis/wiki/resulthandlerexample interface: public interface countrydirrdbmapper { public static class countrydirbaseitemwithtext { public countrydirbaseitem baseitem; } public list<countrydirbaseitem> select(resulthandler handler); } this xml mapper <resultmap id="readitemsrm" type="countrydirrdbmapper$countrydirbaseitemwithtext"> <association property="baseitem" javatype="countrydirbaseitem"> <id property="id" column="id"/> <result property="comment" column="comment"/> </association> </resultmap> this code form dao: sqlsession session = mybatisconnectionfactory.getsqlsessionfactory().opensession(true); list<countrydirbaseitem> list; try{ countrydirrdbmapper mapper = session.getmapper(countrydirrdbmapper.class); cla

android.support.v5.app.Fragment or android.app.Fragment? -

im using android studio 1.0 rc1. i have created mainactivity (tabbedactivity): public class mainactivity extends actionbaractivity implements actionbar.tablistener it imports: ... import android.support.v4.app.fragment; ... so heres problem: ive made fragmentactivity: public class blankfragment extends fragment { this on imports: now want this: public fragment getitem(int position) { // getitem called instantiate fragment given page. // return placeholderfragment (defined static inner class below). switch (position){ case 0: return scoutlogfragment.newinstance("a","b"); case 1: return blankfragment.newinstance("a", "b"); case 2: return placeholderfragment.newinstance(position + 1); default: return placeholderfragment.newinstance(position + 1); } } but tells me: "required: import android.support.v4.app.fragment;

jsp - use Ajax to call data from servlet -

i know question has been asked before, can't seem find awnser on it. i'm trying call servlet method when page loaded, @ moment it's endless loop cause every time servlet posts response page gets reloaded , calls servlet again calls reloads page again etc etc.. i'm collecting id url use in servlet collect data need. here code i'm using. <form style="display:none;" action="servletc" method="post"> <input type="hidden" name="hdn_parameter" value="<%= request.getparameter("productid")%>"/> <input type="submit" id="btn_loadform" name="loadform" style="display: none;"/> <script> document.getelementbyid('btn_loadform').click(); </script> </form> and got couple pieces of code throughout page <img id=&