Posts

Showing posts from January, 2010

xlsx - Excel data organized in multiple nested rows, can R read it? -

please see picture. i've started using r, , know how/that can read files excel, can read formatted this? http://www.flickr.com/photos/68814612@n05/8632809494/ (my apologies, upload not working me) elaborating on of what's in comments: if load file excel, can save fixed-width or comma-delimited text file. either should easy read r. the following may obvious already. (first, question: sure can't data in format has 1 set of data per line? possible file you're getting generated different file format more conducive loading data r?) whether should start rearranging data in r or instead manipulate raw text depends on comes naturally (or people have around can help). me, personally, rearrange text file outside of r before loading r. that's what's easiest me. perl great language purpose, unix shell scripts if that's accessible you, or using powerful editor such vim or emacs. if have no preference, i'd suggest perl. if have signifi

http - invalid pixel in Firefox because of content charset setting in Netty server -

i developing http server netty. on occasions, server must answer 1x1 transparent pixel. hard-coded gif transparent pixel in base64, , returned following code : string pixel_string= new string (base64.decodebase64("r0lgodlhaqabaaaaach5baekaaealaaaaaabaaeaaaictaeaow==")); httpresponse response = new defaulthttpresponse(httpversion.http_1_1, httpresponsestatus.ok); response.setcontent(channelbuffers.copiedbuffer(pixel_string, charsetutil.utf_8)); edit : set content-type : response.setheader(httpheaders.names.content_type, "image/gif"); in chrome, fine. however, firefox tells me cannot display pixel (which pretty bad app), pixel data in invalid. after many investigations, figured out fix, changing charset iso-8859-1. response.setcontent(channelbuffers.copiedbuffer( responsebuilder.pixel_string, charsetutil.iso_8859_1)); i don't understand why works, makes me think may run troubles in cases. tried change firefox preferences

postgresql - PostgresSQL query -

i have 4 tables users, roles, user_role, , email. need develop query retrieves user information (username, lastname, , firstname), users email address (from email table) , aggregated list of roles (which connected user tables many-to-many table user_role). developed query below has 1 problem. aggregated list has duplicate role name entries. select distinct on (u.username) u.username "username", u.lastname "last name", u.firstname "first name", e.name "email address" , string_agg(r.name, ';' order r.name) "roles" users u left outer join user_role ur on (u.id=ur.user_id) left outer join roles r on (ur.role_id = r.id) inner join email e on e.user_id = u.id u.active = 1 , length(r.name) > 0 , r.active = 1 , ur.active = 1 group u.username, u.lastname, u.firstname, e.name order u.username if comment out inner email join , associated email fields(see below) correct role names in string_agg. selec

.net - Generic UserControl with ComponentResourceManager syntax error -

in winforms project (vs2010, .net 4.0) had user control named myview , derived system.windows.forms.usercontrol . modified control generic user control: partial class myview(of tentity {new, class}) inherits system.windows.forms.usercontrol ' source code here end class unfortunately, auto-generated initializecomponent() code vs winforms designer supplied vb.net syntax error , produce compilation error: dim resources system.componentmodel.componentresourcemanager = new system.componentmodel.componentresourcemanager(gettype(myview)) instead of above line of code, there should be: dim resources system.componentmodel.componentresourcemanager = new system.componentmodel.componentresourcemanager(gettype(myview(of tentity))) how can fix behavior of vs2010 winforms designer? related topic explanations , proposed workaround: fix embedded resources generic usercontrol the chances it's bug vs2010. bypass way quite similar known me

AngularJS - ng-switch not working as expected -

i using angularjs twitter bootstrap. fiddle issue can found here . the html code in question here is: <button type="button" class="btn" ng-repeat="tool in toolbar"> <div ng-switch on="tool.action"> <i class="icon-plus-sign" ng-switch="insert"></i> <i class="icon-edit" ng-switch-when="edit"></i> <i class="icon-trash" ng-switch-when="delete"></i> </div> </button> and scope is: $scope.toolbar = [ { "action": "insert" }, { "action": "edit" }, { "action": "delete" } ]; problem want icons displayed 1 per button somehow more 2 icons shown. what doing wrong? you missing when . replace html <button type="button" class="btn" ng-repeat=&quo

python - new line from a text file -

i have file example.txt in format: a,b,c,d and want convert to: a b c d i wrote not work: with open('newline.txt', 'w') f: f.write (file("example.txt", "r").read().replace(",", "\n")) you well: with open('newline.txt', 'w') f: f.writelines (w + '\n' w in open("example.txt").read().split(","))

