Posts

Showing posts from February, 2013

html - How should I edit a model entry in mvc? -

i working on small app using phalcon php framework. have implemented multiple controllers , models, far when want edit user example, use link links localhost/myappname/user/edit/11 "user's id" i told not best way this, , trying without passing id through url, using post method in forms without success far. correct way edit or delete entry or there better? tried search problem couldn't figure how name question yet find answered question. if don't want let access edit page can in few ways. solution #1 you can use phalcon acl block user's has no permission edit page allowed people managers can edit user or whatever. see access control lists acl solution #2 you can crypt/decrypt user id in url not readable humans , in edit method try dectypt id , if not valid echo error. <?php use phalcon\crypt; // create instance $crypt = new crypt(); $key = 'le password'; $user_id = 5; $encrypt = $cryp

mysql - PDI or mysqldump to extract data without blocking the database nor getting inconsistent data? -

i have etl process run periodically. using kettle (pdi) extract data source database , copy stage database. use several transformations table input , table output steps. however, think inconsistent data if source database modified during process, since way don't snapshot of data. furthermore, don't know if source database blocked. problem if extraction takes minutes (and take them). advantage of pdi can select necessary columns , use timestamps new data. by other hand, think mysqldump --single-transaction allows me data in consistent way , don't block source database (all tables innodb). disadventage innecessary data. can use pdi, or need mysqldump? pd: need read specific tables specific databases, think xtrabackup it's not option. however, think inconsistent data if source database modified during process, since way don't snapshot of data i think "table input" step doesn't take account modifications happening when reading. try

cast string to ToolStripMenuItem in vb.net -

i want cast string toolstripmenuitem using directcast function. code is: dim parentmenu toolstripmenuitem = directcast(combobox1.selecteditem, toolstripmenuitem) but raise following error unable cast object of type 'system.string' type 'system.windows.forms.toolstripmenuitem'. you cannot cast string toolstripmenuitem because of simple fact string is not toolstripmenuitem! directcast function requires kind of relationship (like inheritance) between 2 objects work. means 1 of 2 objects must same type other, or 1 of them must inherit or implement other one. read more directcast: https://msdn.microsoft.com/en-us/library/7k6y2h6x.aspx if want done in 1 line do: dim parentmenu new toolstripmenuitem(combobox1.selecteditem.tostring()) you need use .tostring() or cstr() since combobox1.selecteditem returned object.

sql - ASP.NET working with Data Sources -

i new asp.net, tasked creating website graph data our customer. is there way work data pulled datasource in asp.net, before goes table or graph? i pulled set of data sql database, , need calculate average of 1 of columns plot along data. know can in select statement, trying minimize strain on our sql server queries , put bit more of load onto our web server. <asp:sqldatasource runat="server" id="nondamped" connectionstring='<%$ connectionstrings:connectionstring %>' providername='<%$ connectionstrings:connectionstring.providername %>' selectcommand="<ommitted>"></asp:sqldatasource> you can use object of datatable class or dataset class store results select statement. can traverse though data using [row] [column] index properties of objects. eg. sqldataadapter sda=new sqldataadapter("select query",connectionstring); datatable dt=new datatable(); sda.fill(dt); if(dt.rows.count>0)

java - android upload file opened via by storage api presented in kitkat -

used below code open file intent intent = new intent(intent.action_open_document); intent.addcategory(intent.category_openable); intent.settype("image/*"); startactivityforresult(intent, read_request_code); used below code read file parcelfiledescriptor parcelfiledescriptor =attachimageonpost.this.getcontentresolver() .openfiledescriptor(data.getdata(), "r"); filedescriptor filedescriptor = parcelfiledescriptor.getfiledescriptor(); rect rect=new rect(100, 100, 100, 100); image.setimagebitmap(bitmapfactory.decodefiledescriptor(filedescriptor, rect)); is there way can upload file using httpclient import java.io.file; import java.io.ioexception; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.entity.mime.multipartentity; import org.apache.http.entity.mim

objective c - Retrieve the SMS text in iOS -

