Posts

Showing posts from August, 2011

How to replace first occurrence of string in Java -

i want replace first occurrence of string in following. string test = "see comments, test, us" **if test contains input follows should not replace see comments, (with space @ end) see comments, see comments** i want output follows, output: test, thanks in advance, you can use replacefirst(string regex, string replacement) method of string.

c++ - hash_map not working -

#include <ext/hash_map> using namespace std; class hash_t : public __gnu_cxx::hash_map<const char*, list<time_t> > { }; hash_t hash; ... i'm having problems using hash_map. const char* im using key 12 length number format 58412xxxxxxx. know there 483809 different numbers, should hash_map size after inserting everything, i'm getting 193 entries. hash_t::iterator = hash.find(origen.c_str()); if (it != hash.end()) { //found x++; (*it).second.push_front(fecha); } else { //not found y++; list<time_t> lista(1, fecha); hash.insert(make_pair(origen.c_str(), lista)); } the same procedure works using python dictionaries (i'm getting correct number of entries) not close using c++. possible since every key begins 58412 (actually every key, not of them, , that's reason don't want chop 5 chars), im getting lot of collisions? const char* not key, since have pointer comparison instead of strin...

css - Why aren't my hyperlinks changing colors or underlining? -

why aren't hyperlinks changing colors or underlining? have in css in standard vs 2010 site: a:link, a:visited { color: #034af3; outline: none; } a:hover { color: #1d60ff; text-decoration: none; outline: none; } a:active { color: #034af3; outline: none; } p { margin-bottom: 10px; line-height: 1.6em; } what doing wrong? in wrong spot? thanks! you have set not display text-decoration on hover. with hover decoration: http://jsfiddle.net/kbznb/ without hover decoration: http://jsfiddle.net/kbznb/1/ it looks changing color, due color similarities of #1d60ff , #034af3

Should an array or a class be used for holding multiple variables in PHP? -