excel - Protect one worksheet with a password from showing up -

is there built-in way in excel protect 1 spreadsheet in workbook password? something when user ticks or selects control , password prompted before worksheet become visible. if not built excel, can implemented vba? you try approach which: makes sheet veryhidden , protected can't unprotected - or detected - standard xl menus adds in protection on workbook_beforeclose , workbook_open events i haved used sheet called yoursheet example you should protect vba in project add further security. insert active x checkbox , use code check if: the checkbox true the user knows password unhide sheet. ( fred used in example) checkbox code private sub checkbox1_click() dim strpass string if checkbox1.value strpass = application.inputbox("please enter password", "admin check") if strpass = "fred" thisworkbook.sheets("yoursheet") .unprotect "fred"

php - Foreach in Multi-Dimensional Array -

i'm trying practice/learn foreach loops in php. understand basic foreach. struggle multi-dimensionals. i have array test out: $data = array( array('new york', 'new york city'), array('hotel', 'lodging','motel'), array('cheap') ); what loop through each , fine every possible combination & assign it's own array (will later displayed columns). first column ('new york', 'new york city') second column ('new york hotel', 'new york lodging', 'new york motel') third column ('new york city hotel', 'new york city lodging', 'new york city motel') fourth column ('new york hotel cheap', 'new york lodging cheap', 'new york motel cheap') fifth column ('new york city hotel cheap', 'new york city lodging cheap', 'new york city motel cheap') how accomplish this? i've tried couple things,

php - Inserting a Row into a Google Fusion Table, Using forms -

i trying set page allow visitors enter information posted directly google fusion table (rather mysql database). i hear google getting rid of old fusion tables sql api, need conforms fusion tables api v. 1. understand supposed come post request in format like: "insert (column name) values (user-input response)," after trying many iterations of this, i'm not having success. eventually, resorted copying sample code basic form input fusion tables, changing values own example table. still not working. here code - hoping experience in area might able evaluate. don't know i'm doing, guess. <!doctype html> <style type="text/css"> body { font-family: arial; } </style> <script src="https://apis.google.com/js/client.js?onload=initialize"></script> <script type="text/javascript"> // clientid , apikey available @ // https://code.google.com/apis/console. more information, see // http:/

ruby on rails - Multiple Database Users per function -

we exploring how sql inject risks can limited allowing key functions perform duties within our rails application. security officier, not full time rails person. the way see it, writing database should occur when account created (registration) or account modified (user profile update). simplification purposes, let's assume no other updates happen within application users. if not block sql injection attack on read request, protected better 2 separate calls. can rails support following configuration? - one database connection "read" requests one database connection (same exact database) "write" requests if so, how in database file , code requests? i thought might post out. class user < activerecord::base self.abstract_class = true ... end cur = create update read r = read only class usercur < user establish_connection "user_cur_database_#{rails.env}" end class userr < user establish_connection &quo

sql - results from both tables even corresponding rows does not exist in other table -

this question has answer here: what kind of join need use create 1 table many? 3 answers i results both tables corresponding rows not exist in each other table. join should use results below. tried full, no luck. table 1: ca cb cc === === === aa 11 x1 bb 22 x2 cc 33 x3 ee 44 x4 table 2: ca cb cd === === === aa 11 y1 bb 22 y2 ff 55 y5 gg 66 y6 expecting results like: ca cb cc cd === === === === aa 11 x1 y1 bb 22 x2 y2 cc 33 x3 (null) ee 44 x4 (null) ff 55 (null) y5 gg 66 (null) y6 select coalesce (t1.ca, t2.ca) ca ,coalesce (t1.cb, t2.cb) cb ,cc ,cd table1 t1 full join table2 t2 on t1.ca = t2.ca , t1.cb = t2.cb order coalesce (t1.ca, t2.ca) ,coalesce (t1.cb, t2.cb) sqlfiddle

c# - Access Dynamically Created Controls in a TabPageControl -

i creating bunch of usercontrols each in tab in tabcontrol. problem i'm having need access value controls. have no idea how this. string q; foreach (tabpage tp in tabcontroler.tabpages) { filter f = tp.controls.find("filter",true); //not working @ all. q += f.querry; } when creating control, add name it: filter filter1 = new filter(); filter1.name = "filter1"; if winforms , filter1 name of filter control, be: if (tp.controls.containskey("filter1")) { filter selectedfilter = (filter)tp.controls["filter1"]; } debug.write(selectedfilter.value);

