Posts

Showing posts from June, 2012

php - Parsing curl links and point to own server -

i'm trying set basic proxy script pull external contents , execute scripts on them. bypass same origin policy, i'm using curl fetch contents <?php $url = 'http://www.mozilla.org'; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_useragent, "mozilla/1.0"); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, true); $result= curl_exec ($ch); curl_close ($ch); echo $result; ?> however doesn't fetch css + images etc. inserted 'base' reference points original source echo '<base href="http://www.mozilla.org"/>'; my question is, methods should use parse of css, img, , other js links on each page of pulled external content, url should like: http://mydomain.com/curl.php?url=http://www.mozilla.org/main-page.html/ http://mydomain.com/curl.php?url=http://www.mozilla.org/main-page.html/sub-

angularjs - How do I mix links that trigger page refreshes, with Angular's html5Mode = true without breaking the back button? -

i'll walk through problematic flow... i load google.com (just starting point) i goto app.com i nav app.com/projects i nav app.com/api/test (through window.location) i see raw json (good far...) i press back, url changes app.com/projects still see json. i press again, url changes app.com still see json. i press again, google.com loads. i press forward, app.com loads fine... normal what's odd, i've observed when html5mode = true in webkit— firefox works desired ... . . . first, server.coffee looks this: app.get '/partials/:partial', routes.partials app.get '/api/test', api.test app.get '*', routes.index basically, requests load index (which bootstraps angular), exception view/partial handler, , test api route responds raw json. . . . (i'm using ui-router module managing nested views , ui states; uses $urlrouterprovider , similar angular's $routeprovider ) second, app.coffee looks this: app = angular.m

ios - How to stop UIView CABasicAnimation in iPhone -