currently, creating script parse information out of type of report passed it. there part of script pull students information report , save later processing. is best hold in form of class, or in array variable? figure there 3 methods use. edit: really, question comes down 1 way have sort of performance advantage? because otherwise, each method same last. as class direct access variables: class studentinformation { public $studentid; public $firstname; public $lastname; public $middlename; public $programyear; public $timegenerated; function studentinformation(){} } as class functions: class studentinformation { private $studentid; private $firstname; private $lastname; private $middlename; private $programyear; private $timegenerated; function studentinformation(){} public function setstudentid($id) { $this->studentid = $id; } public function getstudentid() { return $th...

Externalize strings in Javascript -

i have been searching on line tool externalized strings in javascript have been unable so. hoping there similar 1 built eclipse (source -> externalize strings...). if knows of tool or plugin eclipse accomplish that, let me know. we have software project mature needs support translations, , hence need string externalized. i suggest use json-based language look-up table if want populate these values via javascript. eclipse cannot this. see: localization in web app using javascript , json

sql server - Using stored procedure output parameters in C# -

i having problem returning output parameter sql server stored procedure c# variable. have read other posts concerning this, not here on other sites, , cannot work. here have. trying print value comes back. following code returns null value. trying return primary key. have tried using @@identity , scope_indentity() (i.e. set @newid = scope_identity() ). stored procedure: create procedure usp_insertcontract @contractnumber varchar(7), @newid int output begin insert [dbo].[contracts] (contractnumber) values (@contractnumber) select @newid = id [dbo].[contracts] contractnumber = @contractnumber end opening database: pvconnectionstring = "server = desktop-pc\\sqlexpress; database = pvdatabase; user id = sa; password = *******; trusted_connection = true;"; try { pvconnection = new sqlconnection(pvconnectionstring); pvconnection.open(); } catch (exception e) { databaseerror = true; } executing command: pvcommand = new sql...

python - How to perform multiple changes to a csv file without intervening writes -

i want perform multiple edits rows in csv file without making multiple writes output csv file. i have csv need convert , clean specific format program use. example, i'd to: remove blank rows remove rows value of column "b" not number with new data, create new column , explode first part of values in column b new column here's example of data: "a","b","c","d","e" "apple","blah","1","","0.00" "ape","12_fun","53","25","1.00" "aloe","15_001","51","28",2.00" i can figure out logic behind each process, can't figure out how perform each process without reading , writing file each time. i'm using csv module. there better way perform these steps @ once before writing final csv? i define set of tests , set of processes. if tests pass, processes appl...

netbeans - way2sms api not working in java -

i using way2sms api in web application. working fine not able send sms. can tell me must have gone wrong suddenly. api outdated? or there problems way2sms site or gateway? here's code wrote, you'll find useful. import java.net.*; import java.io.*; public class smssender { //replace way2sms username , password below static final string _username = "your way2sms username"; static final string _password = "your way2sms password"; static final string _url = "http://ubaid.tk/sms/sms.aspx"; static final string charset = "utf-8"; //to build query string send message private static string buildrequeststring(string targetphoneno, string message) throws unsupportedencodingexception { string [] params = new string [5]; params[0] = _username; params[1] = _password; params[2] = message; params[3] = targetphoneno; params[4] = "way2sms"; string query = string.format("uid=%s...

python - PyCharm can't find the right paths if I open a directory that is not the Django root -

our projects structured: /project-name /src /django-project-name etc.. readme.md requirements.txt if open /project-name instead of /django-project-name pycharm underlines imports saying can't find , tries reference imports src.django-project-name.app_name.models.thing can't found when run django. how can work same when mount /djang-project-name gets these things right? i fixed going file -> preferences -> project structure selecting /django-project-name in tree , clicking sources add it.

javascript - keydown event new value -

browser: google chrome v19.0.1084.52 i have textbox needs number less or equal 255, on keydown want check if value above or equal 255 else prevent event. in console when console.log event show event.srcelement.value value appear i.e. 12 => 123, when console.log event.srcelement.value show input was, not be. console.log's happening 1 after other, nothing in between, no pauses. how can find new value of textbox on keydown , why console.log returning different results? thanks here's code: function inputnumeric(event,max) { console.log (event); console.log ('event.originalevent.srcelement.value: '+event.originalevent.srcelement.value); console.log ('event.srcelement.value: '+event.srcelement.value); } $("#rs485addr").keydown(function(event) { inputnumeric(event); }); console.log: event.originalevent.srcelement.value: 12 event.srcelement.value: 12 event.srcelement: accept: "" accesskey: "...

java - how to access collection returned by jpql from ejb in managed bean -

i have app need fire jpql query sum() , func(year,...) functions, means 2 fields fetched , stored collection , collection returned managed bean. question how use collection retrieve each value. below session bean , managed bean code: public collection getscripqtyyearwise(integer scripid) { try { collection coll=em.createquery("select sum(t.tradeexecutedquantity), func('year',t.tradedatetime) tradestock t t.scripid.scripid = :scripid group func('year',t.tradedatetime) ").setparameter("scripid", scripid).getresultlist(); return coll; }catch(exception e){return null;} } eg of data returned: sum(qty) year 210 2011 198 2012 need extract each of values in each record returned in followinf managed bean: objejb=(stockcommodityejbstateless) new initialcontext().lookup("stockcommoditytest"); collection coll=objejb.getscripqtyyearwise(scripid1); // how u...

regex - Get a non inline css from javascript -

i know critic want, ask question. i know can't style of element if css weren't formated inline. want regex (because not make one) style tags , apply regex innerhtml make array 1 : css["mydiv"]["color"] -> "red" without using getcomputedstyle because of browser incompatibility. there no way achieve remotely close using regex. css rules applied using complicated algorithm , rules may inherited, prioritized , overridden in various ways. no coincidence took major browsers years come compliant implementation. you should exercise implementation instead. tool need javascript , api need dom. each node in dom there style object contains applied styles , has format close trying generate. can access via getcomputedstyle , currentstyle .

c++ - How does OpenMP implement access to critical sections? -

i want read input file (in c/c++) , process each line independently fast possible. processing takes few ticks itself, decided use openmp threads. have code: #pragma omp parallel num_threads(num_threads) { string line; while (true) { #pragma omp critical(input) { getline(f, line); } if (f.eof()) break; process_line(line); } } my question is, how determine optimal number of threads use? ideally, dynamically detected @ runtime. don't understand dynamic schedule option parallel , can't if help. insights? also, i'm not sure how determine optimal number "by hand". tried various numbers specific application. have thought cpu usage reported top help, doesn't(!) in case, cpu usage stays consistently @ around num_threads*(85-95). however, using pv observe speed @ i'm reading input, noted optimal number around 2-5; above that, input speed becomes smaller. quesiton is- why see cpu usage of 850 when using 10 threads?? can d...

javascript - Submit the form only if email is valid -

i need way submit form if email valid. if email not valid show alert ( below can see code ). javascript: function validateemail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/; return re.test(email); } function continueornot() { if(validateemail(document.getelementbyid('emailfield').value)){ // ok }else{ alert("email not valid"); return false;} } html: <form method="post" action="register.php" enctype="multipart/form-data"> <table> <tr><td>email:</td></tr> <tr><td><input type="text" size="30" name="email" id="emailfield"> </td></tr> <tr><td>password:</td></tr> <tr><td><input type="password" s...

caching - How can I cache (cache on my server) a site like Stackoverflow written in PHP -

i have tried make own practice , finished basics. have never cached more javascript , css before. have tried searching , google cant clear on following questions. i want know pages should cached on server. i.e should cache page questions/45/title-goes-here? how cache header part if username different everyone? do dump whole file text file every single question? doesn't seem practical. how set cache page used button. sorry if answers obvious, have researched , dont it. thanks your caching system set of tools quick lookups on things "expensive" generate , don't change much. to determine should cached, need study work far , figure out parts taking cpu or database time. , cache those. for caching stackoverflow, perhaps 1 strategy might generate cache object html of each question, including s populated afterwards using javascript. process of looking question , tags might more time consuming looking single cache entry includes both. for head...

delphi - What can I do about maximized, styled windows, which show their borders on adjacent monitors? -

on multi-monitor system, "blank" vcl application maximizes fine, same application styles enabled (and 1 chosen default) maximizes incorrectly. i'm seeing right-hand edge of window extend onto 2nd monitor (my main on left). when started comparing other windows apps, noticed under windows 7 (at least), maximized windows not have non-client borders on left, right or bottom sides. , indeed, standard vcl (non-styled) app behaves same way, without non-client borders. how fix this? notice tformstylehook has handler wmnccalcsize, haven't dissected yet, makes me wonder if vcl might incorrectly handling message maximized window. after fiddling time on this, take is, not vcl-styles bug @ all. indeed related behavior in article mentioned in comment question mghie . the specific behavior that, size of maximized window larger work area of monitor window maximized on. supposedly, window manager hides overhang borders. apparently, doesn't quite customized frame...

javascript - PHP not able to echo form input while using Ajax -

my php file echo's statement cannot echo actual value given user. i using ajax , on left hand side there form asks email id. when email id entered , form submitted, results need show on right hand side. on submitting form though, php able echo statement "you have entered :" cannot echo actual email id entered. pls help this form:- <form action="javascript:ajaxpage('files/search2.php', 'columntwo')" method="post"> email :<input type="text" name="email" value=""/> <input type="submit" value="submit">` </form> this php file:- <?php $email = $_post['email']; echo "the email id :"; echo $email; ?> <html> <body> <h1>hello world</h1> </body> </html> only message "the email id :" displayed $email not displayed first : use eve...

javascript - How to display a unordered list with unique bullets based on condition? -

i generating list sql server, filtering based on new , old records , displaying them in respective categories on webpage. want show unique list bullets old , new records. im getting mashup of every record each category on top of eachother. icons list items coming twitter bootstrap css, using glyphicons. new records have popover displays on hover. list-generating code foreach($resultarray $category_name => $items) { echo '<h3>'. $category_name.'</h3><ul>'; foreach($items $itemid => $itemdetails) { ?> <li class="<?php if(strtotime($itemdetails['posted']) > (strtotime('-30 days'))){echo 'icon-star';} else {echo '';} ?>" data-content="this item new on corkboard. check out!" data-original-title="new item"> <?php echo '<a href="newgenview.php?id='.$itemid.'">'.$itemdetails['name'].' - '.$itemdet...

wordpress - I want to add conditional logic functionality to cforms plugin -

i want add conditional logic functionality cforms plugin. existing contact form needs following added feature: user selects type of product have dropdown on form. based on choice make, unique auto-responder email sent them. there going 10 different auto-responses depending on of 10 drop-down choices select in form. auto-responses need accessible , editable within cforms. can 1 have clue how this. cforms provide ?. possible ways ? is there alternate plugins provide functionality. thanks. after using contact form 7, cforms... while, bit bullet , bought gravity forms . it's more polished , easier update cforms. conditional logic.

sockets - Java: Read/Write compressed objects over TCP -

i have transfer records on tcp though sockets. used objectinputstream , objectoutputstream , worked fine. 1 critical think socket opened once , has remain open through whole communication each side reads , writes more once (so more persistent connection). i tried compress objects before writing them in order increase overall performance , results quite encouraging but, since used gzipoutputstream , bytearrayoutputstream , memory overhead large , in case outofmemory error. i tried deflateroutputstream didn't seem apropriate writting objects. there way solve problem? java serialization convenient, rather ineffective both size-wise , in cpu usage. if want high performance, suggest use different communication protocol, example based on protocol buffers or else light-weight.

javascript - Load URL into iframe and find values of the HTML that was just loaded - Jquery -

i trying load url iframe doing following jquery code. problem when try find element of iframe loaded, returns content loaded in previous click. , first click null. can me around this? thanks $(document).ready(function() { $('.popup').click(function() { $('#myiframe') .attr('src', $(this).attr('href')) .attr('frameborder', '0') return false; }); alert($('#myiframe').contents().find('.name').html()) }); you need wait the fetched url load iframe before can fetch contents it. can use the jquery .load() function this. this: $(document).ready(function() { $('.popup').click(function() { $('#myiframe') .attr('src', $(this).attr('href')) .attr('frameborder', '0') .load(function() { alert($(this).contents().find('.name...

mesh - Reconstruct surface from 3D triangular meshes -

i have 3d model, consists of 3d triangular meshes. want partition meshes different groups. each group represents surface, such planar face, cylindrical surface. surface recognition/reconstruction. the input set of 3d triangular meshes. output mesh segmentations per surface. is there library meets requirement? if want go lots of mesh processing, point cloud library idea, i'd suggest cgal: http://www.cgal.org more algorithms , loads of structures aimed @ meshes. lastly, problem describe solved on own: enumerate vertices enumerate polygons create array of ints size of number of vertices in "big" mesh, initialize 0. create array of ints size of number of polygons in "big" mesh, initialize 0. initialize counter 0 for each polygon in mesh, @ vertices , value each has in array. if values each vertex zero, increase counter , assign each of values in vertex array , polygon array correspondingly. if not, relabel vertices , polygons higher num...

trouble with this case statement Ruby -

can me understand how write case statement not working , noob have no idea how fix it: def hide_link?(link, mailing) case link when 'edit' && ['sent', 'sending', 'archived'].include?(mailing.status) return true when 'send_schedule' && ['sent', 'sending', 'archived'].include?(mailing.status) return true when 'archive' && ['archived'].include?(mailing.status) puts "i should in here" return true else 'dashboard' && ['sending', 'draft'].include?(mailing.status) return true end end basically want return true when link matches criteria. i believe if link doesn't match these criterias method should return false. thus: def hide_link?(link, mailing) case link when 'edit' ['sent', 'sending', 'archived'].include?(mailing.status) when 'send_schedule...

mysql - is there a tool that can show a live log of all the sql commands the mysql engine receives? -

using mysql - there tool can show live log of sql commands mysql engine receives? a. helpfull see explain plan dml commands. b. helpfull if turned on , off on mysql server no need restart service. c. open source/free mysql nice. thanks. you first need activate general query log . there must tools around parse log, favourite being : tail -f /path/to/mysql.log ;) unfortunately, may not disabled dynamically, need restart server in order activate/disable log. careful, though, activating log has severe performance impact. not use in production.

deployment - Error code 40 when running SSRS reports from Internet Explorer (run as administrator) -

we deployed vb.net application on customer's computer contains ssrs reports. the application connects sql server database in app without problems. installed sql server data tools deploy reports (rdl) , data source (rdl) files report server. these deploy without problems. in sql server data tools can "preview" reports without problems well. we run problem when attempting view report internet explorer (run administrator). we following error: cannot create connection data source 'datasourcereports' (this name used targetdatasourcefolder) error:40 - not open connection sql server we same error when app deployed runs reports. please let know not set correctly on sql server side. a possibility experiencing double hop authentication problem. it's not clear explanation, sql server database on separate server report server? if so, credentials allow connect report server windows integrated security not pass credentials on sql server database...

Android , HTC WIdget animations -

how possible animations on widgets happen in htc weather widgets? way t go such animations? since app widgets limited in functionality, how can achieve these ? kindly give suggestions? you can use gif achieving animation. refer android api can refer frame animation guide of android

android - Wi-Fi Direct and "normal" Wi-Fi - Different MAC? -

Image
i'm trying connect 2 phones know each other's mac address via wi-fi direct, , stumbled upon following problem: mac address, receive wifimanager wifiman = (wifimanager) .getsystemservice(context.wifi_service); wifiinfo wifiinf = wifiman.getconnectioninfo(); mac_address = wifiinf.getmacaddress(); is different 1 receive wifip2pmanager when discovering , requesting peers. example: a0:xx:xx:... turns a2:xx:xx.... know why? did not find way "wi-fi direct mac address", , thought mac address should unique, , it's same wi-fi module handles both (normal wi-fi , p2p/direct). weird.. should do? 2 devices (galaxy nexus) i've got, it's first 2 characters differ in mac addresses - should discard them? probability encounter problems (two devices differ in first part of mac address) high? thanks. reading mac address on wikipedia. addresses can either universally administered addresses or locally administered address...

javascript - Jquery AJAX not loading page, despite page existing -

i'm relatively new whole ajax thing , i'm editing script open modal box, , load requested content said box. have following javascript jquery(document).ready(function($){ $('a[name=modal]').click(function(e) { e.preventdefault(); var maskheight = $(document).height(); var maskwidth = $(window).width(); //set height , width mask fill whole screen $('#mask').css({'width':maskwidth,'height':maskheight}); $('#mask').fadeto(600,0.75); var load_page = $(this).attr('ajax'); //get window height , width var winh = $(window).height(); var winw = $(window).width(); // set loading html displayed var loadinghtml = '<center><img src="_img/progress_bar.gif"/></center>'; //set loading bar $('#placeholder').html(loadinghtml).fadeto(600,1); $('#placeholder').css('top', winh/2-$('#placeholder')....

java - Regex with -, ::, ( and ) -

i need split string (age-is-25::or::last_name-is-qa6)::and::(age-is-20::or::first_name-contains-test) into string[0] = (age-is-25::or::last_name-is-qa6) string[1] = and string[2] = (age-is-20::or::first_name-contains-test) i tried writing many regex expressions, nothing works expected. using following regex, matcher.groupcount() returns 2 assigning results arraylist returns null elements. pattern pattern = pattern.compile("(\\)::)?|(::\\()?"); i tried split using ):: or ::(. i know regex looks stupid, being beginner best write. you can use positive lookahead , lookbehind match first , last parentheses. string str = "(age-is-25::or::last_name-is-qa6)::and::(age-is-20::or::first_name-contains-test)"; (string s : str.split("(?<=\\))::|::(?=\\()")) system.out.println(s); outputs: (age-is-25::or::last_name-is-qa6) , (age-is-20::or::first_name-contains-test) just note however: seems parsing k...

Android and exception on introducing own custom key store -

i'm generating keystore certificate follows: export classpath=/developer/bouncycastle/bcprov-jdk16-146.jar certstore=~/bitbucket/android/cooorijed/res/raw/mykeystore.bks if [ -a $certstore ]; rm $certstore || exit 1 fi keytool \ -importcert \ -v \ -trustcacerts \ -alias 0 \ -file <(openssl x509 -in mycert.pem) \ -keystore $certstore \ -storetype bks \ -provider org.bouncycastle.jce.provider.bouncycastleprovider \ -providerpath /developer/bouncycastle/bcprov-jdk16-146.jar \ -storepass password this generates key store without apparent problem. in eclipse clean android project , see "mykeystore.bks" in raw folder. load key store follows: private keystore keystore() { try { keystore trusted = keystore.getinstance("bks"); inputstream in = context.getresources().openrawresource(r.raw.mykeystore); try { trusted.load(in, "pas...

arrays - loading data from a json -

i have data available want load this: { "success": true, "message": null, "total": null, "data": [{ "clocktypes": ["_12", "_24"], "speedtypes": ["mph", "kmph"], "scheduletypes": ["default", "auto"] }]} i normaly load data this ext.define('myapp.store.combotimezone', { extend: 'ext.data.store', constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callparent([ext.apply({ autoload: true, storeid: 'myjsonstore5', proxy: { type: 'ajax', url: 'json/timezone.json', reader: { type: 'json', root: 'data' } } }, cfg)]); }}); now clocktypes 1 record in combobox. how can 2 records: _12 , _24 in combobox? your root should be... data.clocktypes -...

ios - How to properly open and close a NSStream on another thread -

i have application connects server using nsstream on thread. application closes connection should user decide log out. problem never able close stream or thread upon having user disconnect. below code sample on how approach creating thread network , trying close stream: + (nsthread*)networkthread { static nsthread *networkthread = nil; static dispatch_once_t oncetoken; dispatch_once(&oncetoken, ^{ networkthread = [[nsthread alloc] initwithtarget:self selector:@selector(networkthreadmain:) object:nil]; [networkthread start]; }); return networkthread; } + (void)networkthreadmain:(id)sender { while (yes) { @autoreleasepool { [[nsrunloop currentrunloop] run]; } } } - (void)scheduleinthread:(id)sender { [inputstream scheduleinrunloop:[nsrunloop currentrunloop] formode:nsrunloopcommonmodes]; [inputstream open]; } - (void)closethread { [inputstream close]; [inputstream removefromrunl...

c# - CurrentCellDirtyStateChanged commits too soon -

i have datagridview text column , checkbox column. when user clicks checkbox want prompt user. i've got working using code below: private void grid_currentcelldirtystatechanged( object sender, eventargs e ) { var grid = sender datagridview; if ( grid.iscurrentcelldirty) grid.commitedit( datagridviewdataerrorcontexts.commit ); } however, when try type in text column keeps committing type instead of when i'm finished typing. causes text cell keep highlighting , allowing me enter single character. how modify event handle when checkbox value changes? what need pay attention checkbox, not text. solution have found similar problem put event on cellenter recorded field being edited. dirty handling event checks decide do. why coordinates aren't available in dirty check can't imagine.

javascript - "Skip Navigation" Link without anchors -

i trying create "skip navigation" link without being able use anchors. site built in peculiar way, anchor link formatting has been re-purposed. so, attempting allow people skip navigation using focus. however, isn't working. html code skip navigation link itself: <!-- start top left in nav bar --> <aside> <a href="" onclick="javascript:skipnav()" tabindex="1" id="skipnav" role="link">skip navigation</a> </aside> <!-- end top left in nav bar --> code change focus var nav = document.getelementbyid('#skipnav'); nav.onclick=skipnav(); function skipnav(){ document.activeelement.blur(); if ($('#linkhome').hasclass('current')==true) { $('#homefocus').focus(); } if ($('#linkteam').hasclass('current')==true) { $('#teamfocus').focus(); } if ($('#linktraining').hasclass(...

ruby on rails - How to render HTML inside Slim templates -

i'm trying render link preceded icon. i'm using slim templating engine along bootstrap css . usually following way: <a href="#"><i class="icon-user"></i> profile</a> according slim's documentation, can use == render without escaping html. so, translating slim, tried following variations: li== link_to "<i class='icon-user'></i> profile", current_user li== link_to "#{'<i class="icon-user"></i>'.html_safe} profile", current_user li= link_to "#{'<i class="icon-user"></i>'.html_safe} profile", current_user all variations rendered <a href="/users/1"><i class="icon-user"></i> profile</a> escaping i tag. how can stop slim or rails escaping html? (rails 3.2 slim 1.2.1) you want disable html escaping link_to argument, not entire link_to result. you're p...

How to add pagelines to a EditText in android? -

Image
is possible show pagelines in edittext ? i mean these lines: let's edittext 500 500 pixels in size. want lines visible across 500 500 square. is there build in way this? tried google couldn't find answer. guess other option dynamically create graphic based on textheight , linespacing, such ugly work-around. the notepad application sample android dev site shows how this. http://developer.android.com/resources/samples/notepad/index.html looks (scroll down code): most of relevant code in this file . pay attention linededittext inner class. defined within activity. draws lines required. inside activity oncreate() method, setcontentview(r.id.note_editor) set view, defined here snippet extracted here . update : code modified @pieter888 draw lines on entire edittext control. import android.content.context; import android.graphics.canvas; import android.graphics.paint; import android.graphics.rect; import android.util.attributeset; import and...

hadoop - strange behavior of flume-ng -

i trying aggregate apache web server logs hdfs using flume-ng..but strangely getting first few rows hdfs..more strangely every time start agent 2 files getting created , second file smaller first one. agent conf file looks this: agent1.sources = tail agent1.channels = memorychannel-2 agent1.sinks = hdfs agent1.sources.tail.type = exec agent1.sources.tail.command = tail -f /var/log/apache2/access.log.1 agent1.sources.tail.channels = memorychannel-2 agent1.sinks.hdfs.channel = memorychannel-2 agent1.sinks.hdfs.type = hdfs agent1.sinks.hdfs.hdfs.path = hdfs://localhost:9000/flume agent1.sinks.hdfs.hdfs.file.type = datastream agent1.channels.memorychannel-2.type = memory also not getting error message on terminal..is normal or mistake part??

ruby - How do I scrape reviews on the web? -

i want scrape reviews various products , things in web, how can that. there company called searchreviews.com, it, want know how it. they page's html parse it, targeting whatever information need. it's awful, because depends on dom of site you're scraping, can change @ time, in both trivial , complex ways. i've worked companies have scraped (legitimately) various types of sites, , it's horrible.

c# - 'System.Data.SqlClient.SqlConnection' threw an exception Windows 7 -

a bunch of our new users got brand new windows 7 pc's , i'm not sure why i'm getting below error when application starts. run app admin , still exception thrown. thanks! appreciated! users administrators of own pc. the type initializer 'system.data.sqlclient.sqlconnection' threw exception. system.typeinitializationexception: type initializer 'system.data.sqlclient.sqlconnectionfactory' threw exception. ---> system.typeinitializationexception: type initializer 'system.data.sqlclient.sqlperformancecounters' threw exception. ---> system.io.fileloadexception: not load file or assembly 'file:///c:\users\\omain\appdata\local\apps\2.0\7lmdr8e0.x2t\60x0dgvm.vvw\asce..tion_6bf0e6a67bb42923_0001.0000_1a6b34a6368d30ed\creation.exe' or 1 of dependencies. access denied. @ system.reflection.runtimeassembly._nload(assemblyname filename, string codebase, evidence assemblysecurity, runtimeassembly locationhint, stackcrawlmark& stackmark...

blackberry - SQLite keep expanding -

i'm new blackberry development , site. right now, i'm working on app retrieve data json service. in app should parse data database , save in 4 tables. parsed data , successful able create database , add first , second tables. the problem i'm facing right is, second table in data base keep expanding. checked database in sql browser , discovered everytime click on app icon adds 700 rows table again.(ex. 700 becomes 1400) . (only second table, first table works fine). thank in advance this code: public void parsejsonresponceinbb(string jsoninstrformat) { try { jsonobject json = newjsonobject(jsoninstrformat); jsonarray jarray = json.getjsonarray("tables"); (inti = 0; < jarray.length(); i++) { //iterate through json array jsonobject j = jarray.getjsonobject(i); if (j.has("managers")) { add(new labelfield("managers has been added database")); ...

php - how to split a string field sentence in mysql to words -

i using cms adding new product. along adding product giving option add keywords. keywords:<textarea rows="10" cols="20" name="keywords"></textarea> then inserted in mysql table. want use these keywords search option. saving string of sentences seperated comma or space. how can each word table? you can find functions deals string-splitting here , here

php - Images not showing up in Media Library -

i have same problem described in thread: wordpress - images not showing in media library . thing solutions described in thread not working me. i have tried chmod files including "uploads" , folders/files under that. any other suggestions how solve this? edit: im able se images in media library, not under custom fields , featured images. give try, access file using web browser full url it. if can open using web browser, there not issue in permissions or chmod. confirm permission.

.net - Order xml file using linq2xml -

following question filter xml linq2xml after succesfully filtering (removing nodes) xml file. i'd order attribute in nodes. sample of xml file: <root> <group price="50"> <item price="60"/> <item price="50"/> <item price="70"/> </group> <group price="55"> <item price="62"/> <item price="57"/> <item price="55"/> </group> <group price="61"> <item price="62"/> <item price="61"/> <item price="65"/> </group> <!--more group nodes--> </root> and i'd get: <root> <group price="61"> <item price="65"/> <item price="62"/> <item price="61"/> </gro...

java - Can we pass soundpool id from one activity to other? -

i new android. working on app, i'll need load many soundpools different activities. question can load soundpools in single activity , pass id different activites ever tis needed in bundles? (intenet). or there other way it? (goal reduce time takes load same soundpools in different activities) thank in advance. you override/implement application class, in application, can load soundpools , in other activities call getapplication

android - using MylocationOverlay in osmdroid -

i can't make mylocationoverlay work, searched , tried many codes not single working one. black screen. need keep track of user location. managed track user location regular overlay notice each new location map downloaded again (which anoing , not practical). the code using regular overlay: import java.util.arraylist; import org.osmdroid.defaultresourceproxyimpl; import org.osmdroid.resourceproxy; import org.osmdroid.tileprovider.tilesource.tilesourcefactory; import org.osmdroid.util.geopoint; import org.osmdroid.views.mapcontroller; import org.osmdroid.views.mapview; import org.osmdroid.views.overlay.itemizediconoverlay; import org.osmdroid.views.overlay.itemizedoverlay; import org.osmdroid.views.overlay.overlayitem; import org.osmdroid.views.util.constants.mapviewconstants; import android.app.activity; import android.content.intent; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle...

jQuery UI draggable. Allow drag to initiate only from a particular tag -

i have jquery draggable set , working ok on table row. can select , drag entire row. want "grip" style icon displayed on left can initiate drag. how set up? you can read how on official documentation page . i haven't worked draggable myself yet, implement such handle sortable, using official documentation, easy task.

design - Achieve Play-cards like layout of controls in Android (Prototype image attached) -

Image
i'm working on board game based on playing cards, , following prototype i'm supposed achieve in game. as can see 13 cards stacked, each of card clickable , respond tap event . idea there empty 13 containers arranged in above manner , when cards dealt, these containers show cards player has received. needs dynamic. restriction i don't have game engine used , based on standard android widgets. so question is, can achieve above layout in prototype image? so question is, can achieve above layout in prototype image? yes. how can achieved figure out. here hints: it best create view hierarchy programatically rather in xml file maximum compatibility different screen sizes take @ framelayout , relativelayout margins can take negative values

php turn array in to mysql queries -

i have form submitted, user created , can assigned number of roles: example (admin, user etc.) the form posts data array roles[] . when 1 role selectable had 1 mysqli_query() create user (in users table). second create row in roleid table matched userid roleid using mysqls last_insert_id , mysql last_insert_id work if there more 1 role assigned user? the 3 tables follows: users (name, email, password, id) roleid (userid, roleid) roles(id, description) i need create entry in roleid table each checkbox selected user creation form. thought imploding array ( implode(',',$roles) ) im not sure mysql accepts values in form. ideas? you have either query once per role, or insert multiple records in 1 query. mysqli use prepared statements this. $user_id = mysqli_insert_id(); $query = "insert `roleid` (userid, roleid) values "; foreach($roles $index => $role_id) { $roles[$index] = "($user_id," . intval($role_id) . ")"; } $que...

networking - DHCP Multiple IP address request -

i trying mimic dhcp client end using c++ code. objective free/unused ip's dhcp server assign different equipments - similar dhcp relay, not technically same. client running on embedded linux platform , talks dhcp server via our internal network. as per dhcp protocol there formal procedure ( discover , offer , request , ack/nak , release ) communicate dhcp server.according rfc's(2131), when discover , receive , offer unused ip address in yiaddr field. further use ip address in request message using option 50 mentioned in rfc 2132. my main router, make- edgewater(which dhcp server) on sending discover message, sends offer message unused ip address in yiaddr field (i used unused ip in consequent request message), requirement. did same experiment few other router's (netgear, dlink, broadcom) , found offer message sending me same ip address of client requesting unused ip's. curious know why happening. understand, i'm following steps mentioned in rfc2131/r...