http - Is new server request sent every time when url clicked/accessed/pressed? -

for example in address bar if press enter load url , close tab while it's starting load? request sent anyway in case? if yes, interested in bit more details sent , not, or sent back? any appreciated yes request sent every time. when click link or access page request sent , browser waits until response comes server. see article more in depth details http://devhub.fm/http-requestresponse-basics .

sql server 2008 - joining two sql statements in a stored procedure - (no same columns) -

i have situation deals 2 sets of data different columns. know use union union requires equal number of expressions in both tables. trying join these 2 statements in stored procedure. first statement has 1 column 'location' select tablea.name, tableb.occupation, tablea.location, 'group1' [groupby] tablea, tableb tablea.id = 1 select tablea.name, tableb.occupation, 'group2' [groupby] tablea, tableb tableb.id = 10 my result should this name occupation groupby location david doctor group1 usa john pilot group1 asia dwayne wrestler group2 null axel rockstar group2 null my table structure table id name occupation location 1 david doctor usa 1 john pilot asia 2 mike clerk europe table b id name occupation 3 wayne writer 4 shane publisher 10 dwayne wrestler 10 axel rockstar that's called union; manually add ", nul

c# - Delete a self signed certificate created using makecert -

i created self-signed certificate using following command: makecert -r -pe -n "cn=aaa" -sky exchange -ss -sr localmachine aaa.cer this certificate shows server certificate in iis manager, want. now wish delete programmatically ( c# ), command line can that? you can delete delete other file in c#: string path = @"c:\program files\microsoft sdks\windows\v6.0a\bin\aaa.cer"; fileinfo myfileinf = new fileinfo(path); myfileinf.delete();

javascript - selecting all elements of a class within elements of given id -

my html code looks <div id="parta"> <div class="myclass typea"> blabla </div> <div class="myclass typea"> blabla </div> <div class="myclass typea"> blabla </div> <div class="myclass typeb"> blabla </div> </div> <div id="partb"> <div class="myclass typea"> blabla </div> <div class="myclass typea"> blabla </div> <div class="myclass typea"> blabla </div> <div class="myclass typeb"> blabla </div> </div> i want use javascript count number of elements of class myclass , 1 within #parta . when use $(".myclass").size() 8 result (it counts elements both parta , partb ). when use $(".myclass.typea").size() 6 (it gets myclass , typea elements, both parts) when use $("#parta.myclass").size() 0 . a

objective c - UILabel on a UIToolbar (programmatically) doesn't display the label -

i have following code in -viewdidload: : self.navigationcontroller.toolbarhidden = no; uibarbuttonitem *sharebutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemaction target:self action:@selector(sendemail:)]; uibarbuttonitem *spacer1 = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0.0 , 25, self.view.frame.size.width, 21.0f)]; label.backgroundcolor = [uicolor clearcolor]; label.textcolor = [uicolor whitecolor]; label.text = @"text-here"; label.userinteractionenabled = no; label.font = [uifont systemfontofsize:18.0]; label.textalignment = nstextalignmentcenter; uibarbuttonitem *labelitem = [[uibarbuttonitem alloc] initwithcustomview:label]; self.navigationcontroller.toolbaritems = [nsarray arraywithobjects:sharebutton, spacer1, labelitem, nil]; however, when load app

c - Does accesing .text segment via `extern` variables cause undefined-behaviour? -

this file "1.c" #include <stdio.h> char foo; int bar(){ } int main(){ printf("%d",foo); return 0; } //-------------------------- this file '2.c' void foo(){ } compiler invoked gcc 1.c 2.c does above gives undefined behaviour? guess is, yes . otherwise it's impossible optimization. multiple different definitions same entity (class, template, enumeration, inline function, static member function, etc.) [what common undefined behaviour c++ programmer should know about? but far know char foo produce weak symbol can overridden void foo(){} @ linkage. furthermore, if change char foo extern char foo , still definition ? it'd cause undefined behaviour, yes. there lots of quotes standard explicit various types of declarations , forth, sums up: in set of translation units , libraries constitutes entire program, each declaration of particular identifier ext

salesforce - Add wordpress custom post type data to an external db -

