Posts

Showing posts from June, 2013

node.js - In JetBrains WebStorm 6, NodeJS/Javascript how can you define, in the comments a JSON example? -

i have function json parameter comes same structure each time. /** * @param box {object} */ function testbox( box ) i looking way instruct autocomplete of structure insert in input parameter aside fact {object}. looking avoid typos in coding function. i have noticed if add structured json var, later in function ide hints of structure, in case of function parameter, don't such thing. how might 1 this? please, see following thread: https://groups.google.com/forum/?fromgroups#!topic/jsdoc-users/vr5rez1i8jc - recommended way of documenting using @typedef webstorm support jsdoc @typedef annotation. in case oif problems resolving/typehinting, please, feel free file bug http://youtrack.jetbrains.com/issues/web

objective c - Doubts on concurrency with objects that can be used multiple times like formatters -

maybe stupid question ask need confirmations on it. usually, when deal objects can used multiple times within application use approach following. create extension, example nsdecimalnumber+extension , or class utility number formatter created following. + (nsnumberformatter*)internal_sharednumberformatter { static nsnumberformatter* _internal_numberformatter = nil; static dispatch_once_t oncetoken; dispatch_once(&oncetoken, ^{ _internal_numberformatter = [[nsnumberformatter alloc] init]; // other configurations here... }); return _internal_numberformatter; } + (nsstring*)stringrepresentationofdecimalnumber:(nsdecimalnumber*)numbertoformat { nsstring *stringrepresentation = [[self class] internal_sharednumberformatter] stringfromnumber:numbertoformat]; return stringrepresentation; } this approach quite since, example, formatters expensive create. applied other situations well. now, questions following. does approach valid ...

ios - Changing the background image using UISwitch -

hi im working on simple app changing background image using uiswitch . the problem on device pictures in original size. i'm using 960 x 640 png's, should fine on device huge. thats using. - (ibaction)changedstate:(uiswitch*)sender { uiswitch *switchvalue = (uiswitch*)sender; [self settorchon:[switchvalue ison]]; if(switchvalue.on) { // lights on self.view.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"latarka_4_on.png"]]; } else { // lights off self.view.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"latarka_4_off.png"]]; } } make sure have 2 sets of images.- latarka_4_on.png latarka_4_off.png for sd resolution (480 x 320). and latarka_4_on@2x.png latarka_4_off@2x.png for hd resolution (960 x 640) chances going wrong if have pngs no suffixes @2x retina resolution.

java - Read structured binary file -

i want read binary file in java. know file contains succession of data structures as: ansi ascii byte string, integer, ansi ascii byte string. how can read , data of file, if suppose number of data structures known (n)? see interface datainput has method readutf() read string, uses utf-8 format. how can hanle case od ascii? the flexible (and efficient) approach, think, is: open fileinputstream . obtain filechannel using stream's getchannel() method. map channel mappedbytebuffer using channel's map() method. access data through buffer's various get* methods.

ruby on rails - What is the reason to use ||= instead of = in model to define a constant -

found in current project: class video < activerecord::base ... valid_video_hosts ||= %w(www.youtube.com youtube.com vimeo.com www.vimeo.com) ... end usually use simple valid_video_hosts = %w(...) , haven't guess why previous developers used ||= anybody know benefits? update i know ||= in general cases, question defining constant way in model. ||= used cheap way memoize value , other posters mention. however... why memoize constant? the author protecting against warnings when loading source file multiple times. ( warning: initialized constant valid_video_hosts )

ruby bundle install fails with (Errno::EEXIST) -

i'm on ubuntu 12.10. installed rvm , ruby 1.9.3 on top of , gem rails , bundle. trying run bundle install or better so rvmsudo bundle install both gives me same error: fetching git://github.com/resque/resque.git unfortunately, fatal error has occurred. please see bundler troubleshooting documentation @ http://bit.ly/bundler-issues. thanks! /home/snir/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': file exists - /home/snir/.rvm/bin/bundle (errno::eexist) /home/snir/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir' /home/snir/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p' /home/snir/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each' /home/snir/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p' and goes.. i not around it. reinstalling bundle didn't help, reinstall ruby , didn...

javascript - Type of datastructure -

i have multiple questions contains sub questions. store in data structure can choose sub question when user selects first question. also, sub questions uses general questions within category. thought using multidimensional array realized take quite long time search through array. any suggestion appreciated. thank you this solution far. //key question , value(object) contains value related question categorytosubquestions[2] = {"what type of countertop?":{ "stone_slab_countertops": "stone slab countertops", "granite_countertops" : "granite countertops", "marble_countertops" : "marble countertops", "quartz_countertops" : "quartz countertops", "slate_countertops" : "slate countertops", ...

mysql - How to Optimize the below query -

select c.std_date,c.conf_link,c.conf_link link,c.conf_id,c.url_id,c.entry_source,c.data_source,c.title,c.conf_domain, c.descrip, c.std_loc, c.std_practices,c.region, co.company_id,co.company,co.home_url conferences c, companies co c.org_id= co.company_id , c.org_id in (12,47,173,120,102,83,95,172,200,78,199,523,134,123,30,185,103,202, 159,133,178,49,161,146,17,212,136,43,107,147,142,3, 205,171,177,443,175,74,156,41,42,128,5,7,62,37,195,68,89,8,39,85,126,36,24,206,208,201,150,152,168,59,97,28,11,116,140,98,117,51,174,93,192,50,617,176,101,194,527,61,179,170,145,40,92,257,149,48,88,486,20,111,106,203,19,31,163,81,25,38,623,628,642,643,644,645,647,677,711,712,713,6173,6174,6176,6177,6184,6185,6186,6189,6191,6207,6210,6211,6212,6214,6215,6217,6218,6219,6222,6223,6224,6294,6297,6298,6300,6301,6302,7468,7469,7471,7472,7473,7474,7475,7476,7477,7478,7479,7480,7481,7482,7483,7484,7489,7490,7491,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,7503,7504,7505,750...

html - Adding float: left breaks list -

i have visual element called "plan", listed in html page. each "plan" has small table , image, want show side side. without styling looks this: http://jsfiddle.net/dctwd/1/ i thought use float: left in table , image make them display in same row, doesn't work. isn't possible use float: left inside li ? else how can achieve this? no need ancient float:left; , when display:inline-block; best friend! your updated jsfiddle . overly simple example, actual css should involve class-based rather element-based css, gets point across. notice fallback of zoom:1; *display:inline; ie7-, , vertical-align:middle; aesthetics. can use top or bottom , whatever works you.

javascript - Not being available to change user installation in Parse Cloud Code -

i trying add new channels parse installation of other users using parse cloud. parse cloud code: parse.cloud.define("subscribetochannel", function(request, response) { var channelname = request.params.channel; var ids = request.params.ids;//this array of ids change var _ = require("underscore"); _.each(ids, function(id) { // create pointer user based on object id var user = new parse.user(); user.id = id; // need master key update installations parse.cloud.usemasterkey(); // user might have more 1 installation var query = new parse.query(parse.installation); query.equalto("user", user); // match installations pointer user query.find({ success: function(installations){ (var = 0; < installations.length; i++){ // add channel installations user installations[i].addunique("channels", channelname); } // save installations parse.object.saveall(installations, { ...

ios - NavigationBar's title showing only the half-top -

to make long story short, that's get: http://img839.imageshack.us/img839/9461/capturedcran20130418000x.png here code appdelegate: [[uinavigationbar appearance] setbackgroundimage:[uiimage imagenamed:@"main_bar.png"] forbarmetrics:uibarmetricsdefault]; [[uinavigationbar appearance] settitletextattributes: [nsdictionary dictionarywithobjectsandkeys: //[uicolor colorwithred:125.0/255.0 green:111.0/255.0 blue:100.0/255.0 alpha:1.0], //uitextattributetextcolor, //[uicolor colorwithred:0.0 green:0.0 blue:0.0 alpha:0.8], //uitextattributetextshadowcolor, //[nsvalue valuewithuioffset:uioffsetmake(0, 0)], //uitextattributetextshadowoffset, [uifont fontwithname:@"pacifico" size:25], uitextattributefont, nil]]; [[uinavigationbar appearance] settitleverticalpositionadjustment:-10 forbarmetrics:uibarmetricsdefault]; what can possibly problem ? i've had similar problems , sorted them out using this: - (id)initwithnibname:(nsstring...

python - How to pass a url value to all subsequent items in the Scrapy crawl? -

i creating crawlspider scrape product website. page 1, extract category urls of form www.domain.com/color (simplified). on category page, follow first link product detail page, parse product detail page , crawl next 1 via next link. each color category therefore has unique crawl path. the difficulty color variable not on product detail page. can extract category page parsing link follows: def parse_item(self, response): l = xpathitemloader(item=greenhouse(), response=response) l.default_output_processor = join() l.add_value('color', response.url.split("/")[-1]) return l.load_item() however, want add color value items parsed product detail page products crawled starting particular color category page. product urls crawled following next links, referring category page lost after first link. there in scrapy docs request.meta can pass data between parsers, i'm not sure applies here. appreciated. my rules are: rule(sgmllink...

Django user.is_authenticated works in views but not templates -

i have view , logs in user: def login_user(request): c = {} c.update(csrf(request)) username = password = '' if request.post: username = request.post.get('username') password = request.post.get('password') user = authenticate(username=username, password=password) if user not none: if user.is_active: login(request, user) c.update(user(request)) return redirect('/module/') else: return redirect('/inactive/') else: return redirect('/failure/') return render_to_response('core/auth.html',c) this correctly logs in user, can access django admin page if on superuser. after logging in , being redirected display username on screen, using {% if user.is_authenticated %} <p class="navbar-text pull-right">welcome, {{ user.username }}. logging in.</p> {% else %} <p class=...

Bitwise Operations in C: setting bits from left -

given integer 10, how write 10 1 bits (starting left) in total of 16 bits so: 11111111.11000000 or given integer 4, write: 11110000.00000000 thanks, i'm still learning c , not familiar bitwise operations. -(1 << wordsize - numbits) ought it. it's instructive see happens in example. 1 << wordsize - numbits 1 << 12 , 00010000.00000000 . recalling -x = ~x+1 , compute ~(1 << 12) = 11101111.111111 . add 1 , 11110000.00000000 .

css - Is there a way to ensure all text-align: center text is indeed centered? -

i attempting assemble footer bootstrap. reason footer links appear off-center, despite making sure text-align: center; applied. there way ensure text elements indeed aligned properly? html <!doctype html> <html> <body> <div class="container-fluid"> <section class="row-fluid"> <div class="span12"> <h1 class="landing"> lorem ipsum </h1> <h4 class="landing"> lorem ipsum lorem ipsum lorem ipsum </h4> </div> </section> </div> <footer class="footer"> <section class="row-fluid"> <ul class="footer-links"> <li> <a href="#">contact</a> </li> <li> <a href="#">about</a> <...

mysql - Edit account information from android app -

i working on android app group of people , have our app connected database store user accounts app. making profile page , want support features edit password, email, ect. how go doing that? need give user permission information on database , allow them edit name, password, ect. new android development, , coming sites on google on how this. links, tutorials, amazing. oh , our database written in mysql, on remote server. this doesn't seem android question specifically. seems me there 2 components here: server-side component , client side. question how implement updating values in database question how expose such functionality in web api how perform such crud operations in mysql database in other words, think "thin client, thick server". app should concerned ui of updating profile , sending updates values server knows how handle that. latter part of purely web development/api development question. while may not answer question exactly, point correct a...

c# - How do i fix a Number Overflow with Monogame and Xamarin? -

i have installed latest versions of osx, xcode, , xamarin monotouch on development hardware, , cannot simplest monogame example run properly. this bouncing box example, , crashes when application starts, on first initialization of color struct = 255: public byte { ... set { this._packedvalue = (this._packedvalue & 0x00ffffff) | ((uint)(value << 24)); } } this code works fine on windows , ios simulator, when run on ipad 1 (ios 5) or iphone 5 (ios6), exception "system.overflowexception: number overflow.". if change code not cause overflow: set { var val = (uint)value; var val2 = val << 24; this._packedvalue = (this._packedvalue & 0x00ffffff) | val2; } this problem goes away, same problem exhibited r, g, , b properties well. intuition monogame wasn't written number overflow in mind, , there may countless examples of this. must 'new' problem since example code written. is there compiler switch ...

Effective video stream compression in C# -

i looking effective way compress real time video stream. in project, streaming seems important because system send , receive both audio , video streams @ same time. considering using h261 or h263. how can achieve such compression ratio using c#? ps found called h323plus, not know how call library because written in c++. if want real-time streaming on udp both audio , video stream can use directshow api (if you're targeting windows). http://msdn.microsoft.com/en-us/library/windows/desktop/dd375454(v=vs.85).aspx you find .net wrapper directshow here http://directshownet.sourceforge.net/ you find more samples on codeproject.com, of them use wrapper http://www.codeproject.com/kb/audio-video/#directshow if plan on targeting windows 7 , newer only, want use windows media foundation api http://msdn.microsoft.com/en-us/library/windows/desktop/ms694197(v=vs.85).aspx

subquery - MYSQL sub query performance inconsistency -

g-day, i'm puzzled following. when run query takes long time resolve: select * test id in (select id test2 customer = 'harry'); when run sub query resolves '13454' in spit second. when change main query's statement in ('13454') resolves instantly. someone have idea why won't run in it's original format?? cheers, rene the reason quirk of mysql. subquery executed each row of outer table. to fix this, use exists : select * test exists (select id test2 test2.customer = 'harry' , test2.id = test.id); this work efficiently if have index on test2(customer, id) . i should add depends on version of mysql (i think fixed in 5.5). older documentation explains as: consider following subquery comparison: outer_expr in (select inner_expr ... subquery_where) mysql evaluates queries “from outside inside.” is, first obtains value of outer expression outer_expr, , runs subquery , captures rows produ...

php - URL rewrite and robots.txt -

i have made urls seo friendly i.e. http://mydomain.com/topic/title-of-page previously, url of above page was http://mydomain.com/search?id=6567889 now google still showing second url in search results. question if disallow /search in robots.txt , google stop crawling page altogether or still crawl mydomain.com/topic/title-of-page i.e. new url? thanks lot help. sorry spaces in url wouldn't let me post them seb you'll want fix right away. there going issues duplicated content on site in regard seo. to cut half of search engine traffic site, add robots.txt file: user-agent: * disallow: /search.php that way none of search engines mine old link. may still have cached search results. being said you'll need handle each of pages serve 301 redirect you're not penalized. tell them update cache. additionally you'll want add sitemap.xml file contains proper urls on server in order of priority. assuming have new path stored in db, you'll...

uibutton - Example of a Sencha Extjs custom button UI -

i'm trying create custom button ui using version 4.1.3 of sencha's extjs sdk , keep getting errors when trying compile sass file compass. i've tried troubleshooting myself, searching around answers online, , posting sencha forum , can't seem find answer. does have or know of example file working custom button ui implemented? i'm sure there's 1 small setting or configuration have wrong, comparing have sample file incredibly helpful. thanks.

java - Is there a procedure to creating JUnit test cases? -

i'm new java development , today first time paired program create test case. kind enough talk out-loud thinking explain why things being done (e.g. creating constructor arguments instead of having default constructor, etc). while retain 40% of saw/heard today wondering if there set of steps/guidelines follow, end result test case starting point. know usual responses of every shop has own standard, there personal preferences , tools, depends if test class own versus legacy, etc. either way, figured , ask members. here snippet of notes took show had in mind, in terms of responses. using mockito, cannot mock objects being created methods, therefore try , constructor take objects. allow mock them , pass them method easier testing. mockito not handle static methods, can create wrapper class invokes static method. now, new wrapper class not use static methods , class testing use instead of static method. allows use when/thenreturn without having handle static method d...

vb.net - Error when closing my application in the middle of the loop -

here code loop: do while potsstatus = true dim foregroundhwnd intptr = getforegroundwindow dim mysearchwinow intptr = findwindow(nothing, searchwindow) if foregroundhwnd = mysearchwinow if rbq.checked = true keybd_event(vbkeyq, 0, 0, 0) keybd_event(vbkeyq, 0, keyeventf_keyup, 0) thread.sleep(1) elseif rbw.checked = true keybd_event(vbkeyw, 0, 0, 0) keybd_event(vbkeyw, 0, keyeventf_keyup, 0) thread.sleep(1) elseif rbe.checked = true keybd_event(vbkeye, 0, 0, 0) keybd_event(vbkeye, 0, keyeventf_keyup, 0) thread.sleep(1) elseif rbr.checked = true keybd_event(vbkeyr, 0, 0, 0) keybd_event(vbkeyr, 0, keyeventf_keyup, 0) thread.sleep(1) end if end if the problem when loop running , exit/close application encounters errors, process remains , loop never ends. thing can manually stop process in task manager. hope can me this. edit: solved. made loop false in form closing ...

java - Making a JPanel square -

if have jpanel multiple subcomponents, how make jpanel remains square despite how parent resized? have tried variations on following code, not result in subcomponents being square. public void paint(graphics g){ if(this.issquare()){ dimension d = this.getsize(); if(d.height > d.width){ this.setsize(d.width, d.width); } else { this.setsize(d.height, d.height); } super.paint(g); } here sscce. the containing parent: import javax.swing.jframe; public class testframe extends jframe{ public testframe(){ this.add(new testpanel()); } public static void main(string[] args){ testframe tf = new testframe(); tf.setsize(500, 500); tf.setvisible(true); } } what should square jpanel: import java.awt.borderlayout; import java.awt.color; import java.awt.dimension; import java.awt.graphics; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.border.line...

sql - within substring method how to use Isnull() -

in of columns have null value. can't achive other informations(my other columns) null value. use isnull . logged put isnull() in following code. my code is select top(10) 'insert jobs(budget) values('+ cast(substring(cast(r.budget varchar(50)), 0, patindex('%laks%', r.budget))*100000 + substring(cast(r.budget varchar(50)), patindex('%laks%', r.budget) + 4, patindex('%thousands%', r.budget) - patindex('%laks%', r.budget) - 4)* 1000 varchar(50))+')' requirementsdetailsfororganization r in above code, calculate salary in lakhs , thousands. wherever put isnull(), shows error. suggest me come out of issue.. now think happening you may have used patindex('%laks%', isnull(r.budget,'')) now patindex() returns zero if pattern not found. when search pattern '%laks% ' inside empty string returned isnull() , value 0 returned causes error in substring() function , index ou...

web - Getting DISQUS comment count -

i'm trying comment count comic on comics website . example, comic id 66 has 2 comments. i'd count , display on page. far when follow disqus guide below, gives me link comic comments, doesn't give me total comments. disqus says... append #disqus_thread href attribute in links. tell disqus links , return comment count. example: <a href="http://foo.com/bar.html#disqus_thread">link</a> . but how count if url string this: <a href=".?action=viewimage&site=comics&id=66">link</a> so questions are: where append #disqus_thread ? how can comments count 1 comic url , display total comments on page? while old thread looks no answer accepted add thought incase helps others. in function.php add following: function disqus_count($disqus_shortname) { wp_enqueue_script('disqus_count','http://'.$disqus_shortname.'.disqus.com/count.js'); echo '<a href="...

c# - Bind items in generic list and Serialize -

this code: list<test> list = new list<test>(); (int j = 0; j < dss.tables[0].rows.count; j++) { list.add(new test(dss.tables[0].rows[j]["pset"].tostring(), convert.toint32(dss.tables[0].rows[j]["score"].tostring()))); } stringbuilder data = new stringbuilder(); javascriptserializer json = new javascriptserializer(); json.serialize(list, data); hdlinedata.value = list.tostring(); but it's not serializing list, if not binding list correctly. please suggest me how bind list in json format. you can use [serializable()] attribute on custom class , then: javascriptserializer serializer = new javascriptserializer(); var json = serializer.serialize(myobject); to ignore specific properties in object you're serializing, place [nonserialized] attribure on them. i referred here

python - Importing modules globally -

i provide users python script import modules them , drop python interpreter imported modules available @ level. have code thought might work, not seem to: module_list = ['module_a','module_b'] # import our common modules module in module_list: try: print "importing: {0}".format(module) exec("import {0}".format(module)) except: print "fyi failed importing {0}. not available use".format(module) so when script done drop python module user can do: >>> module_a.run() you can use code.interactiveconsole() , pass locals dictionary containing local context in console run. storing modules in there can make them available interactive shell.

php - MySQL: Compare two TABLES and list rows that are new? -

we have daily data feed. need determine rows new. (it's long story, there no record numbers rows , aren't going any.) need able identify rows new since previous data feed. file comes in json , have been putting mysql table other purposes. how take yesterday's table , compare today's table, , display rows have been added since yesterday? can done in mysql, or need of php? if doing in php, i'm thinking search today's table yesterday's table, , flag (an added column) in today's table called new "n" when it's found. "y" default means row new. using mysql select new="y" , display new fields. how this? overlooking better method? thanks! if have 2 separate tables (which how sounds description, odd) , aren't comparing literally same table, can select partnumber today_table partnumber not in (select partnumber yesterday_table)

How do I use rails validates for length to check for one value or another, not a range? -

i trying write model books in rails app , want validate isbn attribute there 2 possible lengths isbn: 10 , 13. how use validates make sure given isbn either 10 or 13 numbers long? i thought using range: validates :isbn, length: { minimum: 10, maximum: 13 } but if somehow 11 or 12 numbers { should_not be_valid }. is there way this? you can use custom validator purpose: class book < activerecord::base attr_accessible :isbn validate :check_length def check_length unless isbn.size == 10 or isbn.size == 13 errors.add(:isbn, "length must 10 or 13") end end end

Is there an RSpec formatter which can play an audio file when specs pass/fail? -

i came in touch funny nyan cat formatter able play music while specs running. because our test suite growing , growing else while running, e.g. browser on internet. great though have audio signal when specs have finished (or when 1 fails), know when return work. is there formatter this? if not, i'll try create 1 myself taking @ how nyan cat formatter works. thanks josh you can simple on shell like: rake spec && 'pass!' say mac thing i'm sure similar available other platforms.

linq - Group and sum list (vb.net) -

i've got list of objects class bundledtellingen property ttimestamp string property tvalue double end class now trying group list ttimestamp , sum tvalue. searching similar questions clear best way go using linq. i've put together: dim query = bundledlist.groupby( _ function(telling) telling.ttimestamp, _ function(telling) telling.ttimestamp, _ function(ts, values) new _ {.key = ts, _ .sum = values.sum()} _ ) using writer streamwriter = new streamwriter("c:\test.txt") each result in query writer.writeline(result.key & " " & result.sum) next end using as far can tell looking @ examples @ http://msdn.microsoft.com/en-us/library/bb534493.aspx#y0 should work, though following exception: "overload resolution failed because no accessible 'sum' accepts number of arguments." you've specified 1 unnecessary parameter grou...

Visual Studio project publishes, but no content -

good day i want publish project in visual studio 2012 ultimate. publishes fine (as file system c:\projects), but, when opening folder publishes in c:\projects...there nothing. empty. why that? thanks i had same problem . try deleting current profile , add new profile project.

sublimetext2 - Regex for converting file path to package/namespace -

given following file path: /users/lawrence/myproject/some/very/interesting/code.scala i generate following using single regex replace (the root can constant): some.very.interesting this purpose of generating snippet sublime text can automatically insert correct package/namespace header scala/java classes :) sublime text uses following syntax regex replace patterns (aka 'substitutions'): {input/regex/replace/flags} hence why iterative approach cannot taken - has done in 1 pass! also, substitutions cannot nested :( if know maximum number of nested folders.you can specify in regex. for 1 3 nested folders regex: /users/lawrence/myproject/(\w+)/?(\w+)?/?(\w+)?/[^/]+$ replace: $1.$2.$3 for 1 5 nested folders regex: /users/lawrence/myproject/(\w+)/?(\w+)?/?(\w+)?/?(\w+)?/?(\w+)?/[^/]+$ replace: $1.$2.$3.$4.$5 given constraints thing can do

XML from webservice to SQL Server using SSIS -

Image
i have web service task saves xml output variable. the question variable type be? how can transfer xml variable sql server database? can't seem make data flow work, xml source ole db source? on right path? thanks <xs:element name="table"> <xs:complextype> <xs:sequence> <xs:element name="flightdate" type="xs:datetime" minoccurs="0"/> <xs:element name="flightno" type="xs:string" minoccurs="0"/> </xs:sequence> </xs:complextype> </xs:element> i need save flight date , flight no temporary table in sql. must have own column flightdate , flight no change xml source data acces mode xml data variable, then can give "user::flightinfoxml" variable.

Using msvcrt.getch() in Eclipse / PyDev -

i wanted use msvcrt.getch() in eclipse pydev read signe char found out don't work (but works in windows console). any idea ? maybe use sys.stdin.read when run in pydev? sys.stdin.read(1) read 1 line input...for use in windows console , in pydev make same selection based on os , run variants(using sys.stdin.isatty ). example next code read timelimited user input. when run in windows console if program's standard input piped in program's standard output, sys.stdin.isatty returns false , input read sys.stdin.read , not msvcrt.getch : import sys, time import platform if platform.system() == "windows": import msvcrt else: select import select def input_with_timeout_sane(prompt, timeout, default): """read input user or timeout""" print prompt, sys.stdout.flush() rlist, _, _ = select([sys.stdin], [], [], timeout) if rlist: s = sys.stdin.readline().replace('\n','') ...

ruby on rails - how to deal with timeout in ROR project -

i working project ruby on rails. there's 1 page list of items can choose multiple of them , change information @ time. when data huge , choose many items in process @ time. run few minutes long, page show error message , caused server timeout...how can let run ten minutes not timeout , return error message? there not 1 way this. firstly, can in log check long sql queries, if see long ones, can try , optimize them. you can use gems rails-footnotes see sql queries in bottom of each page in dev environment. if doing expensive tasks, try process them in background tools such resque or delayed_jobs.

r - Transform multi dimensional array into factored data frame -

i have results tapply function creates array (with module names, animal names (rows) , test days (columns)) this ,, module1 [,d1] [,d2] [,d3] [,d4] [a1,] 1 3 2 1 [a2,] 2 1 3 2 ,, module3 [,d1] [,d2] [,d3] [,d4] [a1,] 1 3 2 1 [a2,] 2 1 3 2 ,, module3 [,d1] [,d2] [,d3] [,d4] [a1,] 1 3 2 1 [a2,] 2 1 3 2 what transform data frame module name , dimension names factors in data frame such this: module1 d1 a1 1 module1 d1 a2 2 module1 .. module3 d4 a1 1 module3 d4 a2 2 etc which can use ggplot , other functions. there packaged/function let me this? here's 1 way using plyr , reshape2 : adply(a, 3, function(x) melt(cbind(names=rownames(x), as.data.frame(x)))) # x1 names variable value # 1 module1 a1 d1 1 # 2 module1 a2 d1 2 # 3 module1 a1 d2 3 # 4 module1 a2 d2 1 # 5 module1 a1 d3 2 # 6 ...

java - ListView row buttons: How do I create a custom Adapter that connects a View.OnClickListener to a button on each row of a ListView? -

i want listview contain buttons, setting button's xml property, onclick="myfunction" , placing public void myfunction(android.view.view view) method in activity causes nosuchmethodexception (the stack trace null) thrown, although onclick listener there, doesn't fire myfunction(...) , cause activity close. how create custom adapter connects view.onclicklistener button on each row of listview? my listview created follows... [activity.java content..] public void myfunction(android.view.view view) { //do stuff } [activity.xml content..] <linearlayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".frmcustomerdetails" > <listview android:id="@+id/lstcustomerdetailslist" android:layout_width="...

android - Change default camera properties -

Image
i want take picture application using intent camera = new intent(mediastore.action_image_capture); startactivityforresult(camera, take_picture); and send webserver. since webserver compresses 150x150 image of size not more 50 kb , don't need take 3264x2448 image of size ~ 2 mb because takes hell lot of time send transfer. want take minimum sized image. so, there way ask camera specific sized image? i tried using camera api , changing properties: private camera mcamera; camera.size picturesize = getsmallestpicturesize(mcamera .getparameters()); if (picturesize != null) { mcamera.getparameters().setpicturesize(picturesize.width, picturesize.height); } private camera.size getsmallestpicturesize(camera.parameters parameters) { camera.size result = null; (camera.size size : parameters.getsupportedpicturesizes()) { if (result == null) { result = size; ...

SVG is empty when manipulating with javascript -

i'm working on enyo application. want draw on svg. code far: enyo.kind({ name:"draw", kind:enyo.control, tag:"svg", attributes:{ xmlns:"http://www.w3.org/2000/svg", version:"1.1" }, classes:"drawsvg", published:{ drawsize:5, selectedcolor:"333333", paths:0 }, handlers:{ ondown:"ondownhandler", onmove:"onmovehandler" }, create:function(){ this.inherited(arguments); this.render(); }, rendered:function(){ this.inherited(arguments); }, ondownhandler:function(sender,target){ this.ipaths++; var p = this.getpositioninsvg(target); var path = document.createelementns("http://www.w3.org/2000/svg", "path"); path.setattribute('class', 'drawpath'+ this.ipaths); path.setattribute('fill', ...

asp.net - Reusing same connection in signalR while navigating through different pages -

i have mvc project, multiple pages. i have long running process, updates client on progress. however, update sent single client, instead of broadcasting all. clients.client(connectionid).sendmessage(msg); in layout.cshtml, how connect hub var serverhub = $.connection.notifier; window.hubready = $.connection.hub.start(function () { }); the problem is, when navigate page, no longer receive messages signalr, because connection id has changed. how should workaround issue, such signalr hub can still send messages single client, while client navigates page page. you want create server mapping of users connection id's. see: signalr 1.0 beta connection factory . you want let users persist past ondisconnected event , when connect different connection id can continue pumping data down them. so thought process follows: page loads, signalr connection instantiated once connection started call => trycreateuser (returns user, whether existed or creat...

ios - On dismiss iAd Screen ipad screen becomes black -

i have tab based application.i have created iad object in appdelegate class , using in 3 view controller class.it working on tab 2's first screen , tab 3's first screen.on tab 2 there table view ,on clicking row of table view navigate new view have used same code iad .on clicking iad iad screen opens in landscape mode , when closing screen becomes black , log following. [adhostwindowcontroller supportsorientation:]: message sent deallocated instance 0x100bc740 i have created object in app delegate this.. self.bannerview = [[adbannerview alloc]init]; [self.bannerview setdelegate:self]; iam adding banner in view controllers this [[[self appdelegate] bannerview] setframe:cgrectmake(0, hightofview-180, 768, 66)] all view controllers in portrait iads open in landscape mode. how solve ,this working in ios 6 ,but problem ios5 ipad.how solve thgis .plz me .any advise appreciated.thanks iad not problem looksfrom question check u when view disappears on showing i...

jquery - How to set td or cell's trigger unable? I can fire the trigger but do not turn off the trriger -

how set td or cell's trigger unable? can fire trigger not turn off trriger.i set trigger this: my.contextmenu({ trigger: '#grid td ', //leftbutton: false, rightbutton: true, menu: '#testmenu', callback: ctxcallback }); if using contextmenu plugin medialize, according doc, can try: $("#grid td").contextmenu(false); to disable trigger. disable contextmenu trigger

javascript - Clearing memory references in closures -

Image
i have question how closures work in relation garbage collection. have created javascript application seems continually adding objects don't cleaned when create new project. in code application clears out references newly created objects , make sure unbind events , dispose them. when in chrome heap profiler see: when click on references of objects can see there pointers objects in jquery proxy function. (specifically variable 'context') from can see, proxy function creates closure , closure has reference viewport when constructed. how i'm using proxies in viewport3d: //in constructor of viewport3d this.keydownproxy = jquery.proxy( this.onkeydown, ); jquery(document).on( "keydown", this.keydownproxy ); ... //in dispose method of viewport jquery(document).off( "keydown", this.keydownproxy ); this.keydownproxy = null; so can see removing events nullifying proxy closure reference exists. so why viewport3d still exist in memory after e...

validation of fields in a form in scala with lift frame work -

i working lift framework , scala. have form sign application, , want validate fields in it. have snippet access form values, , 1 validation class wrote validation functions. following code i've tried far. in snippet: if(validationclassobject.validatename(first_name)){ if(validationclassobject.validatename(last_name)){ if(validationclassobject.validateemail(email)){ if(validationclassobject.validateusername(name)){ // adding values db s.redirectto("/") } else{ s.notice("invalid user name") } } else{ s.notice("invalid mail id") } } else{ s.notice("invalid last name") } } else{ s.notice("invalid first name") } in validationclass wrote validation code looks like: //function validating mail address def validateemail(email: string): boolean = """(\w+)@([\w\.]+)""".r...

c# - MVC 4 - Centralize the create action -

i'll try clear. i'm developing web application based on mvc 4 , entity framework. through app, can create products depending on other table product types can see, in create product view, have dropdownlist contains product types : @model busimaterial.models.product @{ viewbag.title = "create"; } <h2> create</h2> @using (html.beginform()) { @html.validationsummary(true) <fieldset> <legend>product</legend> <div class="editor-label"> purchase date : </div> <div class="editor-field"> @html.textboxfor(model => model.purchasedate, new { @class = "datepicker"}) @html.validationmessagefor(model => model.purchasedate) </div> <div class="editor-label"> serial number : </div> <div class="editor-field"> @html...

Why am I getting this error with this Java code? -

this beginning of file. it's named correctly, classes defined, it's giving me error. error: '{' expected; (on first line of given code) public class classroster extends student extends belt { what's going on? you can't have "extends student extends belt". can't extend 2 classes multiple inheritance not supported (and comma separated if could, implements). what have: public class classroster extends student and student class extends belt public class student extends belt

css - Alternate Rows with exception > inherit background color -

i have table alternate row background-color: tr:nth-child(even) {background: #fff} tr:nth-child(odd) {background: #f4f4f4} the table comprised of 2 types of cells, ".main" , ".sub". i background-color alternate every other ".main", while ".sub" rows color of previous ".main". it great if solution css, open jquery if it's best way go. any ideas? <table> <tr id='1' class='main'><td></td></tr> <tr id='2' class='main'><td></td></tr> <tr id='3' class='main'><td></td></tr> <tr id='4' class='main'><td></td></tr> <tr id='5' class='main'><td></td></tr> <tr id='6' class='sub'><td></td></tr> <tr id='7' class='main'><td></td>...

c# - Drawing a GUI in XNA -

i'm working on making xna 2d platformer, , i'm wondering if it's possible draw kind of static gui on game? what mean here while game updates , players position changes etc, gui drawn on kind of static layer (overlay?), size of window game being run in. way game wouldn't have update gui's position , little bit nicer handle. any ideas? thanks time yeah, can draw them using spritebatch :) //hudtexture transparent texture size of window/screen, hud drawn onto it. spritebatch.draw(hudtexture, vector2.zero, color.white); //let's works draw score @ [100,100]. spritebatch.drawstring(hudfont, points.tostring(), new vector2(100,100), color.white); if plan on making more gui (buttons etc) might want check out answer wrote other post: xna drawstring() draws partial string also; drawing scores etc, have experienced quite bit of boxing/unboxing because of tostring. reason, have had array of strings represent score: string[] scoretext = new string[10...

javascript - Should I use fixed or dynamic time step in a networking game? -

i developing online networking game using box2d js , vert.x server->client framework. i have searched pros , cons of each , believe dynamic time step better since not assume each client has same processing power, however, there (many) people think fixed time step better. please enlighten me. you can throw determinism out window if timesteps not synchronized. when are, determinism difficult. spending less computation on simulation have real costs may not apparent. each different setting (and in case of dynamic timesteps/iterations, each different individual execution) resulting behavior on same input can different. can have user run on slow hardware can potentially cheat through levels. determinism perhaps marginally less important outside of multiplayer engine context, not having deterministic system make more difficult reason pretty (gameplay mechanics, game difficulty, exploits) can impact every kind of game can think of. imagine puzzle game wasn't determi...

Glowing WPF Buttons -

after clicking wpf buttons in our app glow blue, original color, blue, etc. appears default behavior on windows vista/7. not happen on xp. advice? you need override default button template -- http://mark-dot-net.blogspot.com/2007/07/creating-custom-wpf-button-template-in.html should ya started. specifically section 3: <controltemplate.triggers> <trigger property="ismouseover" value="true"> <setter targetname="border" property="borderbrush" value="#ff4788c8" /> <setter property="foreground" value="#ff4788c8" /> </trigger> <trigger property="ispressed" value="true"> <setter property="background" > <setter.value> <lineargradientbrush startpoint="0,0" endpoint="0,1" > <gradientstop color="#ffffd...