i have 3 views dynamically created using loop. in called below method rotation animation - (void)runrightspinanimationonview:(uiview*)view duration:(cgfloat)duration rotations: (cgfloat)rotations repeat:(float)repeat; { cabasicanimation* rotationanimation; rotationanimation = [cabasicanimation animationwithkeypath:@"transform.rotation"]; rotationanimation.fromvalue = [nsnumber numberwithfloat:0]; rotationanimation.tovalue = [nsnumber numberwithfloat:((360*m_pi)/180)]; //rotationanimation.tovalue = [nsnumber numberwithfloat: m_pi * 2.0 /* full rotation*/ * rotations * duration ]; rotationanimation.duration = duration; //rotationanimation.cumulative = yes; rotationanimation.repeatcount = repeat; [view.layer addanimation:rotationanimation forkey:@"rotationanimation"]; } how can stop rotation animation in touch begin of view?... tried below coding in touch begin method didn't work -(void)touchesbegan:(nsset *)touches withevent:(uievent

c# - Validate TextBox for Existing data in SQL -

i trying validate inputs database. user should not able save same title twice. i using code: private bool exists() { var entity = factory.definitions.calculationparameters.list(); // list() lists values of existing data. if (aspvalidators.validatetextboxes(titletextbox)) //validates textbox string { return entity.where(item => item.title == titletextbox.text); } } now @ item => ... part i'm getting error : cannot implicitly convert type 'system.collections.generic.ienumerable' 'bool'. i don't know do. please? so problem of return type of code private bool exists() you returning 'system.collections.generic.ienumerable not of bool type. you can use way return entity.any(item => item.title == titletextbox.text);

c++ - Direction of for loop based on variable -

i have couple of biggish loops separate functions reduce code duplication. the difference between them first line of loop. one is: for (int j = 50; j < average_diff; j++) { the other is: for (int j = upper_limit; j > lower_limit; j--) { i have integer, tb indicates 1 i'd use (it has value of 1 or 2 respectively). i'm wondering how might best accomplish this. use case macros? don't wrap for , wrap contents in function: for (int j = 50; j < average_diff; j++) { process(j); } (int j = upper_limit; j > lower_limit; j--) { process(j); }

android - Pass and get back unique event ID per action -

i'm developing smartwatch extension android email app (aqua mail). something possible older liveware apis, , can't find way of doing new smartware apis is: ... being able pass unique per-event opaque id app smartware, , obtain when processing user actions. there sourceid, in case corresponds mail account, not individual message. the motivation implement message-specific actions, e.g. being able mark individual message "read" right smartwatch, or open on phone smartwatch. i guessing want implement notification extension. pass own per-event id, use friend_key column in event table. defined in notification.eventcolumns.friend_key of smartextensionapi library. you can also: obtain unique id set smart connect specific event define own set of actions performed on events (up 3 actions per source) when user reads event on smartwatch, event marked read automatically, in internal smartconnect database. if user chooses perform action on event, scrolli

node.js - passportjs error callback throwing exception -

i'm using localstrategy mysql(with sequelize) working except when mysql throws exception (just test, shut down mysql server). return done(error) callback throwing exception crashing server. here piece of code: passport.use(new localstrategy({usernamefield: 'email', passwordfield: 'password'}, function (email, password, done) { db.user.find({where: {email: email}}).done(function (error, user) { if(error) return done(error); if (!user) return done(null, false, {message: 'unknown user'}); //validate password if (user.password != password) { return done(null, false, {message: 'invalid password'}); } //all ok return done(null, user); }); } )); and exception: typeerror: property 'next' of object #<context> not function @ context.actions.error what doing wrong? thanks! edit: req._passport.inst

iphone - Problems with load data in CollectionViewController -

Image
i ve problem collectionviewcontroller , data load... i trying load external json file... the first problems when app load collectionviewcontroller shows collection cell , without images , texts... initial load when json loaded , scrolling screen appears that: after loaded json , scrolling screen what solution, collectionviewcontroller showed first show isn't possible charge collectionviewcontroller in other collectionviewcontroller, lot you must call [yourcollectionview reloaddata] rebind uicollectionview after json loaded good luck

android - Inflate a view to a LinearLayout -

how can inflate other view linearlayout? better show layout first. list.xml <framelayout > <imageview/> <progressbar /> </framelayout> <textview/> <textview /> then , main.xml <horizontalscrollview android:id="@+id/hscrollview" android:layout_width="wrap_content" android:layout_height="40dip" android:layout_margintop="50dip" android:background="#000000" android:scrollbars="none" > <linearlayout android:id="@+id/linear_temp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" > </linearlayout> </horizontalscrollview> so, want list.xm

javascript - How to hide the article at the home page in joomla 2.5 -

how hide article @ home page in joomla 2.5? some times want have home page out showing empty article. there few ways this, , depend on specific use case. for example, if want hide on homepage, can change template following. find: <jdoc:include type="component" /> change to: $menu = & jsite::getmenu(); if ($menu->getactive() != $menu->getdefault()) { <jdoc:include type="component" />; } no need worry js.

reporting services - How to find only failed user details in SSRS 2008 R2? -

i want find failed user details, below query giving duplicate records. not able find proper solution. to find failed job details i'm using below query: select * executionlog e join catalog c on e.reportid = c.itemid c.name '%reportname%' , timestart>= '2013-04-15 09:00:00.000' , status <> 'rssuccess' however, above query giving duplicate values particular report. how can unique details? note: cannot apply distinct or group by because table contains columns of ntext , image data types if want "failed user details" don't select ntext or image columns @ all. way can distinct normally: select distinct --parameters, --content, --property, --parameter, instancename, reportid, username, requesttype, format, timestart, timeend, timedataretrieval, timeprocessing, timerendering, source, status, bytecount, [rowcount], itemid, path, name, parentid, type, intermediate, s

php - Does urlencode() protect against XSS -

$address , $citystate user provided, stored in db, , available others view shown below. there risk of xss ? should htmlspecialchars() used on it? <img src="http://maps.google.com/maps/api/staticmap?markers=color:blue|<?php echo(urlencode($address.' '.$citystate));?>&amp;zoom=14&amp;size=400x400&amp;sensor=false" alt="map" /> there no magic wand php function protect all. every protection 100% safe till day hacked. need understand , how site can hacked , improve protection every day. you can interesting tips article xss prevention . also php.net urlencode documentation : <?php $query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar); echo '<a href="mycgi?' . htmlentities($query_string) . '">'; ?>

android - Install an APK without lowering the defenses of the device -

i planning series of "webapp" ios , android. webapp mean kind of application opened browser , install desktop (for ios) tap icon create shortcut. same thing android not immediate iphone , user medium-low range not easy perform action quickly. alternative create apk (which obvious reasons (like fact realize hundred of webapp similar) can't put in market). problem installing apk directly, device prompts user lower defenses of device .. avoid step, wondering, can build apk "verified" without loading on market , certified point of not lower defenses of device? can build apk "verified" without loading on market , certified point of not lower defenses of device? thankfully, can't. serious security flaw if possible. there's reason requiring go through channels google play.

java - Why system variable (path) wasn't created after jdk 1.7 installed -

all, the first time met kind of problem, when installed jdk 1.7, there no problem found in process. after , try verify version of jdk . run java command in dos window. got result says java not recognized internal or external command, operable program or batch file . can tell me why , happen? thanks. the java installer not automatically add bin directory of jdk path , seem expect. you'll have yourself, explained in jdk installation instructions: updating path environment variable (optional)

javascript - Get function associated with setTimeout or setInterval -

let's assume have timeout id returned settimeout or setinterval . can get, in way, original function or code, associated it? something this: var timer_id = settimeout(function() { console.log('hello stackoverflowers!'); }, 100000); var fn = timer_id.get_function(); // desired method fn(); // output: 'hello stackoverflowers!' you can put wrapper around settimeout - threw 1 (after few iterations of testing...) (function() { var cache = {}; var _settimeout = window.settimeout; var _cleartimeout = window.cleartimeout; window.settimeout = function(fn, delay) { var id = _settimeout(function() { delete cache[id]; // ensure map cleared on completion fn(); }, delay); cache[id] = fn; return id; } window.cleartimeout = function(id) { delete cache[id]; _cleartimeout(id); } window.gettimeout = function(id) { return cach

java - Easy way to make an ImageView that is underneath a GridView match the GridView's size exactly? -

Image
my imageview displaying image of chess style board little game i'm making. covered gridview displays images of pieces. have displaying underneath not positioned properly. want match edges of gridview don't know how. there way make gridview "parent" of imageview "match_parent" in xml it's height , width , on? here screen of how app looks now. want ugly colored grid made line gridview images black squares around edge of pieces centered in squares of board. here xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/textfieldfu" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" andr

javascript - Testing CSS Transition finished in Jasmine -

i'm trying test bit of javascript using jasmine & jasmine-jquery so have bit of javascript in function tracktransition = ()-> $("#test").on "transitionend mstransitionend webkittransitionend otransitionend", ()-> console.log "trans end" i've applied styes in spec.css add css transition , added html fixture, added in jasmine specs so: describe "checks when animation finished", -> beforeeach -> @trans = spyonevent('#test', 'transitionend mstransitionend webkittransitionend otransitionend') jasmine.clock.usemock() tracktransition() "should check when transition ended", -> expect(@trans).not.tohavebeentriggered() jasmine.clock.tick(1001) expect(@trans).tohavebeentriggered() now have tested on page , fires fine, on runner fails , console.log doesn't run. can test transitions? this cant work cause jasm

html - Does this selector require the child to be a part of the named element first (i.e. hierarchical)? -

consider following css: #searchsection label, input, select does only apply if label , input , , select element inside #searchsection ? something tells me it's more css in end: #searchsection label { } input { } select { } no, this means any label inside #searchsection any input any select to apply input s, label s , select s inside #searchsection : #searchsection label, #searchsection input, #searchsection select{ color:#f00; }

asp.net - Comparision of data available in one table using Select Query in asp -

respected members, have data 2 years in 1 sql table , populated gridview data (for 1 month) using select query command as <asp:sqldatasource id="sqldatasource15" runat="server" connectionstring="<%$ connectionstrings:punctualitymainconnectionstring2 %>" selectcommand="select sum(case when dir_ind = 'dir' 1 else 0 end ) &quot;direct&quot;, rly punctualitymain rly in ('cr', 'er', 'ecr', 'ecor', 'nr', 'ncr', 'ner', 'nfr', 'nwr', 'sr', 'scr', 'ser', 'secr', 'swr', 'wr', 'wcr') , date &gt;= '4/1/2012' , date &lt;= '4/30/2012' group rly"></asp:sqldatasource> the gridview rly direct cr 5 er 7 ecr 2 now, want display gridview comparative statement (month compared same month previous year) including %improvement / deterioration.

Magento Load Collection Using Order By -

my query generating magento collection is $usermodel = mage::getsingleton('user/user')->getcollection()->addfieldtofilter('user_id', array('in' => array($user_id))); select `main_table`.user_name `user_table` `main_table` (user_id in('1', '3', '2')); i want use query: select `main_table`.user_name `user_table` `main_table` (user_id in('1', '3', '2')) order field(user_id , 1,3,2); so display user name in same order id's input. i.e. "1,3,2" which method used in magento load collection using order by ? thanks in advance! you can zend_db_select collection , add order zend_db_select question: zend db select : order field('id',some_array) - how?

python - Establishing session with web app to crawl -

i planning write website crawler in python using requests , pyquery. however, site targeting requires me signed account. using requests, possible me establish session server (using credentials site), , use session crawl sites have access when logged in? i hope question clear, thank you. yes possible. i don't know pyquery i've made crawlers log in sites using urllib2. need use cookiejar handle cookies , send login form using request. if ask more specific try more explicit too. le: urllib2 not mess. it's best library such things in opinion. here's code snipet log in site (after can parse site normally): import urllib import urllib2 import cookielib """adding cookie support""" cj = cookielib.cookiejar() opener = urllib2.build_opener(urllib2.httpcookieprocessor(cj)) urllib2.install_opener(opener) """next log in site. actual url different , data. should check log in form see parameters takes , values.

python - matplotlib figure canvas name -

i have gui built using pyqt4 use matplotlib (figurecanvas) plot several plots using multiple canvases (this intentional rather using subplots). each canvas use method: self.canvas_xx.mpl_connect('scroll_event', self.on_mouse_scroll) where xx represents iteration of canvas signal perform action. want able reference canvas name rather using: ylabel = event.inaxes.axes.get_ylabel().split(' ')[0] where use longer method of referncing ylabel name of each graph. i looked under event method using: dir(event) , there method called "canvas", there no apparent method name of canvas. any ideas? i not quite sure mean name, can a reference canvas object via event_canvas = event.inaxes.axes.figure.canvas and canvas events hashable, can use them keys in dict other_thing = pre_populated_dict[event_canvas] to keep track of ever other data want given canvas in code. in python there is, in general, not clean way names of references object (it

android - libgdx 0.9.8 compilation to html5 not working on phones browser -

i building libgdx demo app gdx setup gui, compile html5 , deploy war. works fine in desktop browser, when test in mobile browser, android 4.1.2 , 4.2 both chrome , default browser, see blank screen. although canvas element render it's not showing sprite. no error shown in console of web inspector. webgl enabled in default browser of android 4.1.2, tested in http://get.webgl.org/ . tried current libgdx version 0.9.8 , nightly builds. at moment, version 0.9.8, looks not supported mobile browsers. for more info check http://badlogicgames.com/forum/viewtopic.php?f=11&t=8879

sql server - Does a Full-Text Index work well for columns with embedded code values -

using sql server 2012, i've got table has several hundred-thousand rows, , grow. in table, i've got nvarchar(30) field contains medical record number (mrn) values. these values can alphanumeric value, not words. for example, dr-345687 34568523 *45612345;t my application allows end user enter value, '456' in search field. application need return 3 of example records. currently, i'm using entity framework 5.0, , asking field.contains('456') type of search. this takes 3-5 seconds return since appears table search. my question is: creating full text index on column performance? haven't tried yet because copy of database have lots of data in in qa trials. looking @ documentation full text indexes appears optimized around separate words in field value, hesitant take performance hit create index without knowing how affect query performance. ef won't use t-sql keywords needed access sql server full text index ( http://msdn.

java - Display blob on JSP -

i have class fields (string, string, blob) . on jsp want display obj in table like: <c:foreach var = "p" items="${products}"> <img src="${p.image}" /> </c:foreach> how do it? you have 2 options: usually resources referenced in html page loaded asynchronously, i.e. browser first loads html page , loads images etc. referenced in html page. in case write servlet delivers image client. in case src attribute of img tag has contain path servlet. the second option embed image base64 encoded src attribute described in post: embedding base64 images

java - JUnit 4 vs. TestNG 6 -

this question has answer here: junit 4 vs testng - update 2013 - 2014 [closed] 6 answers the question classic , has been asked several times . questions , answers few years old now. so differences of junit , testng in current versions? there still important features of testng missing in junit? how easy powermock integration? tool support (quality of ide , ci server plugins). or, asked other way around: there reasons prefer junit on testng? after more research i've found following advantages of testng compared junit: support multi threading tests better test parameterization more detailed reports better grouping of tests test prioritization dependencies between tests (useful integration test , gui tests) much better documentation additional setup/teardown levels (@before/aftersuite, @before/aftertest, @before/aftergroup) tends faster in

c# - How to use GetPropertyValueSafely from CommonLibrary.NET? -

when using commonlibrary.net , how 1 use getpropertyvaluesafely() function correctly? i want this: public static string app_title = comlib.reflectionhelper.getpropertyvaluesafely(application.productname); but need add second parameter, , don't understand enough yet know asked for. here syntax usage documentation file: public static object getpropertyvaluesafely( object obj, propertyinfo propinfo ) this parameter requirements: parameters obj type: system..::..object object property retrieved. propinfo type: system.reflection..::..propertyinfo property name. so put object ? tried this, too: public static string app_title; comlib.reflectionhelper.getpropertyvaluesafely(app_title, application.productname); but that's not answer either. i tried this: public static string app_title = comlib.reflection.reflectionutils.getpropertyvalue((object)app_title, application.productname).tostring(); ...which compiles, throws runtime type error li

redefinition - How to Bypass a Standard C++ Function While Maintaining Its Functionality -

i looking way able redefine set of posix functions end redefinition call original function. idea trying create layer can restrict os api's can called depending on "profile" active. "profile" determines set of functions allowed , not specified should not used. for example, if in 1 profile not allowed use strcpy, able either cause compile time error (via static_assert) or print screen saying "strcpy not allowed in profile" such below: my_string.h #include <string.h> char *strcpy(char *restrict s1, const char *restrict s2) { #if defined(profile_pass_through) printf("strcpy not allowed in profile\n"); return strcpy(s1, s2); #elif defined(profile_error) static_assesrt(0, "strcpy not allowed in profile\n"); return 0; #else return strcpy(s1, s2); #endif } so way within main.cpp can use my_string.h #define profile_pass_through #include "my_string.h" int main() { char temp1[10]; cha

java - Android tcp vs udp for video streaming -

i want transmit live video phone camera multiple users reliably on network , client specific data bandwidth efficiency using tcp ensure reliability need n no of connections n no of users application have transmit same data on , on connected clients, consume bandwidth processing power allow exclusive access each connection disconnecting or reconnecting client or sending client specific data etc on other hand udp can save bandwidth because copying data handled router etc. said unreliable , dont think allow exclusive control each client tcp (correct me if i'm wrong) so approach should use? edit: data , video sent using custom methods (basically writing video frames etc socket output stream)

json - MVC4 Jquery / UI / Ajax Release Build breaks my form submissions? -

very strange issue. i have mvc4 web application uses pop-up editing (through jqueryui , partial views) , works fine when application built in debug mode, or if it's built in release mode , run on iis express. the httppost action either returns html partialview containing errors (which repopulates ui dialog box) or json response return json(new { success = true }); if deploy debug build iis, works fine. however, if deploy release build iis stops working , client browsers (all of them) start treating json responses file downloads......?! i've fiddled requests , different..... ones work send headers: accept: */* content-type: application/x-www-form-urlencoded; charset=utf-8 x-requested-with: xmlhttprequest ...and ones fail..... accept: text/html, application/xhtml+xml, */* content-type: application/x-www-form-urlencoded ...and no x-requested-with header. tbh i've got no idea why request headers different based on build config....?! help? well f

mybb - Javascript: Redirecting to another site through a popup -

i'm quite bad javascript , can't work out solution need to. i'm having website , i'm trying make redirection site, through popup. example : <script>alert(this prompt message)</scrip> <script>window.location="http://this-will-redirect-me-to-another-link.com";</scrip> like can see use second javascript redirect persons page, due reasons can't use work half of page(the script kinda 'sandboxed'), if i'd make popup(the first alert script) second script out of 'sandbox'. there has ideas how should implement or can done otherwise php or html? i'm having mybb forum , there's shoutbox i'm using. there's command change notice of shoutbox , command such /notice new notice | noted new notice can changed javascript , it'll work such /notice js code here | thought if make such javascript redirect people webpage. i'm having such forum it's needed redirect main page one, i'd apply it

html - PHP form validation using preg_match for password checks -

this general question on password form validation , using combination of uppercase, lowercase, numbers , characters used. research has showed preg_match required validate password (or whatever variable use): (preg_match("/^. (?=.{8,})(?=. [0-9])(?=. [a-z])(?=. [a-z]).*$/") though how how integrate if statement below? i've tried combining them using && though seems ignore preg_match part. if(($pass == $pass2) && (preg_match("/^. (?=.{8,})(?=. [0-9])(?=. [a-z])(?=. [a-z]).*$/")) any advice appreciated. <?php require "dbconn.php"; $username = ($_get['username']); $email = ($_get['email']); $pass = ($_get['pwd1']); $pass2 = ($_get['pwd2']); $usn = ($_get['schoolnumber']); $matching = 0; if($pass == $pass2) { echo "<script type='text/javascript'> window.alert('your details have been registered, please proceed login new credentials!')</script>"

android - downloading terminates when App goes to background -

i working on app, uses phonegap. when app started first time, downloading data server. downloading process being executed in asynctask, , in onpostexecute() of that, loading url. the problem being arose that, when download process getting executed, , app somehow goes background, downloading gets terminated, unfortunately, absolutely not required. to overcome trouble; guess, using service 1 of options. but, in case, question arises, is, how can possibly, load url inside service. otherwise, else can done? please, suggest me possible ways rid off trouble, facing. use similar method downloading data. may helpful. public void downloadusingget(string apkurl, string filename) { try { string path = environment.getexternalstoragedirectory()+"/android/data/"+getpackagename()+"/files/"; url url = new url(apkurl); httpurlconnection c = (httpurlconnection) url.openconnection(); c.setrequestmet

Would this be sufficient validation of a product ID in php? -

i'm working on small webshop limited number of projects using codeigniter. at start of script, products model gets entire list of products , stores result array property of model. the product id's auto incremented primary keys database. when adds product cart id gets sent post. check 3 things: could $id integer? does integer exceed total number of products? does integer match product id? basically -although simplified- this: // count total number of items $total = count($this->productarray) if (!(int)$id || $id > $total) return false; foreach($this->productarray $product) { if ($product['id'] == $id) return true; } return false; does integer exceed total number of products? this not true. delete products out of sync. that said better idea cast id integer, , query product directly on db. not check against preloaded array; makes no sense.

php - How to read Output of Console Command in Yii? -

i trying build cron jobs backup critical data on yii webapplication have built the cconsolecommand class needs run. runs fine , command executed however job requires application parse output of command being run , act accordingly. is there way inside yii framework?? or there in alternative in php-cli let me integrate current class in yii ?? try using extension, may helpful http://www.yiiframework.com/extension/tconsolerunner

javascript - My D3.js code cause new data to be added as a new graph, I want it to be appended to an existing graph. What did I do wrong? -

i have gone through several d3 tutorial briefly i'm bit confused how animation (ie transform, etc) work. i have csv file on server that's being updated separate process , little webpage graph data. here's have. my question is, can see, every 10 seconds, appended new graph, opposed update current graph , draw new point. need change in order have effect? $(document).ready(function() { $.ajaxsetup({ cache: false }); setinterval(function() { $('#file').load('file.csv', function(){ var input = $('#file').html(); var data = $.csv.toobjects(input); var price = []; var time = []; (var row in data){ price.push(data[row]["price"]); } (var row in data){ time.push(data[row]["time"]); } var data = price; w = 400, h = 200, margin = 20, y = d3.scale.li

Eclipse formatter for java ending braces -

i know if it's possible setup eclipse format braces using banner style. we're working code uses banner style formatting , keep consistent within team version control reasons. here's example of banner style formatting not familiar: public class foo { //------------------------ public static void main (string[] args) { boolean condition = true; try { if (condition) { system.out.println ("condition true"); } else system.out.println ("not condition"); } catch (exception ex) { // handle errors } } //------------------------ } update: name style ratliff. experiment java->code style->formatter preferences. "banner style" seems poor use of space given outline view , quick outline functionality.

java - implementing substraction on listview -

hi new on page. i developing app, on android, have listview populate list of numbers, in 1 column have value of items. can add them , sum them in variable total, use onitemclick event on listview, in order of delete rows, want delete row value total variable example. if have values 8 90 3, total 101, if delete value 90 row id 1, how can delete total , set new total 11 new total left substraction. i implement solution substract on value if put 2 values gave me error here implementation: mlistview.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> a, view v, int position, long id) { int k = (int) id; list<data> dcontrol; dcontrol = data; for(data dt: dcontrol){ residuo = integer.parseint(dt.gety()); } resultnumber = resultnumber - residuo; system.out.println(resultnumber); updatetextfield

Getting the current row's rank with Laravel -

in laravel 4 app, users table has votes column. i'd find current user's rank. can top 10 users user::orderby('votes', 'desc')->take(10) , i'd display current user's rank below list. ideally, go like: auth::user()->rank('orderby', 'votes', 'desc'); i logged in user, ask rank assuming order users table votes. does know if there's way can eloquent? although still hacky can via custom getter (mutator) in eloquent. public function getrankattribute() { return $this->newquery()->where('votes', '>=', $this->votes)->count(); } you can users rank attribute. $rank = auth::user()->rank;

url rewriting - URL optimization with php -

i've been trying several ways optimize url result when db of site consulted, changing .htaccess adding php @ top, , other ways include both, nothing happens, there many ways around web i'm feeling unlucky , kind of powerless trying implement of ways, can't make work. the products catalog organized in popular way in mysql db, nothing revolutionary or unique, $_get method , that's all, got department, category or product user clicks. can give me this? kind of basic advanced developers not one. in advance time! the .htaccess code here: <ifmodule mod_rewrite.c> rewriteengine on rewriterule testpage\.html http://www.google.com [r] rewriterule ^catalog/(\d+) catalogo.php?cat=$1 [l,nc] rewriterule ^department/(\d+) catalogo.php?dpto=$1 [l,nc] rewriterule ^producto/(\d+) producto.php?id=$1 [l,nc] </ifmodule> rewriteengine on rewriterule ^catalog/(\d+) catalog.php?cat=$1 [l,nc] that basic regex match category (\d+) - digit - , map category.php

windows phone 7 - Every Album Art is the same -

i'm making music-player windows phone (c#). decided start app pivot-pages. 1 of them list of albums , there album art on left side of list. made class properties: bitmapimage artwork; album alb; and made viewmodelclass binding: observablecollection<viewmodelhelper.albumhelper> albums = new observablecollection<viewmodelhelper.albumhelper>(); public observablecollection<viewmodelhelper.albumhelper> albums { { return albums; } } public albenviewmodel() { loadalbums(); } public void loadalbums() { using (medialibrary medialib = new medialibrary()) { bitmapimage bmp = new bitmapimage(); foreach (album alb in medialib.albums) { if (alb.hasart == true) { bmp.setsource(alb.getalbumart()); albums.add(new viewmodelhelper.albumhelper(bmp, alb)); } else

ruby - Nesting modules inside of a Rails eninge gem -

what proper syntax nest child modules within parent module being isolate_namespace rails engine gem? # lib/myengine/engine.rb module myengine class engine < rails::engine isolate_namespace myengine # def ... end end for example. parent module myengine , child module blog. myengine share common domain, crud, taggable, searchable, etc, keep gem code dry , isolated main app (myapp), while inheriting isolated namespace , engine. are either of 2 approaches correct? refactor advice? # # lib/myengine/blog.rb module myengine module blog # def ... end end # b # lib/myengine/blog.rb module myengine class engine < rails::engine isolate_namespace myengine module blog # def ... end end end option a. correct, should lib/my_engine/blog.rb . can read more ruby & rails naming conventions here . further, if want put more modules or classes under blog namespace put them in folder lib/my_engine/blog , nest them under myengine::bl

How to identify the records that belong to a certain time interval when I know the start and end records of that interval? (R) -

so, here problem. have dataset of locations of radiotagged hummingbirds i’ve been following part of thesis. might imagine, fly fast there intervals when lost track of until found them again. trying identify segments bird followed continuously (i.e., intervals between “lost” periods). id type timestart timeend limiter starter ender 1 observed 6:45:00 6:45:00 no start end 2 lost 6:45:00 5:31:00 yes no no 3 observed 5:31:00 5:31:00 no start no 4 observed 9:48:00 9:48:00 no no no 5 observed 10:02:00 10:02:00 no no no 6 observed 10:18:00 10:18:00 no no no 7 observed 11:00:00 11:00:00 no no no 8 observed 13:15:00 13:15:00 no no no 9 observed 13:34:00 13:34:00 no no no 10 observed 13:43:00 13:43:00 no no

linux - Change in gnu ld linker behavior -

when went using gnu ld version 2.20 2.21 , began seeing following change in behavior. not sure if broken behavior in 2.20 fixed in 2.21 or if else going on. libfoo.so : provides symbols foo() libfoobar.so : provides symbol bar() , specifies libfoo.so in dt_needed slot main.cpp : uses symbols foo() bar() previously, build main.cpp doing : g++ main.cpp -lfoobar the internal dependency of foobar.so on foo.so ensure foo() bar() found now, above not work , have explicitly link foo : g++ main.cpp -lfoobar -lfoo so question : right behavior - if .so has dependencies, considered when searching symbols used directly in executable or these dependencies available in private namespace .so only? thanks. so question : right behavior the new behavior right one. if .so has dependencies, considered when searching symbols used directly in executable no. whatever dependencies libfoobar.so has private implementation detail, can change tomorrow. should not cou

mysql - COMException using ODBC while trying to list "Views" in Codesmith -

i have established odbc connection mysql server (odbc driver version 5.1 oracle). connection test succeeds! if click show tables of database succeeds well. trying show views , following error: das objekt oder der provider kann den angeforderten vorgang nicht ausführen. (translated: object or provider not capable of performing requested operation.) error of type "comexception" occurred while attempting populate schema information. please check data source settings , try again. ----------------------------------- system.runtime.interopservices.comexception (0x800a0cb3): das objekt oder der provider kann den angeforderten vorgang nicht ausführen (translated: object or provider not capable of performing requested operation.) @ adox.views.get_count() @ schemaexplorer.adoxschemaprovider.getviews(string connectionstring, databaseschema database) @ schemaexplorer.cachedschemaproviderproxy.getviews(string connectionstring, databaseschema database) @ schemaexplorer.database

javascript - rotate object onclick -

so have code supposed add when clicked "+10" button 10degree rotation object, when clicked "+30" button 30degree rotation object, 90degree position max available. ads 1 , dont know how make move degree want move. http://jsfiddle.net/9xghf/ var rotateobject = document.getelementbyid("object"); var objectrotation = 0; var add10 = document.getelementbyid("add10"); var add30 = document.getelementbyid("add30"); add10.onclick = function(){ rotate(0, 10); } add30.onclick = function(){ rotate(0, 30); } function rotate(index, limit){ if(objectrotation < 90 && index <= limit){ index++; objectrotation++; rotateobject.style.transform="rotate(" + objectrotation + "deg)"; rotateobject.style.webkittransform="rotate(" + objectrotation + "deg)"; rotateobject.style.mstransform="rotate(" + objectrotation + "deg)";

java - Restoring code from JAR -

i accidentally deleted whole folder nest thingy workspace project i'm working on , have exported jar file. is there way open jar file eclipse or that? i have tried extracting jar desktop , dragging files eclipse doesn't work. gives me classes cannot use them. is there way can code jar file? you need java decompiler : http://java.decompiler.free.fr/ download jd-gui , open jar program , "save sources" someplace.

post - Radio buttons: PHP only passing "Other" value -

i've borrowed several versions of php (from here , other sites) pass selected amount in radio fieldset ecommerce gateway, regardless of have tried, pass amount entered "other" field (which simple text box). of radio buttons selected, error indicating field missing or wrong format. first time using php, assistance provided @ first-grade level appreciated! though problem seems related if else if statement, included entire php because don't understand how php works. thanks. <?php $x_login = "hco-st.-t-902"; // hosted payment page id. $transaction_key = "6~~xpvr~xmjxn_rkcc99"; // if(isset($_post['amount'])) { if($_post['amount'] == '5') { $x_amount = "5.00"; } elseif($_post['amount'] == '10') { $x_amount = "10.00"; } elseif($_post['amount'] == '25') { $x_amount = "25.00"; } elseif($_post['amount'] ==

jquery - Send javascript popup results to form field -

i have form captures co-ordinates , send server postcode , returns. upon clicking location, popup field prefer result go form field instead. javascript function showlocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; $.getjson('http://www.uk-postcodes.com/latlng/' + position.coords.latitude + ',' + position.coords.longitude + '.json?callback=?', null, gotpostcode); } function errorhandler(err) { if(err.code == 1) { alert("error: access denied!"); }else if( err.code == 2) { alert("error: position unavailable!"); } } function gotpostcode(result) { var postcode = result.postcode; $("#postcodegoeshere").val(postcode); } function getlocation(){ if(navigator.geolocation){ // timeout @ 60000 milliseconds (60 seconds) var options = {timeout:60000}; navigator.geolocation.getcurrentposition(showlocation,

sql - Use two queries to populate table with INSERT statement -

could elucidate me why following not work: insert druginteractions(ndc_fk, ndc_pk) (select top 1 ndc druglist drug_name 'cipro%'), (select top 1 ndc druglist drug_name 'tizan%') the column ndc in druglist primary key uniquely identifies drug. since need 2 things interact druginteractions table has 2 copies of ndc ; these 2 ndc s composite primary key. drug has ndc of 1 , drug b has ndc of 2, row in druginteraction like: ndc_pk ndc_fk 1 2 is there way populate table using insert statement 2 queries, 1 each column i'm trying? error is: msg 102, level 15, state 1, line 2 incorrect syntax near ',' you need use values combine them; insert druginteractions(ndc_fk,ndc_pk) values( (select top 1 ndc druglist drug_name 'cipro%'), (select top 1 ndc druglist drug_name 'tizan%') ) an sqlfiddle test with .

xml - How to categorize containers in Unity configuration file -

is possible apply category attribute container tag can later use retrieve containers? i looking in config file: <container name="example1" category="externalservice"> <container name="example2" category="externalservice"> <container name="example3" category="miscellaneous"> then in code want able like... section.containers.where(c => c.category == "externalservice").tolist(); thanks! i think can't. use kind of "namespace" categorize containers: <container name="externalservice.example1"> <container name="externalservice.example2"> <container name="miscellaneous.example3"> and then: section.containers .where(c => c.category.startswith("externalservice.")) .tolist();

android - Disable misspelling flag of specific words in app? -

our company's name comes misspelled (the red underline) when typed edittext fields in our app. there way can disable misspelling flag specific word avoid nagging feature? and before suggests android:inputtype="textnosuggestions" , still spellcheck available specific field, , exclude our company name. i have no idea if it'll work, can try putting android.text.style.localespan on each occurrence of company name, using locale.root (which has no language) target locale. (most of time encounter charsequence in text view can cast spannable . if can't, copy contents spannablestringbuilder .)

wpf - Passing BitmapImage as Tag to DataTemplate -

i'm bit unexperienced in wpf , trying simple template in wpf button image icon in addition text work. style code: <style x:key="databasebuttonwithimagetag" targettype="button" basedon="{staticresource databasebutton}"> <setter property="contenttemplate"> <setter.value> <datatemplate> <grid> <grid.columndefinitions> <columndefinition width="1*" /> <columndefinition width="2*" /> </grid.columndefinitions> <image grid.column="0" width="100" source="{templatebinding tag}" /> <contentcontrol grid.column="1" content="{templatebinding content}" /> </grid> </datatemplate> </setter.value>

html - CSS Styles are not available on Firefox/IE -

i designed website using dreamviewer. styles applied webpage not available on firefox , ie, webpage displayed in plain html format. styles displayed in chrome.what reason , how can fix problem? this stylesheet * { padding:0; margin:0; border:0; } p { font-family:arial, helvetica, sans-serif; font-size:12px; color:#202020; line-height:180%;} h1, h2, h3, h4 { color:#00486a; font-family:arial, helvetica, sans-serif;} h1 { padding: 5px 5px 10px 0; font-size:24px;} #wrapper { margin:5px auto; width:1000px; background-color:#e6e6ff;} /*opacity:0.8; filter:alpha(opacity=80)}*/ body { background:url(../img/backgrounds/sparkling_design-hd.jpg); background-repeat:repeat; } #logo { float:left; margin:10px 5px 10px 20px; opacity:1; ;} #logo img { opacity:1;} #loginform { float:right; padding: 20px 30px 10px 10px; margin: 10px 10px; } #loginform { float:right; clear:both; } #loginform a:link { font-family:arial, helvetica, sans-serif; font-size:12p