this function adds custom post 'event' data salesforce db. i've tested function outside of wordpress , works flawlessly. when test inside wordpress adding new event, no error generated , data not inserted sf db. i've tested printing out $_post , saw data being collected. how can display errors can trouble shoot this? function add_campaign_to_sf( $post_id) { global $sf_username; global $sf_password; if ('event' == $_post['post-type']) { try { $mysforceconnection = new sforceenterpriseclient(); $mysoapclient = $mysforceconnection->createconnection(cd_plugin_path . 'toolkit/soapclient/enterprise.wsdl.xml'); $mysflogin = $mysforceconnection->login($sf_username, $sf_password); $sobject = new stdclass(); $sobject->name = get_the_title( $post_id ); $sobject->startdate = date("y-m-d", strtotime($_post["events_

javascript - horizontal alignment div in print css -

i trying print web page.... trying align div structure properly.... problem using media queries iphone layout.... css disturbing print.... how remove properties in media print...and make div horizontally aligned... when right click , print page can see result... http://jsfiddle.net/rrgdw/ @media print { tr.inventorylistheading { background-color: #1a4567 !important; -webkit-print-color-adjust: exact; }} @media print { .inventorylistheading th { color: white !important; }} there's not enough of css/structure go on, if want centre div horizontally add following #idofdiv { position: relative; margin: 0 auto; width: 1000px; /*whatever width*/ } body, html /*whatever parents*/ { position: relative; width: 100%; } your jsfiddle isn't readable you're going have elaborate here more if isn't you're asking for. i'm not sure i've understood, iphone med

php - Laravel3: Variables that has to be set forever -

<meta name="description" content="{{ $description }}" /> it variable stored in custom.config.php . file can anywhere. (i'm new laravel) how can ensure laravel runs each time? i'm not going use ->with('description', $description'); every time call view. looking like: {{ config::get('website_description') }} you can add variable before route filter: route::filter('before', function() { //do stuff before every request application... $website_description = config::get('website_description'); view::share('website_description', $website_description); }); you can directly access variable in view.

php - PHP5.5 $_SESSION array empty after invocation by <form action=> -

i define form, like: <form name="form1" method="post" action="display_info.php"> when action file display_info.php invoked receives $_post array proper info in form, $_session array empty. still need info in caller's $_session ! is there alternate way invoked php file receives both $_session , $_post info? if try method="session" still arrives empty. if session contains data there should no problem. make sure start session @ start of document with: session_start(); . $_post , $_session global variables different things. don't mix two. they both arrays can access them other array but, $_post holds data posted page, , $_session holds sessions stored in past. so if have form posts data page process data, need start session use , access session data through $_session variable. also try check if $_session empty: var_export($_session);

Ruby - alias for object class -

sorry english. my code ... class myclass newfood = food def index @items = newfood.all end end @items.first food object, want newfood object some help? take example: class foo @@instances = [] def initialize(value) @value = value @@instances << self end def self.all @@instances end end class bar newfoo = foo.dup def index @items = newfoo.all end end # bar::newfoo instantiate it's own objects bar::newfoo.new(5) bar::newfoo.new('fish') bar.new.index => [#<bar::newfoo:0x00000002f33cf0 @value=5>, #<bar::newfoo:0x00000002f65958 @value="fish">] however fail see need kind of metaprogramming hack. edit: crap, forgot class variables ( @@var ) shared along it's childs, example turn messy.

asp.net - System.Data.DataRowView' does not contain a property with the name 'ID' -

i've been having error asp.net. , seems on going. fix 1 thing leads error. had previous problem asked on here: issue inserts , updates . in top answer, told numerous things fix code; however, after inserted "datakeynames="id"" told error... have no idea why now note in gridview, have "datakeynames="id" , linked <asp:boundfield datafield="id" visible="false" /> here stack trace: [httpexception (0x80004005): databinding: 'system.data.datarowview' not contain property name 'id'.] system.web.ui.databinder.getpropertyvalue(object container, string propname) +9502089 system.web.ui.webcontrols.gridview.createchildcontrols(ienumerable datasource, boolean databinding) +3140 system.web.ui.webcontrols.compositedataboundcontrol.performdatabinding(ienumerable data) +67 system.web.ui.webcontrols.gridview.performdatabinding(ienumerable data) +14 system.web.ui.webcontrols.databoundcontrol.ondataso

php - to display all records using jquery ajax -

i have written code displaying records on same page not working.actually want in page insert same page should show records in table format , show added record without refreshing page. ajaxinsert.php <script type="text/javascript" src="../jquery.js"></script> <script type="text/javascript" > $(document).ready(function() { $("#insert").click(function() { var name = $("#name").val(); var rno = $("#rno").val(); var address = $("#address").val(); //var datastring = "&name="+name"+&address="+address; $.ajax({ type:'post', data:{name: name, rno:rno, address:address}, url:'demo_insert.php', success:function(data){ if(data="inserted") { alert("insertion success"); } else { alert("not inserted"); } }

max of a list in python -

so need write , test function returns index of largest element in list (or, if several elements have largest value, index of first 1 of them) , i'm not allowed use max function. appreciated! def largestelementindex(lst): x=0 maxnum=0 while x+1 < len(lst): if lst[x] > maxnum: maxnum=x x+=1 return maxnum print "program output" indexofmax = largestelementindex([1, 4, 3, 3, 2]) print 'index of max value is',indexofmax you need store largest number index: def largestelementindex(lst): x=0 maxnum=0 maxindex=0 while x < len(lst): if lst[x] > maxnum: maxindex=x maxnum=lst[x] x+=1 return maxindex i'd use for loop: def largestelementindex(lst): max_index = 0 max_value = lst[0] index, value in enumerate(lst) if value > max_value: max_index = index max_value = value return max_index

c++ - nVidia driver version from WMI is not what I want -

i want driver version of nvidia video card. used wmi , data "driverversion" obejct of "win32_videocontroller" class. "9.18.13.1106"(file version) , wanted "311.06"(treiber version). can information? if impossible on wmi, want know other way that. thanks. you can using nvml nvidia's tesla deployment kit . can retrieve internal driver version (the 1 you're accustomed seeing nvidia driver) code this: #include <iostream> #include <string> #include <stdlib.h> #include <nvml.h> #include <windows.h> namespace { typedef nvmlreturn_t (*init)(); typedef nvmlreturn_t (*shutdown)(); typedef nvmlreturn_t (*get_version)(char *, unsigned); class nvml { init nvmlinit; shutdown nvmlshutdown; get_version nvmlgetdriverversion; std::string find_dll() { std::string loc(getenv("programw6432")); loc += "\\nvidia corporation\\nvsmi\\nvml.dll"; return loc;

c - Number Guessing Game with two players -

Image
can please me figure out wrong program prety complex me. number guessing game 2 player can play. starts saying player goes first , player has input number either 1 or 2 , enter guess or either pass (players can't pass more 3 times or twice in row). working except everytime player 1 starts asks him guess twice in row bu works fine, , when player 2 starts alternates should this: and code quite lot of code: #include <stdio.h> #include <time.h> #include <stdlib.h> #include <malloc.h> int main(void) { int playernumber = 0; int number = 0; int playerinput = 0; int guess = 0; char input; char str[6] = {0}; int playera = 1; int playerb = 2; int passa = 3; int passb = 3; int = 1; int playerturn = 0; int turn = 0; srand(time(null)); playernumber = 1 + rand() % 2; /* random number generated */ srand(time(null)); number = 0 + rand() % 100; /* random number generated */ while(number != guess) { printf("\nit's player's %d turn\

c# - Add Checkbox Column into GridControlEx -

what want add column filled checkboxes , placed on left side of grid. grid rows binding query. have code: string query = "select transid, company, period, empid, employee trx" datatable tblclaim; tblclaim = db.sql.select(query); tblclaim.columns.add("process", typeof(bool)); //i want column placed on left side of grid gcxclaim.exgridcontrol.datasource = tblclaim; what code is, checkbox disabled , column placed on right side. while tried place tblclaim.columns.add("process", typeof(bool)); before tblclaim = db.sql.select(query); , got error. how can that? thanks. try this, tblclaim.columns.add("process", typeof(bool)).setordinal(0); this set index of column "process" 0

.net - Byte array written to isolated storage area file in C# Windows Phone 7 app is invalid -

i have c# windows phone 7.1 app downloads pdf file foreign web server , (tries) save isolated storage area file. have tried several different ways done, file ends 30% large , when open in text editor, instead of seeing usual 'pdf' characters @ start of file followed encoded characters, see junk. test file i'm using supposed 161k when view file isolated storage explorer , it's 271k. first download file string. inspected string @ point in debugger , contain proper values , correct length. trouble happens when try write isolated storage area. tried both streamwriter & binarywriter identical invalid results. contents of resulting file appears long stream of junk characters. note, deleting file if exists in case, before writing out contents. below code using binarywriter version. wrong? async public static task urltofileasync( string strurl, string strdestfilename,

Android: SQLite database query not returning any records -

i created , populated sqlite database firefox sqlite manager. copied .sqlite file assets folder of android project. my aim use records populate spinner. when query database, cursor displays columns no records. my databasehandler class extends sqliteopenhelper , contains methods oncreate , onupgrade , getalloffices . public list<string> getalloffices(){ list<string> offices = new arraylist<string>(); // select query string selectquery = "select officeid _id, officename " + table_office; sqlitedatabase db = this.getreadabledatabase(); cursor cursor = db.rawquery(selectquery, null); // looping through rows , adding list if (cursor.movetofirst()) { { offices.add(cursor.getstring(1)); } while (cursor.movetonext()); } // closing connection cursor.close(); db.close(); // returning offices return offices; } any ideas on why records not returned app

javascript - Making sense of class extension and instance properties in Coffee Script -

i've gotten coffee script , having issues figuring out how class extension works. seems properties defined instance properties on parent class being implemented static properties when class extended. i have class, called foo, want use base class 2 sub classes, bar , goo. give foo instance property called foobs , method adding foob, so: class foo foobs:[] addfoob: (foob) -> @foobs.push(foob) and extend foo bar , goo, , create new instances, so: class bar extends foo othermethod: -> alert 'doing other stuff' class goo extends foo secondmethod: -> alert 'doing second stuff' barinstance = new bar() gooinstance = new goo() but when add foob barinstance, gets added gooinstance! barinstance.addfoob('test') console.log gooinstance.foobs (outputs ["test"]) clearly i'm doing wrong here. want barinstance , gooinstance each have own "foobs" property, reason seems though foobs i

java - How can I override compareTo method in a class I wrote to compare Strings stored in the class? -

i wrote class, myclass, , each instance has string "name" field. want override compareto method when called compare 2 "name" fields of each instance. here have far: public class myclass implements comparable<myclass>{ public string name; public int age; public myclass(string name) { this.name = name; this.age = 0; } public string getname() { return this.name; } @override public int compareto(myclass mc) { return this.name.compareto(mc.name); } } when go add instances of class ordered list container wrote, not added in order want, alphabetically. ordered list doesn't seem problem, tested adding strings added in correct order. here add() method of ordered list: public boolean add(e obj) { node<e> newnode = new node(obj); node<e> current = head, previous = null; if (current == null) { // empty list head = tail = newnode; currentsize++

html - Expand div according to the inner text -

Image
i've got following div elements in html. act buttons. <div id="button-section"> <!-- section function buttons --> <div class="fn-button"> <!-- function button --> <span>my current checks</span> </div> <div class="fn-button"> <!-- function button --> <span>all current checks</span> </div> <div class="fn-button"> <!-- function button --> <span>add new order</span> </div> </div> this css i've used there elements. #button-section{ width: 100%; height: 150px; position: fixed; bottom: 0; background-color: rgb(229, 229, 255); } .fn-button{ width: 130px; height: 50px; float: left; margin: 10px 0px 0px 20px; border-radius: 10px; background: rgb(111, 111, 111); box-shadow: inset 1px 4px 12px rgb(0, 0, 0); text-align: center; } .fn-button spa

swing - Java - Highlighting Text Between two Chars - JTextPane -

i need able highlight words within 2 chars. example, : //highlight whatever in between 2 quotation marks string keychars = " \" \" "; i have been grueling on weeks now. i've looked up, read source codes, wrote code, , still have yet find out how able this. the following code snippet works. ed=new jeditorpane(); ed.settext("this \"text\" contains \"quotes\". \"contents\" of highlighted"); pattern pl; pl=pattern.compile("\""); matcher matcher = pl.matcher(ed.gettext()); int end=0,beg=0; while(matcher.find()) { beg=matcher.start(); matcher.find(); //finding next quote end=matcher.start(); defaulthighlightpainter d = new defaulthighlightpainter(color.yellow); try { ed.gethighlighter().addhighlight(beg+1, end,d); } catch (badlocationexception ex) { ex.printstacktrace(); } }

java - Methods lacking return types and no void? -

this piece of code in textbook, i'm not understanding method testpanels(). has no return type , no void. how can happen? public class testpanels extends jframe { public testpanels() { jpanel p1 = new jpanel(); p1.setlayout(new gridlayout(4,3)); (int = 1; <= 9; i++) { p1.add(new jbutton(""+i)); } p1.add(new jbutton(""+0)); p1.add(new jbutton("start")); p1.add(new jbutton("stop")); jpanel p2 = new jpanel(new borderlayout()); p2.add(new jtextfield("time displayed here"), borderlayout.north); p2.add(p1, borderlayout.center); add(p2, borderlayout.east); add(new jbutton("food placed here"), borderlayout.west); } public static void main(string[] args) { testpanels frame = new testpanels(); frame.settitle("the front view of microwave oven"); frame.setsize(400, 250); frame.setlocationrelativeto(null); frame.setdefaultcloseoperati

python - understanding functools.wraps -

i using flask-restful , trying have rest endpoints using technique showed here the main code is def authenticate(func): @wraps(func) def wrapper(*args, **kwargs): if not getattr(func, 'authenticated', true): return func(*args, **kwargs) acct = basic_authentication() # custom account lookup function if acct: return func(*args, **kwargs) restful.abort(401) return wrapper class resource(restful.resource): method_decorators = [authenticate] # applies inherited resources i same way , seems work, not sure happens @wraps ? seems magic me @ moment , did not understand following a.) seems function wrapped @wraps passed wrapper, wrapper returning? possible answer : passed function initially? if yes, how can pass more information acct object function receives account object , don't have database fetch it? update based on example, rest endpoint looks class userresource(restresource):

ruby - Feature Testing with Filepicker.io and Capybara -

i working on feature testing filepicker.io upload form , cannot file upload work. using poltergeist driver capybara , debugging have been able do, filepicker iframe never loading. have confirmed using remote debugging of poltergeist. here sample of test code: within_fieldset 'photos' click_button 'find photo' end within_frame 'filepicker_dialog' attach_file '#fileuploadinput', rails.root.join('spec', 'files', 'photo.jpg') end and error being produced: failure/error: within_frame '#filepicker_dialog' capybara::poltergeist::timeouterror: timed out waiting response {"name":"push_frame","args":["#filepicker_dialog"]}. it's possible happened because took long time (for example page load slow). if so, setting poltergeist :timeout option higher value (see docs details). if increasing timeout not help, bug in poltergeist - please report issue tracker. attempting ma

c# - retrieve unique id for just added row -

i new asp.net. executing simple insert query via sql command. want retrieve unique id newly inserted row , store in array. not know how approach problem. my code foreach (gridviewrow gvrow in gvuserdata.rows) { string strquery = "insert vishalc.[rental table] (car_id_reference, username, carname,price,startdate,enddate)" + " values(@carid, @username, @carname,@price,@startdate,@enddate)"; sqlcommand cmd = new sqlcommand(strquery); cmd.parameters.addwithvalue("@carid", gvrow.cells[0].text); cmd.parameters.addwithvalue("@username", gvrow.cells[1].text); cmd.parameters.addwithvalue("@carname", gvrow.cells[2].text); cmd.parameters.addwithvalue("@price", gvrow.cells[3].text); cmd.parameters.addwithvalue("@startdate", gvrow.cells[4].text); cmd.parameters.addwithvalue("@enddate", gvrow.cells

Is there a .Net C# profiler that can report separate statistics for different typed execution of a generic method? -

say have simple program: using system; using system.collections.generic; using system.linq; using system.text; namespace profilertesting { class program { static void myfunc<t>(t t) { system.threading.thread.sleep(100); console.writeline(t); } static void main(string[] args) { ilist<string> l = new list<string> { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m" }; foreach (string s in l) { myfunc(s); } ilist<int> g = new list<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; foreach (int in g) { myfunc(i); } } } } when profile program using .net profiler (i've tried both equatec profiler free version

html - Why does Chrome add a pixel to my Div -

i have created 1010px long 5px border around making it's length 1020, however, when inspect div in chrome, despite fact code still says it's 1010px , it's border 5px it's 1021px i can confirm neither left or right borders adding pixel div supposed house 5 separate images each 202px wide 5 should fit no gaps first image slightest of gaps between , left border i have had work before tables, i'm redesigning site remove tables , replace them divs while maintaining exact same look this code creates div <div width="1010" align="center" style="border: 5px solid #9dbfff; margin:0px; padding:0px;"> note: yes move style .css file after got working here first, part of redesign, removing styles , putting them in .css files you can try using "width" property in style attribute, this: <div align="center" style="border: 5px solid #9dbfff; margin:0px; padding:0px; width:1010px;"> i i

c# - Monodroid OnDismiss with Dialog Fragment -

i have custom dialogfragment called fragment activity uses listview . in api 14, works fine. notifydatasetchanged() called when save button pressed in fragment , dismissed. in api 8, however, following error thrown after our 'save' button pressed in fragment , returns main activity. "java.lang.illegalstateexception: content of adapter has changed listview did not receive notification. make sure content of adapter not modified background thread, ui thread. [in listview(2131099672, class android.widget.listview) adapter(class timepilot.employeesadapter)]" i can use workaround writing update() method in parent activity calls notfiydatasetchange() , calling in fragment when save pressed , before dismiss() , , works fine, feels less correct way of going this. is there anyway implement ondimisslistener dialog fragment using monodroid? (i have seen many examples in doing android, cannot figure out monodroid). the more curious thing error not thrown in api

html - carouFredSel jQuery in Wordpress -

i using caroufredsel jquery slider on html code: <div class="list_carousel"> <ul id="foo"> <li>c</li> <li>a</li> <li>r</li> <li>o</li> <li>u</li> <li>f</li> <li>r</li> <li>e</li> <li>d</li> <li>s</li> <li>e</li> <li>l</li> <li> </li> </ul> <div class="clearfix"></div> <a id="prev" class="prev" href="#">&lt;</a> <a id="next" class="next" href="#">&gt;</a> <div id="pager2" class="pager"></div> </div> and jquery <script type="t

html - Get data from a FORM in javascript -

i need data form . form : <form action="" id="test"> <h2>data</h2> <label for="">name</label> <input type="text" name="name"> <label for="">address</label> <input type="text" name="address"> <label for="">phone</label> <input type="text" name="phone"> <input type="button" onclick="xd()" value="click here"> </form> and used javascript command : <script type="text/javascript"> function xd(){ //var x=document.forms["test"].getelementsbytagname("address") or var x=document.forms["test"].getelementsbytagname("address").value document.write(x); } </script> but it's not working. how easily. you seem targeting element name attribute (address), not tagname

iphone - how to add DropDownComobo in uisearchbar ios -

i want add 1 dropdowncombo in uisearchbar mail application (nstokenfield). on clicking combo display list of items. have read many blogs there no public control apple. there way this? no. have use uipickerview or uisegmentedcontrol create drop down menu. if want custom control,you can check link:- https://github.com/katokichisoft/kspopoverview if need further assistance..please reply me.. you can use action sheet..its upto you.. enjoy..

javascript - Display the validation popup after select all the compulsary fields -

i have issue filterbutton : when client selects compulsary field grid have filtered otherwise must display popup message : "select compulsary field". here in fiddle, have 3 dropdowns , 2 datepicker. when select filterbutton filters data, otherwise must show message.in fiddle dropdowns not working grid because didn't placed code between dropdown , grid datetimpicker working. in this fiddle need display popup validation. here compulsary field in fiddle code: if(datetimepicker1 ===""&&datetimepicker2 ==="") { $("#filter-msg").data("kendowindow").center().open(); } this way tring want validate 5 controls i suggest add test in click event of filter button : $("#filter").on("click", function () { var mindate = $('#datetimepicker1').data("kendodatepicker").value(); var maxdate = $('#datetimepicker2').data("kendodatepicker").value();

How to convert String to float in DataStage 7.5 Server -

how convert string/char float in server ds 7.5. in ds 7.5, don't have conversion options ds 8.x , in 7.5, need map field, example, if in input string , in o/p float, need map input output field. sever convert string float.

ruby on rails - .rvmrc syntax error -

i trying work web app made else. cloned repo , when cd'ed it, .rvmrc executed. getting following error in it: : command not found : command not found : command not found : command not found -bash: /home/sleepingdragon/desktop/sharedcab/main-apps/ytaxi-apps/ytaxi/.rvmrc: line 22: syntax error in conditional expression -bash: /home/sleepingdragon/desktop/sharedcab/main-apps/ytaxi-apps/ytaxi/.rvmrc:'line 23: syntax error near `]] -bash: /home/sleepingdragon/desktop/sharedcab/main-apps/ytaxi-apps/ytaxi/.rvmrc:'line 23: ` && -s "${rvm_path:-$home/.rvm}/environments/$environment_id" ]] the .rvmrc file this: #!/usr/bin/env bash # rvm project .rvmrc file, used automatically load ruby # development environment upon cd'ing directory # first specify our desired <ruby>[@<gemset>], @gemset name optional, # full ruby name supported here, short names use: # echo "rvm use 1.9.3" > .rvmrc environment_id="ruby-1.9.3-p194@yt