i have app uses otp (one-time password) value send via sms i wanted use sms text. thank registration, verification code '####'.please not reply message i wanted show msg on uiview have ok button. , onclick on ok button have copy otp '####' uitextfield . so question is, possible sms text app in ios. links searched shows that, possible jailbreak. but need proper answer, if possible how can achieve it. if not possible link show me in written can show manager , take decision accordingly. it's impossible access user's sms messages on both simulator , on real device (unless it's jailbroken). unlike on android, apple's privacy constraints don't allow developers right access users' personal data such text messages, phone calls, etc. can see various examples this. example, try whatsapp registration process on both iphone , android. on both, you'll receive text message code, while on android code magically inputted , verifie

cordova - Phonegap every 5 minutes wake app in background to check location iOS -

i'm building location-aware app in phonegap has check location periodically in background determine when user enters/exits specific places. question ios specifically. significant-change api no me because it's accuracy level more street-wise building-wise, , latter app requires. so far, after reading comments in great answer this , i've managed keep app alive in background combination of background mode declaration ( in config.xml ): <gap:config-file platform="ios" parent="uibackgroundmodes" mode="replace"> <array> <string>location</string> </array> </gap:config-file> and once when app in foreground after launched, calling: navigator.geolocation.watchposition(...) what need is: the app fully suspended between intervals (as kill battery have app alive in bg under watchposition day long), , woken perform single getcurrentposition + post server each time. the app launched ro

xml parsing - Scraping HTML-page using readHTMLTables in R -

i'd scrape webpage: http://unbisnet.un.org:8080/ipac20/ipac.jsp?&menu=search&aspect=power&npp=50&ipp=20&spp=20&profile=bib&index=.tw&term=%22draft+resolution%22&index=.aw&term=netherlands i need create dataframe containing 5 columns (title, imprint, enhanced title, un document symbol, publication date) each resolution. tried using readhtmltables, can't seem figure out. website contains many tables. when run code list 394 objects, me seems empty. u <- "http://unbisnet.un.org:8080/ipac20/ipac.jsp?&menu=search&aspect=power&npp=50&ipp=20&spp=20&profile=bib&index=.tw&term=%22draft+resolution%22&index=.aw&term=netherlands" tables = readhtmltable(u) names(tables) length(tables) tables[[1]] you have change approach. that's horrible site many, many nested <table> s. here's 1 way deal it, you'll have roll sleeves fields may want. please research xpath queries

c# - Not all code paths return a value when using Task.ContinueWith -

so have function have return in if-else still getting compilation error: not code paths return value public async task<bool> deletepost(string update_id, string authid) { if (utility.networkstatus.hasinternetaccess) { await apis.deletepost.deletepostapi(update_id, authid).continuewith((t) => { if (t.status == taskstatus.rantocompletion) { if (t.result != null) { return t.result.status == 200; } else { return false; //empty result, api failed //not implemented } } else { return false; //task failed //not implemented } }); } else { return false; //no network //not implemented } } can tell me doing wron

php - Running Behat tests from Jenkins -

i'm trying run behat (3.0.15) tests jenkins behat raising failed steps. for example step: and should click header "cómo funciona" link the error: and should click header "c??mo funciona" link # test_behavior/resources/features/web/staticpages/como_funciona.feature:9 [exec] "clickcmofuncionalink" method not available on header (badmethodcallexception) our build.xml <target name="behat"> <exec executable="vendor/bin/behat" failonerror="true"> <arg value="--tags=~@skip"/> <arg value="--profile=jenkins"/> <arg value="--format=progress"/> </exec> </target> and our behat.yml default: suites: default: paths: [%paths.base%/test_behavior/resources/features/web] contexts: - testbehavior\context\basecontext service: paths: [%paths.base%/test_behavior/resources/featu

java - Getting String from Multi-Dimesnional -

could give me hand, please? have multi-dimensional array stores values of string. private static jmenu[] menu_bars; private static final string[] menu_names = {"file", "edit", "view", "search", "info"}; private static final string[][] menu_item_data = {{"new file","open file", "close", "close all", "save", "saveas...", "print"}, {"undo typing", "redo", "cut", "copy", "paste", "delete", "select all"}, {"text color", "font", "text size", "background color"}, {"search..."}, {"sp

python - SQLAlchemy group_by return object with aggregated values -

let's consider have such schema: class owner(db.model): __tablename__ = 'owners' id = db.column(db.integer, nullable=false, primary_key=true, autoincrement=true) name = db.column(db.unicode(30), nullable=false) shares = db.relationship('share', secondary=lambda: shares_owners, lazy="dynamic") class share(db.model): __tablename__ = 'shares' id = db.column(db.integer, nullable=false, primary_key=true, autoincrement=true) apartment = db.column(db.integer, nullable=false) value = db.column(db.integer, nullable=false) owners = db.relationship('owner', secondary=lambda: shares_owners, lazy="dynamic") shares_owners = db.table('shares_owners', db.column('share_id', db.integer, db.foreignkey('shares.id')), db.column('owner_id', db.integer, db.foreignkey('owners.id')) ) filtering shares owned owner piece of cake: share.query.join(shares_owner

math - How to split a longer formula into multiple lines with PHP? -

i have more complicated formulas php. cool if split formula multiple lines. know how strings, have no idea how within 1 single calculation. i want like: public function example_calc(){ $result = $var1 * $var2 + + $var3 * $var4 - - $var5 / $var6; return $result; } don't duplicate + , - signs across lines, split normally public function example_calc(){ $result = $var1 * $var2 + $var3 * $var4 - $var5 / $var6; return $result; } or public function example_calc(){ $result = $var1 * $var2 + $var3 * $var4 - $var5 / $var6; return $result; } and cool work it's ; marks end of "line" of code, not carriage return/line feed

sql server - EXEC statement in SQL stored procedure's cursor loop -

i have following code in stored procedure. seems sometimes, execute statement doesn't execute @id values. ideas? happens if exec statement takes long time in cursor loop? in other words, exec statement synchronous or asynchronous? thanks! declare @id int declare cur cursor local select id wq convert(date, deploy_dt) = convert(date, getdate()) , stage_id = 6 open cur fetch next cur @id while @@fetch_status = 0 begin exec uspupdpublishbywqid @id fetch next cur @id end close cur deallocate cur update: thanks hans. catch exceptions, if goes wrong , save database. see following error today: system.data.sqlclient.sqlexception (0x80131904): timeout expired. timeout period elapsed prior completion of operation or server not responding. ---> system.componentmodel.win32exception (0x80004005): wait operation timed out @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean

security - My wordpress websites on VPS server is getting hacked regularly -

i have purchased vps server ovh. have installed vestacp, has been more 6 months , i'm still facing issues server security. wordpress websites hacked, server slow or not responding whole day. i'm not able identify issue. please. me. here basic checklist started: download , run wpscan against site can obtain here . change passwords, since it's virtual private server pem file might of been compromised. change password access site. update plugins, can't stress enough , see businesses time, don't update plugins. make sure updated latest wordpress version well. if website beyond repair @ time download files , fresh install of wordpress , restore can. invest in ssl certificate encrypt data, protect , users mitm (man in middle) attacks. update .htaccess file restrictions try these . if don't have ids/ips detect sql injection consider installing modsecurity, can download here . since it's virtual private server if backdoor has been planted migh

php - php5filter: Constantly getting UPLOAD_ERR_PARTIAL on files bigger than ~7961 Bytes -

when upload file bigger 7961 bytes (yes not mb, not kb, bytes) upload_err_partial. limit little bit greater 7967b , on. totally sure have in php.ini (i checked running phpini()): post_max_size = 8m upload_max_filesize = 2m max_execution_time = 30 memory_limit = 128m file_uploads = on i have tried increase values, no effect. when file smaller, upload works normally. my configuration is: apache2, apache2-mod-php5filter, php5 5.6.9. apache error.log tells.nothing. have set e_all . thank answers.

java - editText.getText().toString() retrieves the String all uppercase -

i want edittext.gettext().tostring() normal string inserted edittext instead i'm getting uppercase no matter what. relevant xml: <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <textview android:id="@+id/first_name_id" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/first_name_text" android:textsize="20sp" /> <edittext android:id="@+id/first_name_edit_text_id" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/first_name_hint_text" /> </linearlayout> relevant java: sharedpreferences = preferencemanager.getdefaultsharedpreferences(this); sharedprefe

c# - WPF Design Time Data and Data Templates -

Image
i'm developing wpf user control , want display design-time data. it's proving quite challenge things right , use help. here's control far, <listbox> : <usercontrol x:class="ta.weather.ui.wpf.workingseteditor" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="300" loaded="handleloadedevent" > <grid d:datacontext="{d:designdata source=/sampledata/workingset.xaml}"> <listbox x:name="workingsetlistbox" > <grid> <grid.columndefinitions

filter - SAPUI5 - FilterBar - setVisible not working -

i'm using sap.ui.comp.filterbar.filterbar control on project. works fine, except when try hide control. var ofilterbar = new sap.ui.comp.filterbar.filterbar("filterbar",{ reset: ocontroller.handleonreset, search: ocontroller.handleonsearch, showrestoreonfb: true, showclearonfb: true, showrestorebutton: true, showclearbutton: true, ... }); ofilterbar.setvisible(false); i'm getting following error: uncaught typeerror: ofilterbar.setvisible not function since property being inherited sap.ui.core.control class, should work , think has nothing versions either (i'm using 1.24). it has version. in sapui5 1.28 [1] property visible moved sap.ui.core.control control extending have property well. if using earlier version control implement property can made invisible. you extend control using include property: sap.ui.comp.filterbar.filterbar.extend("my.filterbar", { metadata: { properti

java - Best way to quickly and repeatedly search if value is present in a rapidly growing array? -

i have program looks hundreds of categories website , of each category grabs data product detail pages of many of products in each category each category them select table 800 categories, , 100 products each category. the problem many of products belong more 1 category trying put way in code not go product detail page if have grabbed product before(in different category) so code conceptually this: thesql = "select catid categories"; resultset rs = statement.executequery(thesql); while (rs.next()) { > go check website particular catid > loop check products in page > each productid listed in category's page: > check array see if have encountered productid before(in session) > if have, skip product , continue next 1 > if haven't, go product's detail web page, grab data, insert in database, , add productid in our array. } i have 2 questions: 1) counterproductive or reso

c# - Adding a String Indexer to XmlSerializer -

i have xml source can't change , want deserialise using xmlserializer. i can fine there arrays of custom classes access array string , not in integer. i know can use public classname this[string index] but can't work out add class. i want able call object.transaction["transactiontypename"] instead of object.transaction[0] this stripped down version of class. public partial class configuration { private configurationtransaction[] transactionsfield; [system.xml.serialization.xmlarrayitemattribute("transaction", isnullable = false)] public list<configurationtransaction> transactions { { return this.transactionsfield; } set { this.transactionsfield = value; } } } public partial class configurationtransaction { private string typefield; [system.xml.serialization.xmlattributeattribute()] public string type {

jquery - Faulty image height on website -

Image
i have row of images in current books on website , make images same height, set image html book equal 378 using: <img alt="html & css" height= "378" src="html.jpg"> using jquery, set height of other images in row using this: $(window).load(function() { $(".book-pictures").height($("#html").height()); $(".book-pictures").width($("#html").width()); }); $(window).resize(function(){ $(".book-pictures").height($("#html").height()); $(".book-pictures").width($("#html").width()); }); the height of these images uniform good, html book image height smaller others. here html row: <section id="book-section" class="portfolio"> <div class="container"> <div class="row" id="books"> <div class="col-lg-10 col-lg-offset-1 text-center">

html - Writing media queries for mobile devices, low-res desktop and hi-res desktop -

Image
this question has answer here: what difference between max-device-width , max-width mobile web? 8 answers i'm using both screen width , screen height detect difference between mobile , desktops , detect high resolution desktops vs. low resolution desktops. i have javascript use load different css files. looks this: javascript <script> if (screen.width > 800) { if (screen.height < 900) { document.write('<link href="/lowres.css" type="text/css" />'); } else { document.write('<link href="/hires.css" type="text/css" />'); } } else { document.write('<meta name="viewport" content="width=device-width,initial-scale=1">'); document.write('<link href="/mobile.css" type="text/css" />&#

php - Symfony2 - app/console -

i beginner symfony , command line. within command lines cannot go app / console... my symfony project located in "symfony-2.4" folder in www folder (wamp path), i typed cli cd c:\wamp\www\symfony-2.4 and this: php app/console but nothing displayed in command line, why ? image: https://s3-eu-west-1.amazonaws.com/sdz-upload/prod/upload/sans%20titre-1100.png please read symfony requirements documentation. http://symfony.com/doc/current/reference/requirements.html firstly, can execute php app/check.php analyse configuration.

git merge - git cherry-pick being ancestor-aware, not just applying a patch? -

it sure nice if merge -like cleverness , awareness of common ancestors available in cherry-pick . possible? suppose have situation. have development commits made dev , cherry-picked release . [1] x----y---a1---a2---b---z dev \ \----b' release a1: remove function foo() a2: re-add function foo() (ooops, needed) , change function bar() (a1 , a2 listed becuase 2 commits, attempts, fix same bug.) b: modify function foo() b': b cherry-picked release branch x, y, z: changes touching unrelated files. no conflicts here. now want cherry-pick a1 , a2 release branch. obviously, cannot cherry-pick them because there conflict on deletion/modification of foo() . but smart person see how a1 , a2 delete , re-add foo() , how can indeed merged release branch. , make algorithm take commits dev occur after a1,a2 in release , go commit before that, , re-apply a1, a2, b in order applied dev take final state of files , put after b' on releas

c# - FileLabels are not visible -

Image
i try capture desktop screenshot using sharpdx. application able capture screenshot without labels in windows explorer. tryed 2 solutions without change. tried find in documentation information, without change. here mi code: public void scr() { uint numadapter = 0; // # of graphics card adapter uint numoutput = 0; // # of output device (i.e. monitor) // create device , factory var device = new sharpdx.direct3d11.device(sharpdx.direct3d.drivertype.hardware); var factory = new factory1(); // creating cpu-accessible texture resource var texdes = new sharpdx.direct3d11.texture2ddescription { cpuaccessflags = sharpdx.direct3d11.cpuaccessflags.read, bindflags = sharpdx.direct3d11.bindflags.none, format = format.b8g8r8a8_unorm, height = factory.adapters1[numadapter].outputs[numoutput].description.desktopbounds.height, width = factory.adapters1[nu

python - I want Scrapy to run through each item once -

i scrapy run through each item once relevant data grouped together. puts links, headers, dates etc together. posting file more once. pretty new both scrapy , python advice grateful for. here spider code: from scrapy.spiders import spider scrapy.selector import selector fashioblog.functions import extract_data fashioblog.items import fashioblog class firstspider(spider): name = "first" allowed_domains = [ "stopitrightnow.com" ] start_urls = [ "http://www.stopitrightnow.com" ] def parse(self, response): sel = selector(response) sites = sel.xpath('//div[@class="post-outer"]') items= [] site in sites: item = fashioblog() item['title'] = extract_data(site.xpath('//h3[normalize-space(@class)="post-title entry-title"]//text()').extract()) item['url'] = extract_data(site.xpath('//div[normalize-space(@class)="post-body e

ios - How to make a square view resize with its superview using auto layout -

Image
in particular case have view inside view controller added following constraints: set leading, trailing, top , bottom edges 0 set multiplier bottom edge 2:1 now view sits in top half on view controller. inside add square image view, added following constraints: ctrl drag image view superview , added equal heights , widths. change multiplier width , height until have perfect square. added constraints center vertically , horizontally my constraints seems perfect, when running in simulator don't perfect square. besides this, image view doesn't resize when running on different simulator screens. this setup: auto layout , size classes enabled i use inferred size storyboard adaptive layout set width , height i trying run 4s,5,6 , 6+ simulators. i looked on other stackoverflow posts, nothing seems work. are there basic steps ? edit: after setting >=10 constraints: edit 3: added top,bottom,leading,trailing constraints 2 times, 1 lower

Error when using a structure with an array of chars in C -

i have struct contains array of chars , struct has struct. passed reference function initializes array. then, call function print , free array. please me, wrong program? #include <stdio.h> #include <stdlib.h> typedef struct { char *x; double y; } a; typedef struct { a; int w; } b; void f(b *b) { int i; b->w = 5; b->a.x = (char *) malloc(sizeof(char) * 5); printf("addres in f %p: \n", b->a.x); for(i = 0; < 5; i++) b->a.x[i] = 'a'; b->a.y = 20; } void p(b *b) { int i; printf("w: %d\n", b->w); printf("addres in p %p: \n", b->a.x); printf("x: %s\n", b->a.x); printf("y: %f\n", b->a.y); free(b->a.x); } int main(int argc, char **argv) { b b; f(&b); p(&b); return 0; } when run valgrind, occurs following: ==28053== error summary: 1 errors 1 contexts (suppressed: 6 2) ==28053== ==28053== 1 errors in context 1 of 1: ==28

excel - How to open up each CSV file in current directory and add column of data based on CSV file name with an automated script -

i have group of csv files specific name includes date (e.g., reserve013112-sheet1.csv , reserve013112-sheet2.csv ). all of files have date in file name following "reserve" word. want extract date (in date format) , add column existing csv (potentially insert first column in .csv file) follows: old file: number,status,reserve,open,code 110035,open,250000,yes,no,12 110056,auto,30000,no,yes,0 ... new file: date,number,status,reserve,open,code 01-31-2012,110035,open,250000,yes,no,12 01-31-2012,110056,auto,30000,no,yes,0 ... i want automatically (potentially batch file). i have script converts existing excel files csv files, want run in batch file right before script adds date each of files. as many text processing tasks, job can made simple , efficient regular expression utility. excellent option jrepl.bat , pure script (hybrid jscript/batch) utility runs natively on windows machine xp onward. the solution below first uses list *reserve*.csv files.

Jquery add class on page view -

i have added function isscrolledintoview(elem) { var docviewtop = jquery(window).scrolltop(); var docviewbottom = docviewtop + jquery(window).height(); var elemtop = jquery(elem).offset().top; var elembottom = elemtop + jquery(elem).height(); return ((elembottom <= docviewbottom) && (elemtop >= docviewtop)); } window.scroll jquery(window).scroll(function(){ if (isscrolledintoview('h2') === true) { jquery('h2').addclass('in-view') } else {jquery('h2').removeclass('in-view') } }); the problem classes added , removed when top h2 on page visible. each h2 triggered when each individual 1 enters browser window. please forgive me, new javascript. since it's working first h2 , can use .each repeat other h2 elements: jquery(window).scroll(function(){ $("h2").each(function() { if (isscrolledintoview(this) === true) { jquery(this).ad

javascript - Angularjs ng-repeat, ng-form and validation error -

Image
a simplified version of code: <!doctype html> <html ng-app="main"> <head> <meta charset="utf-8"> <title></title> <script type="text/javascript" src="https://code.angularjs.org/1.4.3/angular.min.js"></script> <script> var app = angular.module("main", []); app.controller("testcontroller", function($scope) { $scope.addresses = [{street: ""}, {street: ""}]; $scope.next = function() { if ($scope.addressmainform.addressform.$valid) { console.log("valid"); } else { console.log("invalid"); } $scope.addresses.push({street: ""}); }; $scope.remove = function(index) { $scope.addresses.splice(index, 1); }; }); &

How to make a color name not automatically convert to a hex value in Stylus? -

i iterating loop stylus preprocessor. need color class names , color values , hex values fine class names not ideal. $colors = red blue green orange; item in $colors { .{"" + item} { color: item; } } and compiled: .#f00 { color: #f00; } .#00f { color: #00f; } .#008000 { color: #008000; } .#ffa500 { color: #ffa500; } but expected result was: .red { color: #f00; // or red } .blue { color: #00f // or blue } // .. etc i can imagine there function names remain. any appreciated. if can convert original list of colors set of strings, $colors = 'red' 'blue' 'green' 'orange'; item in $colors { .{item} { color: convert(item); } } yields .red { color: #f00; } .blue { color: #00f; } .green { color: #008000; } .orange { color: #ffa500; } if change convert unquote , hex values replaced names supply them in list.

asp.net mvc - TempData is empty when set in a catch block and we rethrow -

i using custom errors ( web.config ) send unhandled exceptions errorcontroller . in main controller throw exception, catch in catch block , set tempdata have user-friendly message. throw sent errorcontroller . when check tempdata here, empty (as session be, wouldn't it?). i sure not meant empty, , right way of sending data between controllers... not working! mistaken in understanding? homecontroller : catch (exception ex) { tempdata["msgforuser"] = "useful message show"; // logging... throw; } errorcontroller : public actionresult displayerror(int id) { viewbag.msgforuser = tempdata["msgforuser"]; return view(); } web.config : <system.web> <customerrors mode="on" defaultredirect="~/errorpage/displayerror"> <error redirect="~/error/displayerror/403" statuscode="403" /> <error redirect="~/error/displayerror/404" statuscode=&quo

android - Listview selection crashes app -

i have listview listed below. when select first value in listview works fine. however, anytime select other first listview value app crashes. not sure causing this. thanks. <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:id="@+id/container_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <include android:id="@+id/toolbar" layout="@layout

Java string.format() only half working -

i trying construct string using string.format(), stops working (just over) half way through. private string constructmessage(string messagetype, int messagecode,position location) { double lat = location.getlat(); double lon = location.getlon(); double ele = location.getele(); double speed = 0.0; double heading = 0.0; string msg = "$pngvest," + messagetype + "," + vest_id + "," + system.currenttimemillis() + "," + lat + "," + lon + "," + ele + "," + speed + "," + heading + "," + messagecode; string test = string.format("$pngvest,%s,%d,%d,%f,%f,%f,$f,$f,$d", messagetype, vest_id, system.currenttimemillis(), lat, lon, ele, speed, heading, messagecode); system.out.println(msg); system.out.println(test); return msg; } when run above code, following output: $pngvest,location,1,1439998967553,51

single table inheritance - Rails STI: transfer records from one model to another -

i have model called coupons have 2 child models couponapplications and approvedcoupons . last 2 inherit coupons via sti architecture. now want realise following: a user sees couponapplications he clicks on approve button makes couponapplications approvedcoupons i realise update type column of coupons record change types. however, there several concerns, hooks etc in approvedcoupons model happening after creation not easy. in fact, want create complete new record trigger concerns, hooks etc. so wrote consider bad: @coupon_application = couponapplication.find(params[:id]) @approved_coupon = approvedcoupon.new # copy/paste attributes except id considered duplication @approved_coupon.attributes = @coupon_application.attributes.except("id") # set new type @approved_coupon.update_attributes(type: "advertisement") @approved_coupon.save i hope understand want achieve. works way doubt clean code. to summarize: i want change coupon type couponapp

Can't fix the code of the jQuery section below -

<!doctype html> <html> <head> <meta charset=utf-8> <title>twitter feed</title> <style> body { width: 600px; margin: auto; } ul { list-style: none; } li { padding-bottom: 1em; } img { float: left; padding-right: 1em; } { text-decoration: none; color: #333; } </style> </head> <body> <ul id="biebster-tweets"> <script id="tweets-template" type="text/x-handlebars-template"> {{#each this}} <li> <img src="{{thumb}}" alt="{{author}}"> <p><a href="{{url}}">{{tweet}}</a></p> </li> {{/each}} </script> </ul> <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="http://cloud.github.com/downloads/wycats/handlebars.js/ha