Friday, 15 January 2010

r - Syntax (and/or functions) for applying an op over elements of one vector, using as arg elements of a 2nd vector -



r - Syntax (and/or functions) for applying an op over elements of one vector, using as arg elements of a 2nd vector -

i trying find right look creating vector result applying operation on vector, using, in vectorised way, elements of 2nd vector. utilize case have vector of raw values, , vector of breakpoints. want look give me result of applying sum of logical operation on breakpoints respect values in values vector. in other words:

given:

rawfoo <- c(30, 4, 22, 77, 1,169, 10) breaksfoo <- c(10,50, 80) resultfoo <- data.frame(breaks=breaksfoo, matching=numeric(length(breaksfoo)))

i want write single expression delivers column values resultfoo$matching, is: each value in breaksfoo, sum(rawfoo > breaksfoo[i]),

resultfoo breaks nmatching 1 10 3 2 50 2 3 80 1

i have been trying various forms of apply , having problems how express function. perhaps barking wrong tree? can supply multiple demonstration of failure if required. (but guess question simple doesn't need error messages disambiguate ;-)

you can in 3 steps:

write function that, given break, returns list of 2 element: break , result of sum(break > rawfoo).

than can utilize sapply apply function breaksfoo.

finally, need transform result of sapply, matrix, dataframe need.

the next code of these 3 steps in 1 statement:

as.data.frame(t(sapply(breaksfoo, function(x) list(breaks = x, nmatching = sum(x > rawfoo)))))

returns

breaks nmatching 1 10 2 2 50 5 3 80 6

r syntax apply

Kerberos authentication using Java is failing -



Kerberos authentication using Java is failing -

my client has run in problem java application (i have not played in java land in long time). application uses kerberos authentication , works great java 1.6.30. upgrade java 1.7.11 begin getting next error:

javax.secrutiy.auth.login.loginexception: unable obtain principal name authentication.

the jvm running on windows 7 in windows domains authenticating against ad. there breaking alter made between releases? there code alter need fixed? or did on java team goof up? tia

hi running potential problem.

http://www.javaactivedirectory.com/?page_id=93

java 6 doesn't respect registry value while java 7 does.

java kerberos

html - Execute some Javascript onChange using options? -



html - Execute some Javascript onChange using options? -

i've been lurking bit , couldn't find answer. have bunch of buttons want turn drop downwards menu , have code executed onchange. but, i'm new javascript , having hard time figuring out how work. got work, couldn't work more 1 option. here's have:

<button class="lightbutton" onclick="lightswitch(1,true);lightswitch(2,true);lightswitch(3,true);"> lights on</button> <button class="lightbutton" onclick="lightswitch(1,false);lightswitch(2,false);lightswitch(3,false);"> lights off</button>

i got lights turn on doing this:

<form name="functions"> <select name="jumpmenu" onchange="lightswitch(1,true);lightswitch(2,true);lightswitch(3,true);"> <option>lightfunctions</option> <option value="*";>light 1 on</option> <option value="*";>light 1 off</option> </select> </form>

now, see why works -- it's telling whenever changes turn on lights. how alter "onchange" create gets whichever alternative have chosen?

i think i'm missing js unsure.

i appreciate help.

to have select element command first lightswitch can this:

<select name="jumpmenu" onchange="lightswitch(1,this.value==='on');"> <option value="on";>light 1 on</option> <option value="off";>light 1 off</option> </select>

that is, instead of hardcoding true sec parameter lightswitch() test current value of select element. (note i've changed value attributes more meaningful. look this.value==='on' evaluate either true or false.)

within select's onchange attribute this refer select element itself.

edit: have same select command multiple parameters can add together data- attributes alternative elements store many parameters per alternative needed (in case think need 1 extra). , i'd move logic out of inline attribute:

<select name="jumpmenu" onchange="jumpchange(this);"> <option value="">lightfunctions</option> <option data-switchno="1" value="on";>light 1 on</option> <option data-switchno="1" value="off";>light 1 off</option> <option data-switchno="2" value="on";>light 2 on</option> <option data-switchno="2" value="off";>light 2 off</option> <option data-switchno="3" value="on";>light 3 on</option> <option data-switchno="3" value="off";>light 3 off</option> </select> function jumpchange(sel) { if (sel.value === "") return; // nil if user selected first alternative var whichlight = +sel.options[sel.selectedindex].getattribute("data-switchno"); lightswitch(whichlight, sel.value==='on'); sel.value = ""; // reset select display "light functions" alternative }

demo: http://jsfiddle.net/n7b8j/2/

within jumpchange(sel) function added parameter sel select element (set this onchange attribute). "magic" happens on line:

var whichlight = +sel.options[sel.selectedindex].getattribute("data-switchno");

to explain line: sel.options[sel.selectedindex] gets reference selected option, , .getattribute("data-switchno") gets option's data- attribute. + converts attribute string number.

javascript html jsp option onchange

asp.net mvc - Microsoft MVC Razor - EditorFor and Digitalbush mask not working -



asp.net mvc - Microsoft MVC Razor - EditorFor and Digitalbush mask not working -

i cannot mask command exclusively work. simple mvc editorfor line shows fails mask input. i'm sending timespan value it.

@html.editorfor(model => model.vxchargebo.visittime)

should mask _ _ : _ _ instead shows time passed 00:00:00

i've tried adjusting mask, problem seems in mvc or css wanted rule out mvc.

use:

@html.textboxfor(model => model.vxchargebo.visittime)

asp.net-mvc input mask editorfor

WPF: How to save a GIF file in a string or file from an URL? -



WPF: How to save a GIF file in a string or file from an URL? -

i seek retrieve content of .gif located on url string -and save disk-, ran wpf appliactions using webbrowser. after trying dozens of solutions not farther yesterday. thought code below job, saved string cgif contains...the url itself. http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.gifbitmapdecoder.aspx thought needed gifbitmapencoder instead, sample suggests creates empty gif instead of downloaded one.

(ps: want retrieve gif bytes straight wpf webbrowser haven't found working there either)

private void gifsave() { var uri = new uri(@"http://www.archivearts.com/giraffe2.gif"); var img = new gifbitmapdecoder(uri, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.onload); string cgif = img.tostring(); }

modified sample on gifbitmapdecoder msdn page:

// open stream , decode gif image var uri = new uri(@"http://www.archivearts.com/giraffe2.gif"); gifbitmapdecoder decoder = new gifbitmapdecoder(uri, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.onload); bitmapsource bitmapsource = decoder.frames[0];

then utilize copypixels() method of bitmapsource re-create pixel info array. convert array string?

i haven't done this, took @ msdn hints.

wpf string save uri gif

css - Two background images. One in HTML one in BODY. In Firefox body image isnt rendered -



css - Two background images. One in HTML one in BODY. In Firefox body image isnt rendered -

something weird happening.

i've basic html code. html, head, body. (as i've received negative votes, here's total code)

<html> <head> </head> <body> </body> </html>

this css:

html { background-image: url(background.png); background-repeat: repeat; margin-top:-8px; } body { background-image: url(telefonillo.png); background-repeat:no-repeat; }

this chrome , firefox shows:

how can prepare this?

i tried "inspect" firefox, , tried remove "background.png" html, "telefonillo.png" shows up.

tried "z-index:1" on body, isn't working, isn't content @ all.

edit: tried removing divs, , other css, incase there kind of problems between rules, it's still happening.

why don't utilize before

body:before { content:""; background:url(background.png) no-repeat top left; width:100%; height:100%; } body { background:url(telefonillo.png) no-repeat top left; width:100%; height:100%; }

html css

c# - DateTime.ParseExact raises FormatException -



c# - DateTime.ParseExact raises FormatException -

the code:

datetime.parseexact("2/2/2002", "dd/mm/yyyy", system.globalization.cultureinfo.invariantculture)

is raising system.formatexception.

i'll appreciate if tell me doing wrong.

it should d/m/yyyy

datetime.parseexact("2/2/2002", "d/m/yyyy", system.globalization.cultureinfo.invariantculture)

the reason of exception converts 2 places dd string found 2/.

c# .net datetime

expressionengine - safecracker matrix-menu doesn't appear in overlay -



expressionengine - safecracker matrix-menu doesn't appear in overlay -

i have site, not visible public, utilize safecracker , matrix fields in several locations. on pages load normally, fine. when matrix fields appear in overlay (using colorbox), matrix-menu div isn't created.

stepping through code firebug, issue seems line:

var $body = $(document.body);

doesn't set $body correctly (maybe race status overlay loading?). when gets chunk of code in matrix.js:

obj.menu.$ul = $('<ul id="matrix-menu" />').appendto($body).css({ opacity: 0, display: 'none' });

$body doesn't resolve, menu can't attache anywhere. think i've fixed it, want check , see if should worried i'll break else. if alter above code to:

obj.menu.$ul = $('<ul id="matrix-menu" />').appendto($(document.body)).css({ opacity: 0, display: 'none' });

everything seems fine. there improve way address this?

if matrix field doesn’t have height when first initialized, puts of initialization stuff on hold, assuming it’s either hidden default or lives on secondary publish tab. cuts downwards on initial page load time , fixes issues celltypes (text, assets, maybe others.) need know dimensions of dom elements within cells.

matrix automatically resume initialization when has been expanded or tab has been clicked on, if you’re using matrix outside of publish page and hiding it, you’ll need trigger initialization-resuming yourself:

for (var = 0; < matrix.instances; i++) { matrix.instances[i].initrowsifvisible(); }

expressionengine

c# - How can I deserialize an XML response to an object when I only need a child element of the XML? -



c# - How can I deserialize an XML response to an object when I only need a child element of the XML? -

i have next xml getting webrequest:

<?xml version="1.0" encoding="utf-8"?> <search> <total_items>5</total_items> <page_size>10</page_size> <page_count>1</page_count> <page_number>1</page_number> <page_items></page_items> <first_item></first_item> <last_item></last_item> <search_time>0.044</search_time> <events> <event id="e0-001-053379749-0"> <title>antibalas</title> <url>http://test.com</url> <description>stuff</description> <start_time>2013-01-30 20:00:00</start_time> <stop_time></stop_time> <tz_id></tz_id> <tz_olson_path></tz_olson_path> <tz_country></tz_country> <tz_city></tz_city> <venue_id>v0-001-000189211-5</venue_id> <venue_url>http://blah.com</venue_url> <venue_name>troubadour</venue_name> <venue_display>1</venue_display> <venue_address>9081 santa monica boulevard</venue_address> <city_name>west hollywood</city_name> <region_name>california</region_name> <region_abbr>ca</region_abbr> <postal_code>90069</postal_code> <country_name>united states</country_name> <country_abbr2>us</country_abbr2> <country_abbr>usa</country_abbr> <latitude>34.0815917</latitude> <longitude>-118.3892462</longitude> <geocode_type>evdb geocoder</geocode_type> <all_day>0</all_day> <recur_string></recur_string> <calendar_count></calendar_count> <comment_count></comment_count> <link_count></link_count> <going_count></going_count> <watching_count></watching_count> <created>2012-12-24 11:40:43</created> <owner>evdb</owner> <modified>2013-01-14 21:08:04</modified> <performers> <performer> <id>p0-001-000000517-4</id> <url>http://test.com</url> <name>antibalas</name> <short_bio>afro-beat / funk / experimental</short_bio> <creator>jfisher</creator> <linker>evdb</linker> </performer> </performers> <image> <url>http://s4.evcdn.com/images/small/i0-001/000/070/311-5.jpeg_/antibalas-11.jpeg</url> <width>48</width> <height>48</height> <caption></caption> <thumb> <url>http://s4.evcdn.com/images/thumb/i0-001/000/070/311-5.jpeg_/antibalas-11.jpeg</url> <width>48</width> <height>48</height> </thumb> <small> <url>http://s4.evcdn.com/images/small/i0-001/000/070/311-5.jpeg_/antibalas-11.jpeg</url> <width>48</width> <height>48</height> </small> <medium> <url>http://s4.evcdn.com/images/medium/i0-001/000/070/311-5.jpeg_/antibalas-11.jpeg</url> <width>128</width> <height>128</height> </medium> </image> <privacy>1</privacy> <calendars></calendars> <groups></groups> <going></going> </event> </events> </search>

i have created next classes:

public class eventsearch { public int total_items { get; set; } public int page_size { get; set; } public int page_count { get; set; } public int page_number { get; set; } public int page_items { get; set; } public string first_item { get; set; } public string last_item { get; set; } public string search_time { get; set; } public list<event> events { get; set; } } public class event { public string id { get; set; } public string title { get; set; } public string url { get; set; } public string description { get; set; } public datetime start_time { get; set; } public string venue_id { get; set; } public string venue_url { get; set; } public string venue_name { get; set; } public string venue_address { get; set; } public string city_name { get; set; } public string region_name { get; set; } public string region_abbr { get; set; } public string postal_code { get; set; } public string country_name { get; set; } public string country_abbr { get; set; } public string country_abbr2 { get; set; } public double latitude { get; set; } public double longitude { get; set; } public list<performer> performers { get; set; } public eventimage image { get; set; } } public class performer { public string id { get; set; } public string url { get; set; } public string name { get; set; } public string short_bio { get; set; } } public class eventimage { public string url { get; set; } public int width { get; set; } public int height { get; set; } public image thumb { get; set; } public image little { get; set; } public image medium { get; set; } } public class image { public string url { get; set; } public int width { get; set; } public int height { get; set; } }

in method calling, want homecoming list of events. here's have far, giving me error:

not expected.

code:

var request = webrequest.create(url); var response = request.getresponse(); if (((httpwebresponse)response).statuscode == httpstatuscode.ok) { // stream containing content returned server. stream datastream = response.getresponsestream(); // open stream using streamreader. streamreader reader = new streamreader(datastream); xmlserializer serializer = new xmlserializer(typeof(eventsearch)); eventsearch deserialized = (eventsearch)serializer.deserialize(reader); homecoming deserialized.events; }

i'm not sure next. need annotate classes?

yes, need add together attributes classes map xml elements objects.

this should work, had alter few things, datetime in xml in wrong fromat made string(you can parse needed), page_items int empty element in xml, wont able deserialize this, have alter string if has chance of beingness empty.

[xmltype("search")] public class eventsearch { public int total_items { get; set; } public int page_size { get; set; } public int page_count { get; set; } public int page_number { get; set; } // public int? page_items { get; set; } public string first_item { get; set; } public string last_item { get; set; } public string search_time { get; set; } public list<event> events { get; set; } } [xmltype("event")] public class event { [xmlattribute("id")] public string id { get; set; } public string title { get; set; } public string url { get; set; } public string description { get; set; } public string start_time { get; set; } public string venue_id { get; set; } public string venue_url { get; set; } public string venue_name { get; set; } public string venue_address { get; set; } public string city_name { get; set; } public string region_name { get; set; } public string region_abbr { get; set; } public string postal_code { get; set; } public string country_name { get; set; } public string country_abbr { get; set; } public string country_abbr2 { get; set; } public double latitude { get; set; } public double longitude { get; set; } public list<performer> performers { get; set; } public eventimage image { get; set; } } [xmltype("performer")] public class performer { public string id { get; set; } public string url { get; set; } public string name { get; set; } public string short_bio { get; set; } } [xmltype("image")] public class eventimage { public string url { get; set; } public int width { get; set; } public int height { get; set; } public image thumb { get; set; } public image little { get; set; } public image medium { get; set; } } [xmltype("thumb")] public class image { public string url { get; set; } public int width { get; set; } public int height { get; set; } }

i tested straight file using:

using (filestream stream = new filestream("c:\\test.xml", filemode.open)) { xmlserializer serializer = new xmlserializer(typeof(eventsearch)); eventsearch deserialized = (eventsearch)serializer.deserialize(stream); }

but stream webresponce should work same filestream

hope helps :)

c# xml serialization webrequest

Update a SQL table with random values from another table (no join condition) -



Update a SQL table with random values from another table (no join condition) -

i'm working on script anonymize table patient data. generated table containing 50,000 rows of anonymous data.

what need number of columns in patient table updated info generated table.

ofcourse read updating tabels , how select random row table. can't figure out how combine in 1 query.

i've seen cte possible solution, don't understand how works. 1 of main issues have generated table doesn't have key in , if did shouldn't relevant since want iterate rows of patient table updating values random row generated table.

i have following:

update patients set patients.pat_firstname = fn.givenname, pat_lastname = fn.surname, pat_streetname = fn.streetaddress, pat_postalcode = fn.zipcode, pat_city = fn.city, pat_dateofbirth = fn.birthday, ( select top 1, givenname, surname, streetaddress, zipcode, city, birthday fakenamegenerator tablesample(1000 rows)) fn

executes 'random' 1 time fill every row in patient table same values. said before, can (should be??) solved cte (tally?) tables, how?

i'm close grabbing c# , code darn thing...

another way of doing add together contiguous numeric column fakenamegenerator table

alter table fakenamegenerator add together id int not null identity(1,1) create unique nonclustered index ix on fakenamegenerator(id)

then becomes problem of generating random number between 1 , 50,000

update p set p.pat_firstname = f.givenname /*...*/ patients p inner loop bring together fakenamegenerator f on f.id = (1 + abs(crypt_gen_random(8)%50000))

the inner loop join hint enforces nested loops bring together patients driving table. seeks fakenamegenerator each row re-evaluating id seek on.

sql random common-table-expression

c - how to create alias for #include in vim -



c - how to create alias for #include<stdio.h> in vim -

everytime write programme need #include or other #include things...

is there anyway create alias this, when type inc in vim , press key, inc changes #include

you can utilize in .vimrc:

iabbrev _istd #include <stdio.h><cr>

now if type _istd include pasted. can have several includes this:

iabbrev _istd #include <stdio.h><cr>#include <stdlib.h><cr>#include <string.h><cr>

c unix vim alias

HTML CSS table row height not working -



HTML CSS table row height not working -

i want upper table row have size of kid div (cp2), couldn't command height. tried modifying margin, padding, height, tables table-layout css-attribute, doesn't want work.

code:

<!doctype html> <html> <head> <style> .cp1{ display: inline-block; width: 32px; height: 32px; background-color: red; vertical-align: top; } .cp2{ display: inline-block; width: 128px; height: 10px; background-color: black; vertical-align: top; margin:0px; margin-left: 10px; } .out{ display: inline-block; width: 3em; height: 1.2em; background-color: red; vertical-align: top; margin-left: 10px; } td,tr{ padding: 0px; margin:0px; } table{ border: 0px; table-layout:fixed; } .in{ height: 1.2em; padding: 0px; margin-left: 10px; vertical-align: top; } </style> </head> <body> <table> <tr> <td rowspan="2"> <input type="checkbox">cb1 <br/> </td> <td rowspan="2" style="padding-left: 10px;"> <div class="cp1"></div> </td> <td style="height: 1px;"> <div class="cp2"></div> </td> </tr> <tr> <td> <div class="out"></div><input class="in" type="text" size="3"> </td> </tr> </table> </body> </html>

thanks

instead of <td style="height: 1px;"> set <td style="font-size: 10px;">, , may have add together line-height: 0px.

html css table

c# - Regex - including the colon -



c# - Regex - including the colon -

i utilize regex match first twelve characters of string i've received. i'm receiving string , want validate string discard , keep. 1 time i've validated string instantiate object based on info in string.

in illustration want check specific character (a), 8 numbers, colon , either b|c followed d. pattern identifies string work with. next pattern fails match , suspect due colon

if(regex.ismatch(my_string,"a[0-9]{8,}:(b|c)d"))

i want match, zeroes number 0-9 , b interchangeable c. need verify colon present, there cases string may malformed.

example of characters should pass regex pattern;

a00000000:bd

that regex should work. few suggestions:

{8,} matches 8 , more characters. the entire regex match substrings of longer string (i.e. "xyza12345678:cdefg"). if don't want that, anchor regex. (b|c) can replaced [bc]

so seek this:

if (regex.ismatch(my_string,"^a[0-9]{8}:[bc]d"))

c# regex visual-studio-2008 .net-3.5

spring - Dependency Injection too late -



spring - Dependency Injection too late -

i using javafx 2 in conjunction spring framework, injection happens late. controller instanciated fxml-loader, spring injection fellow member variables of controller works, works late, means in (1) injection yet didn't happen , in (2) injection did happen:

public class maincontroller extends abstractcontroller { @autowired public statusbarcontroller statusbarcontroller; // implementing initializable interface no longer required according // http://docs.oracle.com/javafx/2/fxml_get_started/whats_new2.htm: private void initialize() { borderpane borderpane = (borderpane)getview(); borderpane.setbottom(statusbarcontroller.getview()); // (1) null exception! } // linked button in view public void sayhello() { borderpane borderpane = (borderpane)getview(); borderpane.setbottom(statusbarcontroller.getview()); // (2) works! } }

any way allow spring inject statusbarcontroller in before state? can't allow user have click button load gui ;-)

my appfactory this:

@configuration public class appfactory { @bean public maincontroller maincontroller() throws ioexception { homecoming (maincontroller) loadcontroller("/main.fxml"); } protected object loadcontroller(string url) throws ioexception { inputstream fxmlstream = null; seek { fxmlstream = getclass().getresourceasstream(url); fxmlloader loader = new fxmlloader(); node view = (node) loader.load(fxmlstream); abstractcontroller controller = (abstractcontroller) loader.getcontroller(); controller.setview(view); homecoming controller; } { if (fxmlstream != null) { fxmlstream.close(); } } } }

you should set controllerfactory on fxmlloader in charge of creating controller instance.

spring dependency-injection javafx-2

Exception policy for Rails API applications -



Exception policy for Rails API applications -

i want know general policy how manage exceptions in rails api application.

i suppose client should receive exceptions related customer's logic. in controller i'm catching these kind of exceptions , sending message of it.

mainapplicationexception top of hierarchy exception class exceptions in application.

class mycontroller < applicationcontroller def some_action ... # processing of request rescue mainapplicationexception => error render: { :message => error.message } end end end

but sure there're big chances exception raised while processing incoming requests.

how should register exceptions , in application should rescue these exceptions? should set these message log? there tutorial kind of problem?

exception handling hard! in general, , when building out api it's of import have grasp of http status codes. trivial illustration of 1 404. illustration you're doing company.find(params[:id] throw activerecord::recordnotfound , can caught way in application controller: rescue_from activerecord::recordnotfound, :with => :not_found

the same goes illustration info have process, if format(e.g. you're receiving 'application/xml' instead of 'application/json.') not take can throw an 406.

the hardest part handling user data, of import question arises here how much want inform user? much info might expose scheme potential hacks.

personally find controller place handle exceptions if don't impact other parts of code. otherwise nice way go might builder pattern allows compose response without handling errors in controller.

there loads of books on exception handling simple introduction on handling api errors , collection of resources might this blog post

hope helps.

ruby-on-rails exception design policy

linux - Unix process running python -



linux - Unix process running python -

i have cron execute 2 python scripts. how can see "ps" command if process running ?

my scripts names are:

json1.py json2.py

ps aux | grep json ought it, or pgrep -lf json.

python linux process

php - How to prevent attacks? -



php - How to prevent <meta http-equiv="refresh"> attacks? -

this question has reply here:

what's best method sanitizing user input php? 13 answers

i think hackers (or script kiddies) attacked website using leaks of website's codebase. posts in database changed contain html:

<meta http-equiv="refresh" content="0;url=http://example.com"/>

but can't rewrite scheme now. strategies prevent situation happening in future?

i'm thinking of migrating admin script subdomain allows access domains. or using mod_security secfilterscanpost , scanning post request containing http-equiv etc. or allowing post requests server or of them?

thank you.

the first step may investigating code injected, may help identify root clause -

if web site contents database , injected tag retrieved part of database content, site has sql injection flaw or other vulnerabilities allow attackers alter content there.

if tag in every php files, means attacker has access file system. either has access ftp or telnet or other admin consoles, or web site has vulnerabilities allow attackers modify/create files on web site.

it may possible server have vulnerabilities allow such access attackers.

after identified root cause, prepare accordingly =)

here generic advises help preventing same happening again:

review web sites , server vulnerabilities, either through code review, pen test or automatic scans , prepare them accordingly.

install update, hotfix, security patches promptly. maintain updated, updated, updated, updated...

assign proper folder permissions (read-write, read-only, no access) on file systems , grant necessary rights users (min-privilege principle).

for example, may consider making web server user readable web content folder except upload folders. configuration files don't require writable web server user. writable administrator only. careful not allow content of such files accessible via web server (i.e. via http:// url of web server). putting them outside web content root direct nice idea putting upload folders outside web content root directory nice idea mine owner of files too, because owners can freely alter permission of file.

be cautious when using 3rd-party components (e.g. wordpress/joomla plugins). utilize if trust publisher. download main site. remember maintain them up-to-dated too. disable , remove them if necessary

restrict access administrative consoles , services ftp, telnet, database administration consoles (e.g. phpmyadmin) , etc. assign passwords them. best don't allow except authorized access (e.g. using ip restrictions set in firewall or configurations, or hide behind vpn)

actually should avoid clear text protocols when passwords (especially administrator's) transmitted. there encrypted alternatives them, e.g. telnet -> ssh, ftp -> sftp/ftp, http/https. database port should avoided accessible internet. there rare screnario need this. configure hear on loop-back interface in case...

php apache security

java - new FILE doesn't Exist in OS X 10.7 -



java - new FILE doesn't Exist in OS X 10.7 -

i'm trying next getting no file created ( no errors thrown either ) on imac os x 10.7.5

tried different paths , looked @ permissions, can -> $ touch myfile1.txt through console...

if create file console , run code file detected , exists.

file f = new file("/users/myname/documents/myfile1.txt"); not create one...

why doesn't work?

file f = new file("/users/myname/documents/myfile1.txt"); if(f.exists()) { system.out.println(f.getname() + " file exists"); } else { system.out.println(f.getname() + " doesn’t exist"); }

thanks help....

when doing

file f = new file();

only object of type file created. not creating actual file.

the actual file created when use

f.createnewfile() function of class file.

java file-io

uitableview - iOS - Tabbed aplication with table view and subview -



uitableview - iOS - Tabbed aplication with table view and subview -

i have 1 problem. in app (it tabbed style), have 1 viewcontroller text , sec table view (rss reader). when have rss , set single view app, subview form rss works, when set tabbed app , click post in table view, subview didnt show up... can help me please?

here codes:

appdelegate.h

#import <uikit/uikit.h> @interface mwfeedparserappdelegate : nsobject <uiapplicationdelegate> { uiwindow *window; uinavigationcontroller *navigationcontroller; } @property (nonatomic, retain) iboutlet uiwindow *window; @property (nonatomic, retain) iboutlet uinavigationcontroller *navigationcontroller; @end

appdelegate.m

#import "mwfeedparserappdelegate.h" #import "viewcontroller1.h" #import "rootviewcontroller.h" @implementation mwfeedparserappdelegate @synthesize window; @synthesize navigationcontroller; #pragma mark - #pragma mark application lifecycle - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after app launch uitabbarcontroller *tbc = [[uitabbarcontroller alloc]init]; viewcontroller1 *vc1 = [[viewcontroller1 alloc]init]; rootviewcontroller *vc2 = [[rootviewcontroller alloc]init]; [vc1.tabbaritem settitle:@"tab1"]; [vc2.tabbaritem settitle:@"tab2"]; [tbc setviewcontrollers:[nsarray arraywithobjects:vc1, vc2, nil]]; [window addsubview:[navigationcontroller view]]; [window makekeyandvisible]; [window setrootviewcontroller:tbc]; homecoming yes; } - (void)applicationwillterminate:(uiapplication *)application { // save info if appropriate } #pragma mark - #pragma mark memory management - (void)dealloc { [navigationcontroller release]; [window release]; [super dealloc]; } @end

from dealloc, see not using arc. have memory leaks; sure release vc1 , vc2 in didfinishlaunchingwithoptions, tab bar controller retain them.

you don't need navigationcontroller property, recommend delete until know you'll need it.

i think you'll want add together rss view (vc2?) nav controller before adding tab bar controller this:

[tbc setviewcontrollers:[nsarray arraywithobjects:vc1, [[[uinavigationcontroller alloc] initwithrootviewcontroller:vc2] autorelease], nil]];

and delete line:

[window addsubview:[navigationcontroller view]];

best of luck!!

edit spelled out tad more:

viewcontroller1 *vc1 = [[[viewcontroller1 alloc] init] autorelease]; rootviewcontroller *vc2 = [[[rootviewcontroller alloc] init] autorelease]; uinavigationcontroller *navcontroller = [[[uinavigationcontroller alloc] initwithrootviewcontroller:vc2] autorelease]; uitabbarcontroller *tbc = [[[uitabbarcontroller alloc] init] autorelease]; [tbc setviewcontrollers:@[vc1, navcontroller]]; [window makekeyandvisible]; [window setrootviewcontroller:tbc];

uitableview subview tabbed-view

.net - NLP/Quest. Answering - Retrieving information from DB -



.net - NLP/Quest. Answering - Retrieving information from DB -

i've been doing bit of reading on nlp recently, , far i've got (very) basic thought of how works, ranging sentence splitting pos-tagging, , knowledge representation.

i understand there's wide diversity of nlp libraries out there (mostly in java or python) , have found .net implementation (sharpnlp). it's been first-class actually. no need write custom processing logic; utilize functions , voila! user input well-separated , pos-tagged.

what don't understand go here, if main motivation build question answering scheme (something chatterbot). libraries (preferably .net) available me use? if wish build own kb, how should represent knowledge? need parse pos-tagged input else db can understand? , if i'm using ms sql, there library helps map pos-tagged input database queries? or need write own database querying logic, according procedural semantics (i've read)?

the next step, of course, formulate well-constructed reply, think can leave later. right bugging me lack of resources in area (knowledge representation, nlp kb/db-retrieval), , i'd appreciate if of there offer me expertise :)

this broad question , such barely fits format stackoverflow, never less i'd give stab.

first, word on nlp broad availability of mature tools in area of nlp in misleading. all/most nlp functions, from, say, pos-tagging or chunking to, say, automatic summarization or named entity recognition covered , served logic , supporting info of various libraries. building real world solutions these building blocks hardly trivial task. 1 needs to:

architect solution along sort of pipeline or chain whereby results of particular transformation feed input of subsequent processes. configure individual processes: computational framework of these established extremely sensitive underlying info such training/reference corpus, optional tuning parameters etc. select , validate proper functions/processes.

the above particularly hard part of solution associated extraction , handling of semantic elements text (information extraction @ large, co-reference disambiguation, relationship extraction or sentiment analysis, name few). these nlp functions , corresponding implementations in various libraries tend harder configure, more sensitive domain-dependent patterns or variations in level of speech or in "format" of supporting corpora.

in nutshell, nlp libraries provide essential building blocks applications such "question answering systems" mentioned in question, much "glue" , much discretion how , apply glue required (along dose of non-nlp technologies such issue of knowledge representation, discussed below).

on knowledge representation hinted above, pos-tagging lone isn't sufficient element of nlp pipeline. pos-tagging add together info each word in text, indicating [likely] grammatical role of word (as in noun vs. adjective vs verb vs. pronoun etc.) pos info quite useful allows, example, subsequent chunking of text logically related groups of words and/or more precise lookup of individual words in dictionaries, taxonomies or ontologies.

to illustrate kind of info extraction , underlying knowledge representation may required "question answering system", i'll discuss mutual format used in various semantic search engines. beware format maybe more conceptual prescriptive semantic search , other applications such expert systems or translation machines require yet other forms of knowledge representation.

the thought utilize nlp techniques along supporting info (from plain "lookup tables" simple lexicons, tree-like structures taxonomies, ontologies expressed in specialized languages) extract triplets of entities text, next structure:

an agent: or "doing" something a verb : beingness done an object : person or item upon "doing" done (or more generically, complement of info "doing")

examples:   cat/agent eat/verb mouse/object.   john-grisham/agent write/verb the-pelican-brief/object   cows/agent produce/verb milk/object

furthermore kind of triplets, called "facts", can categorized various types corresponding specific patterns of semantic, typically organized around semantics of verb. illustration "cause-effect" facts have verb express causality, "contains" facts have verb imply container-to-containee relationship, "definition" facts patterns agent/subject defined [if partially] object (e.g. "cats mammals"), etc.

one can imagine how such databases of facts can queried supply answers questions, , provide various smarts , services such synonym substitution or improving relevance of answers questions (compared plain keyword matching).

the real difficulty in extracting facts text. many nlp functions set play purpose. example, 1 of steps in nlp pipeline replace pronouns noum reference (anaphora resolution or more co-reference resolution in nlp lingo). step identify named entities: names of people, of geographic places, of books etc.(ner in nlp lingo). step may rewrite clauses joined "and" create facts repeating grammatical elements implied. example, maybe john grisham illustration above came text excerpt like author j. grisham born in arkansas. wrote "a time kill" in 1989 , "the pelican brief" in 1992"

getting john-grisham/agent wrote/verb the-pelican-brief/object implies (among other things):

identifying "j. grisham" , "the pelican brief" specific entities. replacing "he" "john-grisham" in 2nd sentence. rewriting 2nd sentence 2 facts: "john-grisham wrote a-time-to-kill in 1989" , "john-grisham wrote the-pelican-brief in 1992" dropping "in 1992" part (or improve yet, creating fact, "time fact": "the-pelican-brief/agent is-related-in-time/verb year-1992/object") (btw imply having identified 1992 beingness time entity of type "year".)

in nutshell: info extraction complicated task when applied relatively limited domains , when leveraging existing nlp functions available in library. much "messier" activity simply identifying nouns adjectives , verbs ;-)

.net sql-server nlp artificial-intelligence question-answering

python - IndexError: list index out of range? -



python - IndexError: list index out of range? -

i have problem, need help of everyone. read rar file (100mb) , process text file (include in rarfile).

import glob import os import unrar2 os import path, access, r_ok os.chdir("e:\\sms") file in glob.glob("*.rar"): # extract test.txt memory entries = unrar2.rarfile(file).read_files('*.txt') test_content = entries[0][1] #print test_content line in test_content.split("\n"): a=line.split(' ') print a[1]

result:

19009057 7030 9119 9119 .... .... bla...bla... ...... 9119 9119 9119 7050 9119 traceback (most recent phone call last): file "e:\laptrinh\android\adt-bundle-windows\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd.py", line 1397, in <module> debugger.run(setup['file'], none, none) file "e:\laptrinh\android\adt-bundle-windows\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd.py", line 1090, in run pydev_imports.execfile(file, globals, locals) #execute script file "c:\users\the\documents\workspace\unrar\test_unrar.py", line 13, in <module> print a[1] indexerror: list index out of range

please, help me! give thanks you!!!

one of lines (probably last) not in format expect. in inner loop:

a=line.split(' ') if len(a) > 1: print a[1]

python list

c++ - Not getting correct address to head and tail nodes in copy constructor doubly linked list -



c++ - Not getting correct address to head and tail nodes in copy constructor doubly linked list -

copy constructor:

// re-create constructor. copies list. crevlist(const crevlist &b) { cout << "copy" << endl; const node *start = b.begin(); const node *end = b.end(); cout << "start; " << start << endl; cout << "end; " << end << endl; cout << "b.begin() : " << b.begin() << endl; cout << "b.end() : " << b.end() << endl; t temp_data; for(;;){ cout << "start->data() loop: " << start->data() << endl; temp_data = start->data(); pushback(temp_data); if(start == end) break; start = start->m_next; }

}

call end pointer tail node (begin() same):

const node *end() const {} node *end() { cout << "m_tail " << m_tail << endl; homecoming m_tail; }

sorry amount of code. can't figure out i'm going wrong

edit: okay here's minimal finish example

driver

using namespace std; #include <iostream> #include "revlist.h" int main(){ crevlist<int> list; list.pushback(7); list.pushback(300); cout << "end ref: " << list.end() << endl; cout << "begin ref: " << list.begin() << endl; cout << list.end() << endl; crevlist<int> new_list(list); cout << "end ref: " << new_list.end() << endl; cout << "begin ref: " << new_list.begin() << endl; }

implementation of doubly linked list:

template<class t> class crevlist { public: //constructor stuff doesn't matter... ; class node { public: friend class crevlist; node() {m_next = 0; m_prev = 0;} node(const t &t) {m_payload = t; m_next = 0; m_prev = 0;} t data() {return m_payload;} const t data() const {return m_payload;} private: node *m_next; node *m_prev; t m_payload; }; //push //////////////////////////////////////////////// void pushback(const t &t) { node * temp = new node(t); if(isempty()){ cout << "is empty" << endl; m_head = temp; m_tail = temp; } else{ node * curr = m_tail; curr->m_next = temp; temp->m_prev = curr; m_tail = temp; } size += 1; } //get pointer first node in list const node *begin() const {} node *begin() { cout << "m_head " << m_head << endl; homecoming m_head; } //get pointer lastly node in list const node *end() const {} node *end() { cout << "m_tail " << m_tail << endl; homecoming m_tail; } private: node *m_head, *m_tail; // head node unsigned size; }; };

and output driver

m_tail 0x2068030 end ref: 0x2068030 m_head 0x2068010 begin ref: 0x2068010 m_tail 0x2068030 0x2068030 re-create start; 0x7fff7745d240 end; 0x7fff7745d240 b.begin() : 0x7fff7745d240 b.end() : 0x7fff7745d240 start->data() loop: 2 segmentation fault //don't care right

you forgot initialize size.

c++ function pointers reference

How separate grep result with comma in bash? -



How separate grep result with comma in bash? -

i have next grep command echo $a | grep -po '(?<=demo-jms2;)[^;]+'. how can separate result of command comma?

how pipe grep output tr '\n' ','

bash grep design-patterns

asp.net - Having some trouble with a custom validator using jquery -



asp.net - Having some trouble with a custom validator using jquery -

i'm having issue getting custom validator work jquery.

here function created check , see if textbox contains po box.

function valpobox(sender, args) { var haspobox = "^p\.?\s?o\.?\sb[oo][xx]."; var streetaddress = $('.streetaddress').val(); var match = streetaddress.match(regexp(haspobox)); if (!match) { args.isvalid = false; sender.errormessage = "address must not contain p.o. box"; $('.valpobox').attr("errormessage", sender.errormessage); } else { args.isvalid = true; } }

the function fires when tab out of textbox , follow logic args.isvalid = false; not display error message.

any ideas i'm doing wrong?

the lastly line have $('.valpobox').attr("errormessage", sender.errormessage); isn't valid code. attr function sets html attribute on element. i'm guessing want add together piece of text after input , show user 1 time has failed validation.

for example, have this:

<input class="streetaddress" /><span id="poboxerror"></span>

your js turns like:

... $('#poboxerror').html(sender.errormessage); } else { args.isvalid = true; $('#poboxerror').html(''); }

this sets span after input error message, , hides 1 time again 1 time has passed validation. 1 of ways accomplish this, other ways involve showing , hiding content, tried create reply close original code possible.

jquery asp.net regex customvalidator

facebook - like button publish: name user liked index of/ on app name -



facebook - like button publish: name user liked index of/ on app name -

i have problem button: if clicked, shows on timeline post:

{name user} liked index of/ on {app name} right description , thumbnail

i set these metatag

<meta name="description" content="ho appena creato la mia storia con ''lettere d'amore'' di goldenpoint. fallo anche tu e avrai subito united nations buono sconto del 10% da utilizzare in tutti negozi goldenpoint e sullo shop on line" /> <meta property="og:image" content="<?php echo $urlthumb; ?>" /> <meta property="og:title" content="goldenpoint lettere d&#039;amore" /> <meta property="og:type" content="game" /> <meta property="og:url" content="<?php echo "https://$_server[http_host]$_server[request_uri]";?>" /> <meta property="og:site_name" content="goldenpoint lettere d&#039;amore" /> <meta property="fb:admins" content="xxxxxxxxxxxxxx" />

and button is:

<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) return; js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/it_it/all.js#xfbml=1&appid=404791622949241"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://apps.facebook.com/lettereamore/" data- send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div>

with debugger see weird thing: if type website url, perfect, if test using url of facebook app, returns index of

how can prepare this? give thanks you

facebook like metatag

android - Back button very slow -



android - Back button very slow -

i have android app tabactivity holding 4 tabs - list view, map view, list , webview. list view can tap item , starts activity, pressing returns tab activity.

however, 1 time map view tab has been visited, navigating sec activity list view , pressing button results in hang of 3-4 seconds. 1 time map view has been visited, problem never goes away until app exited.

some more notes:

the map view can launch activity - , in case button works fine - it's if map view tab inactive when sec activity launched problem occurs. testing on 2 devices - problem occurs on galaxy s, doesn't occur on nexys 7. there's nil obvious in logcat can see. app using maps api v2, , back upwards lib fragment support. app written in mono.

more info. set in log messages on map activity it's lifecycle events:

switching away map tab:

02-12 18:53:43.841 i/maptest ( 5031): onsaveinstancestate 02-12 18:53:43.857 i/maptest ( 5031): onpause

launching sec activity list view tab:

02-12 18:54:06.900 i/maptest ( 5031): onsaveinstancestate virtual void webcore::widget::show() virtual void webcore::widget::show() void webcore::scriptcontroller::updateplatformscriptobjects() virtual void webcore::widget::show() static bool webcore::resourcehandle::supportsbuffereddata() static bool webcore::resourcehandle::supportsbuffereddata() 02-12 18:54:07.353 i/maptest ( 5031): onstop

pressing button sec activity (ie: when pause occurs):

-- absolutely nil in log cat --

switching map tab:

02-12 18:54:59.056 i/maptest ( 5031): onrestart 02-12 18:54:59.060 i/maptest ( 5031): onstart 02-12 18:54:59.064 i/maptest ( 5031): onresume

what might cause returning activity block 3-4 seconds?

alternatively, more can diagnose this?

more info:

as per michal-z's comment, profiled under ddms , of time beingness spent in message dispatching, layout , drawing... i'm suspicious of sort of recursive layout or drawing issue...

also, tried removing map fragment when map activity stopped , adding when map activity started , resolved delay problem, map doesn't remember it's state, looses it's markers , it's slow reappear.

another follow up:

the only solution find remove fragment when activity stopped , add together when resumed - , saving photographic camera position. tried hiding , re-showing fragment both through fragment manager , straight on map view - no luck.

android android-tabhost android-support-library android-maps-v2

php - mysql check manual error -



php - mysql check manual error -

came across error have never seen before after writing next code:

$query= "update `pharm_log` set `text` = ". $bloodtest . " `id` = " . $patientid; $result = mysql_query($query) or die(mysql_error());

my error message

"you have error in sql syntax; check manual corresponds mysql server version right syntax utilize near 'pressure test: 235/43 id = 1' @ line 1"

any 1 have thought on how prepare this? appreciated

the string literal (value of $bloodtest) must wrap single quotes,

$query= "update `pharm_log` set `text` = '". $bloodtest . "' `id` = " . $patientid; $result = mysql_query($query) or die(mysql_error());

as sidenote, query vulnerable sql injection if value(s) of variables came outside. please take @ article below larn how prevent it. using preparedstatements can rid of using single quotes around values.

how prevent sql injection in php?

php mysql

app store - Problems after updating Xcode to 4.6 and iOS to 6.1 -



app store - Problems after updating Xcode to 4.6 and iOS to 6.1 -

i hope can help me. had finished app , ready upload app store when updated xcode 4.6 , ios on iphone 6.1. can't test app in own device without getting next error:

error: failed launch '/users/drausio/library/developer/xcode/deriveddata/surf+- hifxllpzxwzhrqgnmsjhoikiuomi/build/products/debug-iphoneos/surf+.app/surf+' -- no such file or directory (/users/drausio/library/developer/xcode/deriveddata/surf+-hifxllpzxwzhrqgnmsjhoikiuomi/build/products/debug-iphoneos/surf+.app/surf+)

besides, i'm having sorts of code signing errors when seek upload app. errors like:

application failed code sign verification. signature invalid, contains disallowed entitlements, or not signed iphone distribution certificate. unable extract codesining entitlements application. please create sure surf+ valid mach executable that's signed.

i checked , rechecked every certificate , provisioning profile. developer , distribution, ran out of ideas.

thanks in advance ideas!!

cheers

answering own question, apparently xcode didn't name of app. changed surf-.app , happened magic.

app-store code-signing provisioning xcode4.6 ios6.1

javascript - Create JSON object using TypeScript -



javascript - Create JSON object using TypeScript -

i have highcharts in code, used javascript massage info creating json object, code snippet looks like

var yearchartoptions = { chart: { renderto: 'yearchartcontainer', type: 'column', margin: [ 50, 50, 50, 50] }, title: { text: '' }, xaxis: { categories: [], labels: { rotation: -90, align: 'right' } }, yaxis: { title: { text: '' }, plotlines: [{ color: '#ff0000', width: 2, label: { style: { color: 'blue', fontweight: 'bold', zindex: -1 }, formatter: function () { homecoming '$' + highcharts.numberformat(this.value/1000, 0) +'k '; } }, zindex: 10 }] }, }; // create chart var yearchart = new highcharts.chart(yearchartoptions);

how can write in typescript have same javascript result?

add /// <reference path="highcharts.d.ts" /> tag file. can file definitelytyped. should work there.

javascript typescript

javascript - FadeIn and FadeOut effect weird -



javascript - FadeIn and FadeOut effect weird -

i using jquery , want happen is: div fades out using fadeout(). loads content url using load(). 1 time content loaded fades in using fadein(). not work,it flashes loads out loads in. think problem fading happening before load complete.i saw else had same problem when applied solution there no change.here code solution found (not working of course).

jquery('.stil_link_img a').click(function() { var x = jquery(this).attr('href') + ' #continut_eco'; jquery('#continutul_paginii').fadeout("slow").load(x,function() { jquery(this).fadein("slow") }); homecoming false });

you try:

jquery('.stil_link_img a').click(function(){ var x = jquery(this).attr('href') + ' #continut_eco ', $this = jquery('#continutul_paginii'); $this.fadeout("slow", function() { $this.load(x, function() { $this.fadein("slow") }); }); });

javascript jquery

c++ - Are there any Simple email libraries for C? -



c++ - Are there any Simple email libraries for C? -

this question has reply here:

email client library c [closed] 3 answers

i know of simple library java works gmail (http://www.oracle.com/technetwork/java/javamail/index.html), , other things i'm having hard time finding 1 c. (it can c++ too) nice if run 1 app without other downloads.

libvmime pretty simple , easy use, it's c++.

c++ c api email

java - Finding the default file encoding of a remote jvm -



java - Finding the default file encoding of a remote jvm -

i need find out default file encoding on remote java vm, in java program.

is there way execute charset.defaultcharset() on remote vm , value back... without altering programme running on remote jvm?

update:

i trying find out default charset weblogic 11g or weblogic 12c server... did not start, cannot restart , not have 'right' deploy code onto it.

i need able determine default charset of server process within java programme writing. may execute on same machine server... or not. doubtful the server , programme start same environment.

i prefer method depends on few assumption... means more code...

i cannot execute charset.defaultcharset() on server... should not have said 'execute charset.defaultcharset()'. sorry folks. need provide reply right executing charset.defaultcharset() within server process.

edit: after writing answer, discovered it's @ to the lowest degree partially based on faulty assumption, in charset.defaultcharset() isn't guaranteed homecoming same value. of approaches below should still work provided they're tried on same host target application, recommend read first 2 answers of this question more background.

in particular might easier forcibly override file.encoding instead of trying figure out is.

as javadoc of defaultcharset states:

the default charset determined during virtual-machine startup , typically depends upon locale , charset of underlying operating system.

meaning defaultcharset() read-only within jvm process , homecoming same charset jvm processes started on same machine unless environment has been changed explicitly prior starting process (eg. wrapper/launcher script starting jvm , setting different locale current process , children). if you're sure sure 2 processes started in same way, charset.defaultcharset() should homecoming same charset application you're asking for.

with backdrop, , in increasing order of annoyance/effort:

if host running unix/linux, seek procfs. eg. /proc/<vmpid>/environ , /proc/<vmpid>/cmdline (on linux) great places start because show how process actually started without obfuscation of wrapper script. solution gets bonus points because doesn't need restart/alter application inspection. things out for: lang , lc_* variables (intro locale on linux) , jvm command line parameters affecting locale. other operating systems have form of process inspection can utilize show information.

next up: compile , run on particular host/jvm:

import java.nio.charset.charset; public class dumpcharset { public static void main(string[] args) { system.out.println(charset.defaultcharset().displayname()); } }

as mentioned, if processes started in same way, charset.defaultcharset() should homecoming same value (on same host). close, replace application's jar containing main method jar containing above code temporarily (make sure class names match).

if doesn't give info need (it should), seek launching process accepts debugger, attach debugger, , drill downwards locale, and/or execute expressions similar above code.

if still doesn't give info need, can go radical , utilize dynamic bytecode weaving @ class-load time. achieved existing aop framework based on load time weaving (eg. aspectj), or straight asm 4 , java.lang.instrument api. aware there pitfalls create work, it's hard justice whether going reasonably straightforward or not in case. expect (much?) more work above methods.

java character-encoding

cordova - Tastypie - Jquery mobile - Phonegap app Sequence -



cordova - Tastypie - Jquery mobile - Phonegap app Sequence -

i plan on making iphone app web application using jquery mobile.

i've made tastypie api. not sure take here.

should first finish jquery mobile app , phonegap? or there different way go making phonegap app? developer, want efficient can.

i thinking of making web app using tastypie , jquery mobile , connect phonegap @ end. right way go it? advice in aspect me helpful.

yes , using tastypie mobile devlopement .but using titanium .... anyways tasty pie resource ..

tastypie api service if getting info using tastypie in jquery app . first check info resources working propery .atlast can compile phonegap final output. 1 time compiled cant alter code since binary or .app code ..

so create sure info fetching working proceed phonegap..

main advantage of tastypie can access info models of django , perform operations insertion,fetching etc....

things followed

make info ready using tasty pie . mean backend models. use them in jquery app . . test thoroughly , @ lastly can submit phonegap..

cordova jquery-mobile tastypie

c# - When is Double's == operator invoked? -



c# - When is Double's == operator invoked? -

it started trick question posed me.. (it's mentioned in book - c# in nutshell) here's gist of it.

double = double.nan; console.writeline(a == a); // => false console.writeline(a.equals(a)); // => true

the above doesn't seem right. should == (reference equality) & both should consistent.

seems double overloads == operator. confirmed reflector follows:

[__dynamicallyinvokable] public static bool operator ==(double left, double right) { homecoming (left == right); }

strange looks recursive , no mention of nan specific behavior. why homecoming false?

so add together more code distinguish

var x = "abc"; var y = "xyz"; console.writeline(x == y); // => false

now see

l_0001: ldc.r8 nan l_000a: stloc.0 l_000b: ldloc.0 l_000c: ldloc.0 l_000d: ceq l_000f: phone call void [mscorlib]system.console::writeline(bool) l_0014: nop l_0015: ldloca.s l_0017: ldloc.0 l_0018: phone call instance bool [mscorlib]system.double::equals(float64) l_001d: phone call void [mscorlib]system.console::writeline(bool) l_0022: nop l_0023: ldstr "abc" l_0028: stloc.1 l_0029: ldstr "xyz" l_002e: stloc.2 l_002f: ldloc.1 l_0030: ldloc.2 l_0031: phone call bool [mscorlib]system.string::op_equality(string, string) l_0036: phone call void [mscorlib]system.console::writeline(bool) for doubles, == operator phone call translates ceq il opcode where strings, translates system.string::op_equality(string, string).

sure plenty documentation ceq specifies special-cased floating point numbers , nan. explains observations.

questions:

why op_equality defined on double ? (and implementation not factor in nan specific behavior) when invoked ?

reflector's erroneous interpretation

the decompilation seeing reflector bug in reflector. reflector needs able decompile function 2 doubles beingness compared; in functions, find ceq emitted right code. result, reflector interprets ceq instruction == between 2 doubles help decompile function 2 doubles beingness compared.

by default, value types don't come == implementation. (don't user-defined structs inherit overloaded == operator?) however, of built-in scalar types have explicitly overloaded operator compiler translates appropriate cil. overload contains simple ceq based comparison, dynamic/late-bound/reflection-based invokes of == operator overload won't fail.

more details

for predefined value types, equality operator (==) returns true if values of operands equal, false otherwise. reference types other string, == returns true if 2 operands refer same object. string type, == compares values of strings.

-- http://msdn.microsoft.com/en-us/library/53k8ybth.aspx

what said implies == uses reference type semantics comparing of double. however, since double value type, uses value semantics. why 3 == 3 true, though they're different stack objects.

you can think of compiler translation how linq's queryable object contains extension methods with code in them, compiler translates these calls look trees passed linq provider instead. in both cases, underlying function never gets called.

double's comparing semantics

the documentation double allude how ceq cil instruction works:

if 2 double.nan values tested equality calling equals method, method returns true. however, if 2 nan values tested equality using equality operator, operator returns false. when want determine whether value of double not number (nan), alternative phone call isnan method.

-- http://msdn.microsoft.com/en-us/library/ya2zha7s.aspx

raw compiler source

if in decompiled c# compiler source, you'll find next code handle direct translation of double comparisons ceq:

private void emitbinarycondoperator(boundbinaryoperator binop, bool sense) { int num; constantvalue constantvalue; bool flag = sense; binaryoperatorkind kind = binop.operatorkind.operatorwithlogical(); if (kind <= binaryoperatorkind.greaterthanorequal) { switch (kind) { ... case binaryoperatorkind.equal: goto label_0127; ... } } ... label_0127: constantvalue = binop.left.constantvalue; if (((constantvalue != null) && constantvalue.isprimitivezeroornull) && !constantvalue.isfloating) { ... return; } constantvalue = binop.right.constantvalue; if (((constantvalue != null) && constantvalue.isprimitivezeroornull) && !constantvalue.isfloating) { ... return; } this.emitbinarycondoperatorhelper(ilopcode.ceq, binop.left, binop.right, sense); return; }

the above code roslyn.compilers.csharp.codegen.codegenerator.emitbinarycondoperator(...), , added "..."'s in order create code more readable purpose.

c# .net

c# - MSBuild: Describe Which Constructor to Call -



c# - MSBuild: Describe Which Constructor to Call -

i'm working msbuild task needs instantiate class. class had 1 parameterless constructor, msbuild task needed type name instantiate class. have utilize case task run specific constructors, , don't know how handle in generic way. need instantiate different flavors of classa:

public class classa { public classa() { } public classa(int someargument) { } public classa(int someargument, bool someotherargument) { } }

this original task looked like:

<dosomethingtask assembly="containsclassa.dll" type="classa" />

my ideal task phone call constructor has primitive types arguments:

<dosomethingtask assembly="containsclassa.dll" type="classa"> <constructorargs> <arg type="int">1</arg> <arg type="bool">true</arg> </constructorargs> </dosomethingtask>

i'm lost on search type of functionality. create string property called constructorargs , parse using whatever format want, i'm hoping cleaner exists. help can provide!

edit - in case wondering, actual task i'm trying modify creates pregenerated view based on instantiated entity framework dbcontext. have our own dbcontext subclass various constructors, , we'd able phone call specific 1 during view generation.

you seek use reflection , constructor dbcontext subclass.

using system; using system.collections.generic; using system.linq; using system.reflection; using system.text; using microsoft.build.framework; using microsoft.build.utilities; namespace taskclass { // class created public class mydbcontext { public int constructorarg1 { get; set; } public string constructorarg2 { get; set; } public mydbcontext() { } public mydbcontext(int constructorarg1) { constructorarg1 = constructorarg1; } public mydbcontext(int constructorarg1, string constructorarg2) { constructorarg1 = constructorarg1; constructorarg2 = constructorarg2; } } // msbuild custom task public class dosomethingtask : task { public override bool execute() { var taskparameters = new taskparametersinfo(); taskparameters.extracttaskparametersinfo(this); var type = typeof(mydbcontext); constructorinfo ctor = type.getconstructor(taskparameters.types.toarray()); if (ctor == null) { // if constructor not found, throw error log.logerror("there no constructors defined these parameters."); homecoming false; } // create instance var mydbcontext = (mydbcontext)ctor.invoke(taskparameters.values.toarray()); homecoming true; } public int constructorarg1 { get; set; } public string constructorarg2 { get; set; } public string constructorarg3 { get; set; } // class handle task's parameters internal class taskparametersinfo { public list<type> types { get; set; } public list<object> values { get; set; } public taskparametersinfo() { types = new list<type>(); values = new list<object>(); } public void extracttaskparametersinfo(task task) { foreach (var property in task.gettype().getproperties(bindingflags.public | bindingflags.declaredonly | bindingflags.instance)) { var propertyvalue = property.getvalue(task, null); if (propertyvalue != null) { types.add(property.propertytype); values.add(propertyvalue); } } } } } }

import task on msbuild project:

<?xml version="1.0" encoding="utf-8" standalone="no" ?> <project toolsversion="4.0" defaulttarget="dosomething" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <usingtask taskname="taskclass.dosomethingtask" assemblyfile="taskclass\taskclass\bin\debug\taskclass.dll"/> <target name="dosomething"> <dosomethingtask constructorarg1="123" constructorarg2="are u talking me?" /> </target> </project>

hope helps.

c# .net msbuild msbuild-task

ios - How can I get the actual date and time if the device date and time are inaccurate? -



ios - How can I get the actual date and time if the device date and time are inaccurate? -

i noticed if set device time manually, , turn off automatic time sync on ios device, [nsdate date] returns date , time assuming device time correct--which may not be.

since docs mention nsdate has sort of sync ntp, wondering if there built-in way accurate date , time instead of having assume device date , time correct.

perhaps https://github.com/jbenet/ios-ntp can help you? it's library can fetch date , time time server.

ios nsdate ntp

php - Display images stored in a database without using header -



php - Display images stored in a database without using header -

i photo maintain stored in view using next code problem can not play because need header('content-type: image/jpeg'); implementation display., have orders sure before header('content-type: image/jpeg'); should display images no header.

if you're outputting image, doesn't matter if have other php instructions before since output should image.

if trying output image straight html document, consider using info uri:

<img src="data:image/jpeg;base64,<?php echo base64_encode($imagedata); ?>" />

php mime-types content-type

java - 7165X786 size of large image could't be display in real device(Tablets) -



java - 7165X786 size of large image could't be display in real device(Tablets) -

i having problem of displaying big image android. have tried done custom- scrollable-image-view .

i have used total view in class , used 7165*786 size of image it. , of 1.11mb of image. able run code in bluestack , see image in couldn't load in real device.

bmlargeimage = bitmapfactory.decoderesource(getresources(), r.drawable.imagewithout); bmlotusimage1 = bitmapfactory.decoderesource(getresources(), r.drawable.lotus);

i using same canvas in ondraw methow below.

canvas.drawbitmap(bmlargeimage, scrollrect, displayrect, paint); canvas.drawbitmap(bmlotusimage1, 45 - newscrollrectx, 255 - newscrollrecty, paint);

i not able display bmlargeimage in real device can see lotus image on device not big one.

should have decode or scale image or else display in real device?

i solution of not displaying image in real device problem simply.

i have removed target sdk error in webservice. start showing image real device , solution displaying image fit screen below.

private static bitmap shrinkbitmap(string backgroundimage, int width, int height) { // todo auto-generated method stub bitmapfactory.options bmpfactoryoptions = new bitmapfactory.options(); bmpfactoryoptions.injustdecodebounds = true; bitmap bitmap = bitmapfactory.decodefile(backgroundimage, bmpfactoryoptions); int heightratio = (int) math.ceil(bmpfactoryoptions.outheight / (float) height); int widthratio = (int) math.ceil(bmpfactoryoptions.outwidth / (float) width); if (heightratio > 1 || widthratio > 1) { if (heightratio > widthratio) { bmpfactoryoptions.insamplesize = heightratio; } else { bmpfactoryoptions.insamplesize = widthratio; } } bmpfactoryoptions.injustdecodebounds = false; bitmap = bitmapfactory.decodefile(backgroundimage, bmpfactoryoptions); homecoming bitmap; }

and have passed image width adn height parameter in method.

bmlargeimage = shrinkbitmap(backgroundimage, 7165, 786);

java android imageview large-files

Using AWK to Process Input from Multiple Files -



Using AWK to Process Input from Multiple Files -

many people have been helpful posting next solution awk'ing multiple input files @ once:

$ awk 'fnr==nr{a[$1]=$2 fs $3;next}{ print $0, a[$1]}' file2 file1

this works well, wondering if explain me why? find awk syntax little bit tough hang of , hoping wouldn't mind breaking code snippet downwards me. give thanks time , help!

awk 'fnr==nr{a[$1]=$2 fs $3;next}

here handle 1st input (file2). say, fs space, build array(a) up, index column1, value column2 " " column3 fnr==nr , next means, part of codes work file2. man gawk check nr , fnr

{ print $0, a[$1]}' file2 file1

when nr != fnr it's time process 2nd input, file1. here print line of file1, , take column1 index, find out value in array(a) print. in word, file1 , file2 joined column1 in both files.

for nr , fnr, shortly,

1st input has 5 lines 2nd input has 10 lines, nr 1,2,3...15 fnr 1...5 1...10

you see trick of fnr==nr check.

awk

r - Calculate cumulatve growth/drawdown from local min/max -



r - Calculate cumulatve growth/drawdown from local min/max -

i'm learning r (and application trading tasks via quantmod lib) , looking through community pretty regularly lot of new knowledge , tricks here. impression r in general , quantmod lib in particular - it's awesome.

at point need help of seasoned r users. i'm using timeseries downloaded via getsymbols , need calculate cumulative growth/drawdown local minimum/maximum respectively.

i can solve task using cycles can necessary modelling in ms excel, want figure out more simple solution not require cycles , more "native" in r.

example. input data:

20121121 79810 20121122 79100 20121123 80045 20121126 81020 20121127 80200 20121128 81350 20121129 81010 20121130 80550 20121203 80780 20121204 81700 20121205 83705 20121206 83350 20121207 83800 20121210 85385

result:

close cumulative gr/dd 20121121 79810 n/a 20121122 79100 0.58% 20121123 80045 1.55% 20121126 81020 2.37% 20121127 80200 -0.10% 20121128 81350 0.06% 20121129 81010 -0.76% 20121130 80550 -0.82% 20121203 80780 0.73% 20121204 81700 3.78% 20121205 83705 5.19% 20121206 83350 -1.50% 20121207 83800 1.67% 20121210 85385 2.22%

the calculation in tseries bundle function maxdrawdown. here origin of example:

mxdrwdr> # toy illustration mxdrwdr> x <- c(1:10, 9:7, 8:14, 13:8, 9:20) mxdrwdr> mdd <- maxdrawdown(x) mxdrwdr> mdd $maxdrawdown [1] 6 $from [1] 20 $to [1] 26

turning percentages pretty easy -- @ (short) code of function itself.

r time-series xts quantmod

html - CSS causing a blank gap in the right -



html - CSS causing a blank gap in the right -

this chunk of css code causing problem. http://www.asifslab.com unused space displayed can't find mistake. when take out code no space @ side when there there long gap right.

@import url(http://fonts.googleapis.com/css?family=oxygen+mono); /* starter css menu */ #cssmenu { padding: 0; margin: 0; border: 0; } #cssmenu ul, #cssmenu li { list-style: none; margin: 0; padding: 0; } #cssmenu ul { position: relative; z-index: 597; } #cssmenu ul li { float: left; min-height: 1px; vertical-align: middle; } #cssmenu ul li.hover, #cssmenu ul li:hover { position: relative; z-index: 599; cursor: default; } #cssmenu ul ul { visibility: hidden; position: absolute; top: 100%; left: 0; z-index: 598; width: 100%; } #cssmenu ul ul li { float: none; } #cssmenu ul ul ul { top: 0; left: auto; right: -99.5%; } #cssmenu ul li:hover > ul { visibility: visible; } #cssmenu ul ul { bottom: 0; left: 0; } #cssmenu ul ul { margin-top: 0; } #cssmenu ul ul li { font-weight: normal; } #cssmenu { display: block; line-height: 1em; text-decoration: none; } /* custom css styles */ #cssmenu { background: #333; border-bottom: 4px solid #ff3a34; font-family: 'oxygen mono', tahoma, arial, sans-serif; font-size: 12px; position: relative; margin-left: -8px; margin-right: -8px; z-index: 1000; } #cssmenu:after, #cssmenu ul:after { content: ''; display: block; clear: both; } #cssmenu ul { text-transform: uppercase; } #cssmenu ul ul { border-top: 4px solid #ff3a34; text-transform: none; min-width: 190px; } #cssmenu ul ul { background: #ff3a34; color: #fff; border: 1px solid #ff0901; border-top: 0 none; line-height: 150%; padding: 16px 20px; } #cssmenu ul ul ul { border-top: 0 none; } #cssmenu ul ul li { position: relative; } #cssmenu ul ul li:first-child > { border-top: 1px solid #ff0901; } #cssmenu ul ul li:hover > { background: #ff534d; } #cssmenu ul ul li:last-child > { -moz-border-radius: 0 0 3px 3px; -webkit-border-radius: 0 0 3px 3px; border-radius: 0 0 3px 3px; -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box; -moz-box-shadow: 0 1px 0 #ff3a34; -webkit-box-shadow: 0 1px 0 #ff3a34; box-shadow: 0 1px 0 #ff3a34; } #cssmenu ul ul li:last-child:hover > { -moz-border-radius: 0 0 0 3px; -webkit-border-radius: 0 0 0 3px; border-radius: 0 0 0 3px; -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box; } #cssmenu ul ul li.has-sub > a:after { content: '+'; position: absolute; top: 50%; right: 15px; margin-top: -8px; } #cssmenu ul li:hover > a, #cssmenu ul li.active > { background: #ff3a34; color: #fff; } #cssmenu ul li.has-sub > a:after { content: '+'; margin-left: 5px; } #cssmenu ul li.last ul { left: auto; right: 0; } #cssmenu ul li.last ul ul { left: auto; right: 99.5%; } #cssmenu { background: #333; color: #cbcbcb; padding: 0 20px; } #cssmenu > ul > li > { line-height: 48px; }

just clarify htmled's answer, 2 quotes w3schools.com:

"visibility:hidden hides element, still take same space before. element hidden, still impact layout."

"display:none hides element, , not take space. element hidden, , page displayed if element not there."

link: http://www.w3schools.com/css/css_display_visibility.asp

html css

authorization - Paypal: Is there a way to check a cart right before a user pays? -



authorization - Paypal: Is there a way to check a cart right before a user pays? -

is there way paypal's api send site authorization request before completing user's payment?

i think reply here there no way this, 1 can set "authorization" cart parameter instead of "sale". still leaves question of how finish authorization in callback.

may clarify uncertainty extent.

authorization & capture starts when buyer authorizes payment amount during checkout.

for example, can utilize paypal express checkout api paymentaction element set authorization or order.

after buyer completes checkout, can utilize payment’s transaction id authorization & capture apis. can:

capture either partial amount or total authorization amount.

authorize higher amount, 115% of authorized amount (not exceed increment of $75 usd).

void previous authorization.

paypal authorization payment

What characters are allowed in twitter hashtags? -



What characters are allowed in twitter hashtags? -

in developing ios app containing twitter client, must allow user generated hashtags (which may created elsewhere within app, not in tweet body).

i ensure such hashtags valid twitter, error check entered value invalid characters. bear in mind users may non-english speaking countries.

i aware of usual limitations, such not origin hashtag number, , no special punctuation characters, wondering if there known list of additional characters technically allowed within hashtags (i.e. international characters).

karl, you've rightly pointed out, word in language can valid twitter hashtag (as long meets number of basic criteria). such asking list of valid international word characters. i'm sure has compiled such list somewhere, using not efficient approach reaching appears initial goal: ensuring given hashtag valid twitter.

i believe, looking regular look can match word characters within unicode range. such look not dependant on locale , match characters in modern typography can appear part of word.

you didn't specify language writing app in, can't help language specific implementation. however, basic approach follows:

check if of bracket expressions or character classes back upwards unicode character ranges in language. if yes, utilize them.

check if there regex modifier can enable unicode character range back upwards language.

most modern languages implement regular expressions in similar way , lot of them borrow heavily perl, hope next 2 illustration set on right track:

perl:

use posix bracket expressions (eg: [[:alpha:]], [[:allnum:]], [[:digit:]], etc) give greater command on characters want match, compared character classes (eg: \w).

use /u modifier enable unicode back upwards when pattern matching. under modifier, ascii platform becomes unicode platform; , hence, example, \w match of more 100,000 word characters in unicode.

see perl documentation more info:

http://perldoc.perl.org/perlre.html#character-set-modifiers http://perldoc.perl.org/perlrecharclass.html#posix-character-classes

ruby:

use posix bracket expressions encompass non-ascii characters. instance, /\d/ matches ascii decimal digits (0-9); whereas /[[:digit:]]/ matches character in unicode nd category.

see ruby documentation more info:

http://www.ruby-doc.org/core-2.1.1/regexp.html#class-regexp-label-character+classes

examples:

given list of hashtags, next regex match hashtags start word character (inc. international word characters) , followed word character, number or underscore:

m/^#[[:alpha:]][[:alnum:]_]+$/u # perl /^#[[:alpha:]][[:alnum:]_]+$/ # ruby

twitter hashtag

How to revert uncommited changes to a files of certain type in git -



How to revert uncommited changes to a files of certain type in git -

i have bunch of modified files in git repository , big number of them xml files. how revert changes (reset modifications) of xml files?

you don't need find or sed, can utilize wildcards git understands them (doesn't depend on shell):

git checkout -- "*.xml"

the quotes prevent shell expand command files in current directory before execution.

you can disable shell glob expansion (with bash) :

set -f git checkout -- *.xml

this, of course, irremediably erase changes!

git git-revert

parsing - Backbone How can i load only part of a json file into a collection -



parsing - Backbone How can i load only part of a json file into a collection -

hi have json file looks this:

{ "links_1": [ { "navn": "somename", "link": "http://www.domane.com" }, { "navn": "somename", "link": "http://www.domane.com" }, { "navn": "somename", "link": "http://www.domane.com" } ], "links_2": [ { "navn": "someothername", "link": "http://www.domane.com" }, { "navn": "someothername", "link": "http://www.domane.com" }, { "navn": "someothername", "link": "http://www.domane.com" } ] }

then have collection class. want create new collection contains links_1 array json file. , new collection contains links_2 array json file.

how accomplish that?

var col = new collection( collection.prototype.parse = function(response){ homecoming response.links_1; }

so illustrate further, want fetch specific json info objects.

var col = new collection(); col.fetch(links_1); // here want links_1 json info var col2 = new collection(); col2.fetch(links_2); // here want links_2 json info

any help great.

you're on right track trying override parse, you're doing incorrectly. try:

//define collection class var link1collection = backbone.collection.extend({ parse:function(response) { homecoming response.links_1 } }); //initialize new instance of collection class , fetch var collection = new link1collection(); collection.fetch();

edit: select field want extract on instance-to-instance basis, can pass custom alternative in fetch options. options passed parse:

//define collection class var linkcollection = backbone.collection.extend({ parse:function(response, options) { homecoming options.parsefield ? response[options.parsefield] : response; } }); //initialize new instance of collection class , fetch var collection = new linkcollection(); collection.fetch({parsefield:'links_1'});

json parsing backbone.js collections fetch

html - Good CSS library for print and "report" style formatting -



html - Good CSS library for print and "report" style formatting -

what css library can used generating reports, in both preview , print form?

the key in "reports" more formal (and printable) document actual web page.

features good:

support pagination, both web , print printing support anything save time page formatting (e.g., landscape vs portrait, a4 vs letter, etc) pdf back upwards

html css django printing web-publishing

ruby on rails - Update status will show user name -



ruby on rails - Update status will show user name -

previously in app owner of guideline edit own guideline, able edit guideline , when has updated 'edited .... on .... date'. possible?

my update action in guidelines_controller.rb is

def update @guideline = guideline.find(params[:id]) if params[:guideline] && params[:guideline].has_key?(:user_id) params[:guideline].delete(:user_id) end respond_to |format| if @guideline.update_attributes(params[:guideline]) format.html { redirect_to @guideline, notice: 'guideline updated.' } format.json { head :no_content } else format.html { render action: "show" } format.json { render json: @guideline.errors, status: :unprocessable_entity } end end end

and edit action in same controller is

def edit @guideline = guideline.find(params[:id]) @specialties = guideline.order(:specialty).uniq.pluck(:specialty) end

user model user.rb is

attr_accessible :content, :hospital, :title, :user_id, :guideline_id, :specialty has_many :guidelines has_many :favourite_guidelines

guidelines model is

belongs_to :user has_many :favourite_guidelines

if want maintain history of edits, have create table (guideline_edits : guideline_id, user_id, edited_at) , can show lastly edited @ . if want track changes went each of edits, can utilize audited gem

if not want maintain history, can add together edited_by (current user), edited_at (time.now()) fields guideline , update these columns on updating guideline.

and ofcourse, in authorization rules, have allow logged-in user edit guideline.

hope helps

ruby-on-rails ruby-on-rails-3

c# - Error while adding a new record from text boxes to database -



c# - Error while adding a new record from text boxes to database -

error when saving info database. dataadapter.fill(ds,"table") throwing sqlexception saying error while converting info type nvarchar numeric.

private void btnsave_click_1(object sender, eventargs e) { da = new sqldataadapter(); da.selectcommand = new sqlcommand("select * measurement id = @id", con); da.selectcommand.parameters.addwithvalue("@id",txtid.text); sqlcommandbuilder cb = new sqlcommandbuilder(da); da.fill(ds, "measurement"); //(sqlexception unhandled)error converting info type nvarchar numeric. if (string.isnullorempty(txtcellno.text.trim())) { messagebox.show("please come in cell number"); } else { seek { dr = ds.tables["measurement"].rows[0]; dr["cellnumber"] = txtcellno.text.trim(); dr["firstname"] = txtfirstname.text; dr["lastname"] = txtlastname.text; dr["shirt"] = txtshirt.text; dr["pant"] = txtpant.text; dr["duedate"] = txtduedate.text; dr["date"] = txtdate.text; cb.getupdatecommand(); da.update(ds, "measurement"); } grab (exception ex) { messagebox.show(ex.message); } } }

this line:

da.selectcommand.parameters.addwithvalue("@id",txtid.text);

txtid.text string need convert integer. see int.tryparse

c# winforms

actionscript - Flash DataGrid DataProvider Manipulation -



actionscript - Flash DataGrid DataProvider Manipulation -

posting colleague. please don't up-vote or down-vote.

this within same mxml file.

public function togglemonitor(part:object):void { if(part.active == 0) part.active = 1; else part.active = 0; } public function monitorall(monitor:int):void { for(var part:object in blah) { part.active = monitor; } } <mx:datagrid dataprovider="{blah}"> <mx:columns> <mx:datagridcolumn> <mx:itemrenderer> <mx:component> <mx:image source="{data.active == 0 ? img1 : img2}" click="outerdocument.togglemonitor(data)"/> </mx:component> </mx:itemrenderer> </mx:datagridcolumn> </mx:columns> </mx:datagrid> <mx:button click="monitorall(1)"/>

clicking on image right toggles image (i.e. togglemonitor function works). clicking on button doesn't (i.e. monitorall function not work). why isn't button working?

he managed work out issue. method should this:

public function monitorall(monitor:int):void { blah.refresh(); (var i:int = 0; < blah.length; i++){ (blah.getitemat(i) object).active = monitor; } blah.refresh(); }

flash actionscript datagrid dataprovider