Posts

Showing posts from March, 2015

smtp - Understanding MX records with C# -

i missing piece of understanding how mail transfer works in order implement it. i want implement smtp server, receives email message client, looks recipient mx record of domain in order deliver there. what don't understand happens next, connect domain ip? port? the example looking @ gmail, mx server gmail-smtp-in.l.google.com, program need connect domain on port? thank you read: http://www.ietf.org/rfc/rfc5321.txt short answer: when delivering email. mx records of domain name in question. if mxs exist for domain attempt connect them via port 25 , deliver mail per rfc above. connect them in order of preference listed. lower numbers have higher preference. if equi-cost mx's present, free pick 1 @ random. if 1 doesn't answer try same weight mx before going higher in chain. if no mxs answer queue mail , try again.. if no mxs exist try deliver 'a' record on know port of 25 (smtp). but really, read rfcs , become familiar them, out lot

jquery - Found elements in a string -

say have script $.get('test.html', function(data){ //data }); how can find div specific class inside data ?? use data context argument $(selector, context) , this: $.get('test.html', function(data){ $("div.someclass", data) });

javascript - Button onclick only checkes the first appended checkbox -

with script below append 3 elements when append button clicked. a checkbox input text field delete button for now, when delete button clicked checkbox checked, when append (let's call group) 3 items, script doesn't work. can explain how can link elements in sort of way. every time click append button elements linked elements created @ same time same on click. thank in advance <html> <head> <script language="javascript"> function append() { var cb = document.createelement("input"); cb.type = "checkbox"; cb.id = "id" cb.checked = false; var textfield = document.createelement("input"); var delbtn = document.createelement("input"); delbtn.type = "button"; delbtn.value = "remove"; delbtn.onclick= function(){remove()} document.getelementbyid('append').appendchild(cb); document.getelementby

Need help getting started on Facebook C# API -

i'm trying create new facebook iframe application using asp.net , c#, , can't find getting started guides. i'm looking extremely basic intro - i.e. .dll files put, code use authorize , userid, etc. once structure started i'll able figure out...but can't make basic connection facebook! a simple sample app extremely helpful. thank much! many people have tried use facebooktoolkit , failed miserably. don't take word it, through forum going months. adoption microsoft didn't add value project imo going die @ point own weight. the sdk provided facebook hackathon project announced 6 months ago , doesn't seem have been updated since. it's tough imagine company of facebook's size , stature being incompetent, let's face it, have political bent microsoft-adverse, it's no wonder haven't put effort helping side of world of development. i helped bit on fbgraph.net project which, while noble effort, has been retired. search in

Eclipse PDT isn't highlighting PHP syntax in .html files? -

so, i'm doing code maintenance , our php codes embedded in html files. eclipse isn't highlighting of php codes in html file. does have ideas how this? i've tried looking in preferences , google ninja skills fail me. thank in advance. window > preferences > general > content types under "text" find "php content type" add "*.html" close file , reopen again. restart eclipse won't work, since whatever .html file have been open when restart appear again. had close .html file tab viewing , reopen it. thanks again!

.net - c# pointers vs IntPtr -

this 2nd part of 1st question using c# pointers so pointers in c# 'unsafe' , not managed garbage collector while intptr managed object. why use pointers then? , when possible use both approaches interchangeably? the cli distinguishes between managed , unmanaged pointers. managed pointer typed, type of pointed-to value known runtime , type-safe assignments allowed. unmanaged pointers directly usable in language supports them, c++/cli best example. the equivalent of unmanaged pointer in c# language intptr . can freely convert pointer , forth cast. no pointer type associated though name sounds "pointer int", equivalent of void* in c/c++. using such pointer requires pinvoke, marshal class or cast managed pointer type. some code play with: using system; using system.runtime.interopservices; unsafe class program { static void main(string[] args) { int variable = 42; int* p = &variable; console.writeline(*p);

entity framework - update foreign key after primary key creation -

i have following scenario (simplified) using linq ef 3.5 var datarepos = new entities(); var query = product in datarepos.products group product product.categoryid agg select new { category = agg.key, sumtotal = agg.sum(x => x.unitprice) }; foreach (var row in query) { var newpos = new summary() { category = row.category, total = row.sumtotal }; } the summary class represents database table , each time row added table’s primary key increments. need update relevant rows in products table newly generated id summary table i.e. update foreign key (which has default value of zero). the number of rows involved significant. best approach here in terms of efficiency?

linq to sql - Design for multi-tenant app using SOA, UoW, Repository, DataContext & multiple databases -

let me start apologizing length of post wanted provide detail possible increase chance of answer. in advance. i’m adding new features existing application integrates data several databases. in short, allows clients and/or accountants access , update financial information locations. application has 3 tiers web client (i’m looking replace silverlight client soon), service layer running on app server , database tier. when took ownership, application, despite having 3-tiers, simplistic. using ado.net , web service pass-through dynamic (string) sql queries on 1 of databases. first task “clean-up” existing code. there nothing object-oriented app , flat. i’ve begun refactoring application leverage linq-to-sql, implemented repository pattern make business logic testable (not mention more maintainable evolve data access technology ado.net l2s and, hopefully, on entity framework) , reworked code use features of .net. for part, web app piece of cake every page simple query on table o

.net - Implementing a custom Binding -

i have myusercontrol contains label label , , bo public person person {get;set;} . i want person's name bind label this: ( "name: {0}", person.name ), in case if person != null and ( "name: {0}", "(none)" ), in case if person == null more that, if person name changed, label automatically update it. is there possibility such binding ? "dirty" variant: private void label_layoutupdated(object sender, eventargs e) { label.content = string.format("name: {0}", _person == null ? "(none)" : _person.name); } how about: <stackpanel orientation="horizontal"> <textblock text="name: "/> <textblock text="{binding person.name, fallbackvalue='(none)'}"/> </stackpanel> this doesn't use label, accomplishes goal. if needs label, can this: <label co

c++ - Vector of Vector Initialization -

i having tough time getting head wrapped around how initialize vector of vectors. typedef vector< vector < vector < vector< float > > > > datacontainer; i want conform to level_1 (2 elements/vectors) level_2 (7 elements/vectors) level_3 (480 elements/vectors) level_4 (31 elements of float) addressing elements isn't issue. should simple like dc[0][1][2][3]; the problem need fill data coming in out of order file such successive items need placed like dc[0][3][230][22]; dc[1][3][110][6]; //...etc so need initialize v of v beforehand. am psyching myself out or simple as for 0..1 0..6 0..479 0..30 dc[i][j][k][l] = 0.0; it doesn't seem should work. somehow top level vectors must initialized first. any appreciated. sure must simpler imagining. please do not use nested vectors if size of storage known ahead of time , i.e. there specific reason why e.g. first index

rtp and rtsp player integration to browser -

i trying build web service stream music on web browser. got server running open web page says "hello world". problem not understand need put in web page start rtp session. understand need sort of player on web page i'm opening not understand how make player or how show on web page. can me? a little late party here, ... you need player of kind. currently, browsers not support playing live rtp stream. i've done work in area , has required transcode video flv viewable in many of free flash players (i.e. jwplayer, flowplayer, etc.). you write custom browser plugin read rtp stream , display in browser sizeable undertaking.

What is the difference between a StackPanel and DockPanel in WPF? -

Image
what can dockpanel stackpanel cannot? if has image of can achieved stackpanel , not dockpanel , great. stack panel : stackpanel , name implies, arranges content either horizontally or vertically. vertical default, can changed using orientation property. content automatically stretched based on orientation (see screenshot below), , can controlled changing horizontalalignment or verticalalignment properties. dock panel : dockpanel used anchor elements edges of container, , choice set overall structure of application ui. elements docked using dockpanel.dock attached property. order elements docked determines layout.

data structures - Way to implement "Get all strings with Levenshtein distance less than X" -

i'm wondering whether there's efficient data structure perform "retrieve strings levenshtein distance less x". few things i'm interested in: explanation of algorithm. is there existing implementation in existing database / programming langauge? paper / article can refer to? this nearest neighborer search in metric space levenshtein distance metric (or distance) function a vp-tree 1 of ways of solving problem this python vp-tree implementation working demo shows how vp-tree works run on word list provides interactive shell type word , returns words in list no more x distance word typed

mysql - alternative / efficient / optimized query -

i want alternative / efficient / optimized query following query: table: create table `bartco_web_vms_studio`.`table_name` ( `index` int( 10 ) not null auto_increment , `id1` int( 10 ) not null default '0', `id2` varchar( 10 ) not null, `f3` tinyint( 4 ) not null default '0', primary key ( `index` ) ) engine = myisam ; composite index: create index id1_id2 on tablename (id1, id2); number of rows = 7891 update query: update table_name set f3=1 id1=1 , id2='a' or id1=2 , id2='b' or id1=3 , id2='c' basically have update field's value based on 2 fields (id1, id2) values. these 2 fields can in more 1 pair. output explain select f3 table_name ... : id -> 1, select type -> simple, table -> table_name, type -> range, possible_keys -> id1_id2, key -> id1_id2, key_len -> 261, ref -> null, rows -> 2, -> using thanks lot help regards composite index

java - problem with incremental update in lucene -

i creating program can index many text files in different folder. that's mean every folder has text files indexed , index stored in folder. folder acts universal index of files in computer. , using lucene achieve because lucene supported incremental update. source code use indexing. public class simplefileindexer { public static void main(string[] args) throws exception { int i=0; while(i<2) { file indexdir = new file("c:/users/raden/documents/myindex"); file datadir = new file("c:/users/raden/documents/indexthis"); string suffix = "txt"; simplefileindexer indexer = new simplefileindexer(); int numindex = indexer.index(indexdir, datadir, suffix); system.out.println("total files indexed " + numindex); i++; thread.sleep(1000); } } private int index(file indexdir, file datadir, string suffix) throws exception { ramdirectory ramdir = new ramdirectory(); // 1 @suppres

testing - How do I specify POST parameters in wfetch -

i testing api, how specify parameters passed post request in microsoft's wfetch.exe ? you need set "advanced request" dropdown "add headers & body" then in textbox put: content-type: application/x-www-form-urlencoded\r\n \r\n field1=value&field2=value2\r\n if have large amount of form data post can use "from file" option

how to create a RTSP streaming server -

so trying create rtsp server streams music. not understand how server plays music , different requests ever playing @ time. so, organize questions: 1) how server play music file? 2) how request server whats playing? 3) response music playing in client requested music? first: read this (rtsp), , then read this (sdp), , read this (rtp). can ask more sensible questions. 1) doesn't, server streams little parts of audio data client, telling when each part played. 2) there no such request. if want, can have url live streaming, , in rtsp describe request, tell client on. 3) read first (rtsp) document, there! answer question this: rtsp/1.0 200 ok cseq: 3 session: 123456 range: npt=now- rtp-info: url=trackid=1;seq=987654 but music playing have lot more initiate streaming session.

tar - shell script command doubt -

i have command in shell script configs="`tar -tzf ${configs_archive}`" configs_archive tar.gz file. if command executed value of configs? thanks, linuxpenseur ` quote executing command. unless put ` quote, shell treat command regular string. if want execute command , save variable do, must put ` quote

Android Wrap TextView to width of ImageButton -

i have linearlayout contains imagebutton, , underneath that, textview label. have textview centered, , have wrapped width of imagebutton underneath. edit: should put code i'm using. here's linearlayout button , textview <linearlayout android:id="@+id/contestlayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <imagebutton android:id="@+id/contestbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/contestsbtnimg" android:layout_weight="1"> </imagebutton> <textview android:id="@+id/contestlabel" style="@style/mainmenustyle" android:text="@string/contests">

shell - Destination directory while compressing using tar -

i have directory "dir" contains many directories "a", "b" , "c" i want tar dir without including "c" in dir.tar.gz not contain directory "c". what shell command this? thanks, linuxpenseur depending on command line, this: tar -cf archive.tar --exclude c dir also, nitpick question, tar not perform compression.

javascript - alphanumeric sorting in java script -

i having field has data in way . a_0121-x-1 a_0121-x-10 a_0121-x-11 a_0121-x-2 a_0121-x-3 a_0121-z-1 a_0121-z-11 a_0121-z-12 a_0121-z-13 a_0121-z-2 a_0121-z-3 s0 how sort numerically this a_0121-x-1 a_0121-x-2 a_0121-x-3 a_0121-x-10 a_0121-x-11 a_0121-z-1 a_0121-z-2 a_0121-z-3 a_0121-z-11 a_0121-z-12 a_0121-z-13 thanks in advance i think mean natural sort in js look on brian huisman solution https://web.archive.org/web/20130929122019/http://my.opera.com/greywyvern/blog/show.dml/1671288

sleep - Python: Perform ations repeatedly over a time interval, as long as a condition is true -

so i'm trying (access file on website, read contents , perform actions until content says exit. precondition being has wait x seconds before accessing website again; recheck contents): perform = true while(perform): data = urllib.urlopen('someurl') data = data.read() if(data == '0'): dosomething() elif(data == '1'): #1 signifies exit loop perform = false else: time.sleep(10) however never seems work. 'someurl' has value. google says it's sleep function. please help! this: import time while true: print "fetching" time.sleep(10) is minimal test case , works can't problem time.sleep function

postgresql - How to select random trial with sql? (Bernoulli Trial) -

for each parent exists select 1 child row randomly. table structure looks this: parent id child parent_id id rank where there 1..n child records each parent , rank unique per parent going 1 n. the output should like: parent child rank --------+-------+------- 1 34 7 2 56 8 ... with each parent producing 1 child row. (this serve basis bernoulli trials.) (postgresql has random() function gives number between 0 , 1.) not familiar @ postgresql, perhaps this? select distinct on (parent_id) parent_id "parent", id "child", rank child c order parent_id, random()

php - Simulate saving propel object (Don't write into tables) -

i have functionality in project in have show preview user how page after submitting form. preview, setting related propel object form values , in end not saving values preview. this works, previous values of related table deleted , after preview related tables not restored previous state not saving object. please, bug? don't want save of values table, use object show preview. is there proper way of doing this. edit : rephrase question. if don't save propel object, changes affected in tables?. right now, if don't save, main table unaffected relations affected , not restored old values if object not saved. eg: have 2 tables, job , jobsectors foreign key relationship. $job->addjobsector('somesector'); i don't save object, previous value in jobsector deleted , there no new value. thanks i resolved it. whenever functions starting inittablename() used, seems previous values getting deleted. don't call these functions preview. , not savi

objective c - How to play Sound File In Silent Mode iPhone sdk? -

how play sound file in silent mode iphone sdk ? i m trying play sound file in silent mode result 0 i have tried code systemsoundid soundid; audioservicescreatesystemsoundid((cfurlref)[nsurl fileurlwithpath:fullpath],&soundid); audioservicesplaysystemsound (soundid); when import in header file #import <audiotoolbox/audiotoolbox.h> create error error: expected identifier before '\x786f7073' asnwer possible..... thanks in advance regard stupidiphonedeveloper you have define audio session category not silenced mute switch. check out audio session page on apple dev site : http://developer.apple.com/library/ios/#documentation/audio/conceptual/audiosessionprogrammingguide/audiosessioncategories/audiosessioncategories.html%23//apple_ref/doc/uid/tp40007875-ch4-sw1 maybe avaudiosessioncategoryplayandrecord 1 need.

java - how to read the xml node value dynamically? -

i've static xml this. kind of configuration. <scocodes> <element scocode="c1" foo="fooc1" bar="barc1" /> <element scocode="c2" foo="fooc2" bar="barc2" /> <!-- these 100 nodes present --> </scocodes> for given scocode, want know foo value , bar value? since static, need parse once in static block , convert kind of dto , put dtos in collection(list, set etc) elements(dtos) can searched? try this string xmlsource = "your xml"; string xpathexpression = "//element[@scocode='c1']/@foo | //element[@scocode='c1']/@bar"; xpath xpath = xpathfactory.newinstance().newxpath(); stringreader reportconfigurationxml = new stringreader(xmlsource); inputsource inputsource = new inputsource(reportconfigurationxml); string result = (string) xpath.evaluate(xpathexpression, inputsource, xpathconstants.string); cheers, borut

Tree to output Unicode text from CMD -

Image
i'd searched high , low in regards command line output in unicode: what encoding/code page cmd.exe using? how display japanese kanji inside cmd window under windows? etc can't work. i remember seeing page in stackoverflow saying tree limitation , not cmd's limitation. thing is, forgot did day. managed generate output cmd tree command: folder path listing volume serial number 0007ee40 283d:e05a c:. ¦§¦¡¦¡¦¡4minute (Æ÷¹Ì´Ö) - hit heart ¦§¦¡¦¡¦¡f(x) (¿¡ÇÁ¿¢½º) - nu abo (ep) ¦§¦¡¦¡¦¡hwanhee (ȯÈñ) - h soul ¦§¦¡¦¡¦¡kara (Ä«¶ó) lupin (·çÆÎ) ep (3rd mini album) and when open output.txt in ms word, allowed me convert korean , works perfectly! now when try think did, , tried out, get: folder path listing volume serial number 7c910460 283d:e05a c:. ÃÄÄÄ4minute (???) - hit heart ÃÄÄÄf(x) (????) - nu abo (ep) ÃÄÄÄhwanhee (??) - h soul ÃÄÄÄkara (??) lupin (??) ep (3rd mini album) and here's ms word shows, chooses japanese automatically if change korean doe

select - Assign shortcuts to arbitrary windows in order to quickly focus it -

while programming enjoy benefits of multi-monitor setup using windows 7. desktop inhabited 2 editor windows, several console windows , browser (so can ask questions on stackoverflow). can somehow assign shortcuts windows in order focus them? e.g. "alt+1", "alt+2" select editors , "alt+3" select console? edit: forgot each monitor has it's own taskbar. in windows 7, use windows key + 1, 2, 3 respective windows in task bar

How to password protect an application in Android -

i want user enter password everytime tries enter application. is, user must enter password everytime app comes foreground background, pressing launcher icon or long-pressing home key i sort-of achieved first part because launcher intent fired , callback in onrestart of activity. but long-pressing home key , launching not provide callback onrestart. also if user launches app pressing notification from, notification bar. how distinguish whether app in background or fore-ground before user clicked notification in onresume call, set logincounter += 1, in onpause -= 1. if logincounter == 0 => show login dialog. in notification bar set intent call activity , correct? add parameter "iscalledbynotificationbar" boolean in there.

iphone - Rotation Animation on UIImageView -

Image
i have sunrays image. put on background , make rotate continuosly in slow motion.. the image this.. i've tried rotating cabasicanimation, rotates whole frame.. want sunrays revolve @ background not whole frame.. is there way it??? update: here m doing...please point out mistakes... :( i didn't got wat u've explained.. :( here m doing... - (void)viewdidload { sunrayscontainer = [[uiview alloc] initwithframe:cgrectmake(0, 0, 1024, 768)]; sunrayscontainer.clipstobounds = yes; [self.view addsubview:sunrayscontainer]; sunrays = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 1024, 768)]; [sunrays setimage:[uiimage imagenamed:@"sunlight-background copy2.jpg"]]; [sunrayscontainer addsubview:sunrays]; backgroundbuilding = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 1024, 768)]; [backgroundbuilding setimage:[uiimage imagenamed:@"hira-background_fade.png"]]; [sunrayscontainer addsubview:backgroundbuilding]; [uiview beginanimat

ruby on rails 3 - Using whole space of pdf file -

i using prawn create pdf file leaves spaces/margins around page. can't use whole space of pdf file not leaving margins around? thanks !!! are referring page bounds ? the general space consumed on page can shown example code: require 'prawn/core' require 'prawn/layout' prawn::document.generate('padded_box.pdf') stroke_bounds text "margin box" padded_box(25) stroke_bounds text "bounding box padded 25 on sides margins" padded_box(50) stroke_bounds text "bounding box padded 50 on sides parent bounds" end end end this draw bounds of page showing margin. there gap, margins typically defined printing area

Is there any library popular in Python to monitor Linux/Unix system? -

in erlang, thare os_mon module responsible monitoring system, haven't found library python,is there any? thank much! two ways of doing this: use subprocess call process can information you. use pymeter . want easily.

javascript - Jquery- backslash character -

i having problem trying replace backslash character string: var g = myreadstring; g = g.replace("\", "\\\\"); it giving error of unrecognized character. how simple \ replaced 4 \\\\ ? i appreciate help, thanks. pandy the \‍ begin of escape sequence. if mean write \‍ literally, need write \\ escape sequence , interpreted single \‍ . if want replace 1 \‍ 4 \\\\ , need write this: g.replace("\\", "\\\\\\\\") but replace first occurrence of single \‍ . global replace need use regular expression global match modifier: g.replace(/\\/g, "\\\\\\\\")

Removing control characters from a string in python -

i have following code def removecontrolcharacters(line): = 0 c in line: if (c < chr(32)): line = line[:i - 1] + line[i+1:] += 1 return line this not work if there more 1 character deleted. you use str.translate appropriate map, example this: >>> mpa = dict.fromkeys(range(32)) >>> 'abc\02de'.translate(mpa) 'abcde'

iphone - UIView with round corner and white border -

due uiprogresshud need access private api, hope construct uiview round corner , white border. know make corner round is: view.layer.cornerradius = 5; but how make uiview has round corner , white border @ same time? welcome comment thanks interdev using same layer object: view.layer.borderwidth = 1; view.layer.bordercolor = [[uicolor whitecolor] cgcolor];

symfony1 - Disable CSS stylesheet for a specific action in Symfony -

is there way of disabling stylesheet in view.yml specific action in symfony? for example i've got in view.yml: default: stylesheets: [default.css] i want able like: displaysuccess: stylesheet: [!default.css] to disable default.css in displaysuccess only is possible or have explicitly modules/actions should have default.css? you can remove or add stylesheets modules view.yml doing following: displaysuccess: stylesheet: [-default] would remove default.css display action. putting displaysuccess: stylesheet: [-*] would remove stylesheets.

regex - Regular expression for at least 10 characters -

i need regular expression checks string @ least 10 characters long. not matter character are. thanks you can use: .{10,} since . not match newline default you'll have use suitable modifier( if supported regex engine) make . match newline. example in perl can use s modifier. alternatively can use [\s\s] or [\d\d] or [\w\w] in place of .

regex - PHP preg_match result -

this php function working fine: if (preg_match ("/<(\s+@\s+\w)>.*\n?.*55[0-9]/i",$body,$match)) { echo "found!"; } in this message created automatically mail delivery software. message sent not delivered 1 or more of recipients. permanent error. following address(es) failed: xxx@hotmail.com smtp error remote mail server after rcpt to:<xxx@hotmail.com>: host mx3.hotmail.com [65.54.188.72]: 550 requested action not taken: mailbox unavailable but if use same php function in case: a message sent not delivered 1 or more of recipients. permanent error. following address(es) failed: xxx@yahoo.com smtp error remote mail server after end of data: host d.mx.mail.yahoo.com [209.191.88.254]: 554 delivery error: dd user doesn't have yahoo.com account (xxxd@yahoo.com) [0] - mta1010.mail.mud.yahoo.com the preg_match function not give results. doing wrong? you looking email addressing enclosed in < , > . your first input has s

c# - Is it a bug that Delegate.CreateDelegate cannot bind to struct member overrides? -

after following answer on discovered have use ref parameter call instance method on structs. how can create open delegate struct's instance method? i cannot seem bind method overrides explicit interface implementations (to avoid boxing penalty associated, (which overrides far il concerned)), here bug report saying in future version of .net, can bind interface members found on struct: https://connect.microsoft.com/visualstudio/feedback/details/574959/cannot-create-open-instance-delegate-for-value-types-methods-which-implement-an-interface?wa=wsignin1.0#details but trying bind members equals , gethashcode ,or tostring leads errors e.g. public struct { public override int gethashcode(){/*implementation goes here*/} } delegate tret funcbyref<tstruct,tret>(ref tstruct) tstruct:struct ... delegate.createdelegate(typeof(funcbyref<a,int>),typeof(a).getmethod("gethashcode")); will fail exception "error binding target method".

Generic List and static variable behaviour in c# -

i have simple application in c#. when ran code not getting expected result?.i getting 2,2,1 expecting 1,2,3 using system; using system.collections.generic; using system.linq; using system.text; namespace consoleapplication12 { class program { static void main(string[] args) { mylist<int> list1 = new mylist<int>(); mylist<int> list2 = new mylist<int>(); mylist<double> list3 = new mylist<double>(); console.writeline(list1.getcount()); console.writeline(list2.getcount()); console.writeline(list3.getcount()); } } public class mylist<t> { static int _count; public mylist() { _count++; } public int getcount() { return _count; } } } the result expect 2 2 1 this msdn blog post tells a static variable in generic class declaration s

php - Updating Picasa Video Thumbnails Using Zend GData Picasa API -

i want update thumbnail of video in picasa web albums using api. i've got photos php sample code photos data api running. the documentation says can " provide own video thumbnail " updating photo. i've tried following function nothing happens. please help! /** * updates photo (for changing video thumbs * * @param zend_http_client $client authenticated client * @param string $user user's account name * @param integer $albumid album's id * @param integer $photoid photo's id * @param array $photo uploaded photo * @return void */ function updatephoto($client, $user, $albumid, $photoid, $photo) { $photos = new zend_gdata_photos($client); $photoquery = new zend_gdata_photos_photoquery; $photoquery->setuser($user); $photoquery->setalbumid($albumid); $photoquery->setphotoid($photoid); $photoquery->settype('entry'); $en

XSD.EXE to generate F# Classes off of XSD -

i trying use tool xsd.exe generate class files xsd. whether there gained resulting files question, see generated. found reference , notes: which, luke on over f# visual studio team, means can this: xsd.exe fpml-asset-4-z.xsd /classes /l:”microsoft.fsharp.compiler.codedom.fsharpcodeprovider, fsharp.compiler.codedom, version=1.9.9.9, culture=neutral, publickeytoken=a19089b1c74d0809″ which splendid. don't have same version of code dom - looking @ gac changed line to: xsd.exe rixml-datatypes-2_3_1.xsd /classes /l:"microsoft.fsharp.compiler.codedom.fsharpcodeprovider, fsharp.compiler.codedom, version=2.0.0,0, culture=neutral, publickeytoken=a19089b1c74d0809" which yields: c:\users\desktop\csharpsamples\researchuploader\fc-rixmllib>xsd.exe rixml-datatypes-2_3_1.xsd /classes /l:"microsoft.fsharp.compiler.codedom.fsharpcodepr ovider, fsharp.compiler.codedom, version=2.0.0,0, culture=neutral, publickeytoken=a19089b1c74d0809" mi

c# - Get user location by IP address -

i have asp.net website written in c#. on site need automatically show start page based on user's location. can name of user's city based on ip address of user ? you need ip-address-based reverse geocoding api... the 1 ipdata.co . i'm sure there plenty of options available. you may want allow user override this, however. example, on corporate vpn makes ip address look it's in different country.

Calling a batch file with arguments having quotes -

i have batch file test.bat , takes 2 arguments commandline. arg1 - "c:\work area\" arg2 - "hello politics="hero jack"" i have test.bat calling as test.bat "c:\work area\" "hello politics="hero jack"" i want second argument taken bat file hello politics="hero jack" . dont know how call test.bat argument such happens so.. second argument takes "hello politics="hero , discards jack" . can let me know calling wrongly.. in opinion, not possible 1 parameter arg2 - "hello politics="hero jack"" it's because paramter tokenizer not interested in carets. seems, tokenizer count quotes. the parser detects carets , can escape special characters & > or < tokenizer split line %1,%2 parameters use rule. delimiter , ; = starts new parameter, can suppressed, if there unequal count of quotes before test.bat """this 1 param" test.bat &qu

c++ - Looking for testing matrices/systems for iterative linear solver -

i working on c++-based library large, sparse linear algebra problems (yes, know many such libraries exist, i'm rolling own learn iterative solvers, sparse storage containers, etc..). i point using solvers within other programming projects of mine, , test solvers against problems not own. primarily, looking test against symmetric sparse systems positive definite. have found several sources such system matrices such as: matrix market uf sparse matrix collection that being said, have not yet found sources of test matrices include entire system- system matrix , rhs. great have in order check results. tips on can find such full systems, or alternatively, might generate "good" rhs system matrices can online? filling matrix random values, or ones, suspect not best way. i suggest using right-hand-side vector obtained predefined 'goal' solution x: b = a*x then have goal solution, x, , resulting solution, x, solver. means can compare error (diff

python - How to retrieve onclick text? -

in webpage have these elements: <a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c850745e0500d612172" class="pagelink" >page 1</a> <a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c850745e05676787895" class="pagelink" >page 2</a> <a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c85786787666456fgg3" class="pagelink" >page 3</a> <a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c850734234324756767" class="pagelink" >page 4</a> ... . and need retrieve text in window.open function of tags of class "pagelink": /link.php?webpage=45980a6f91ac0c850745e0500d612172 /link.php?webpage=45980a6f91ac0c850745e05676787895 /link.php?webpage=45980a6f91ac0c85786787666456fgg3 /link.php?webpage=45980a6f91ac0c850734234324756767 how can python

ruby on rails - Locale not working when called from a rake task -

i have rails app (2.3.8) send emails using actionmailer controllers, no problems. however, i´ve created rake task called cronjob (in heroku). when emails sent, no locale transformations in dates made. i´ve googled find kind of solution, couldn´t. anyone can me? thanks. here code: cron.rake: desc 'this task called heroku cron add-on' task :cron => :environment puts 'sending diary...' hollydays = [6,0] #weekend unless hollydays.member?(time.zone.now.wday) #if not weekend user.all.each |user| user.deliver_task_diary end end puts 'done.' end user model method: def deliver_task_diary taskmailer.deliver_task_diary(self) end the method in taskmailer model: def task_diary(user) next_five_tasks = user.next_five_tasks last_five_tasks = user.last_five_tasks recipients "#{user.name} <#{user.email}>" "my site <no_reply@mysite.com>" subject "your daily tasks.&qu

modernizr - Can you detect if Cleartype is enabled on PC via javascript? -

some @font-face fonts don't play nice non-cleartype settings (gets choppy on edges) is there way detect via javascript can modernizr-style class addition body if cleartype off can use in css in ie 6+ can check screen.fontsmoothingenabled property. otherwise need use html 5 canvas check this. details here .

PHP nesting quotes -

the following fails: $result = mysql_query("select * tasks userid = '$_session['userid']'"); i tried following: $userid = $_session['userid']; $result = mysql_query("select * tasks userid = '$userid'"); and works. there way without making separate variable? thanks! or this: $result = mysql_query("select * tasks userid = '{$_session['userid']}'");

android - How to calculate distance based on phone acceleration -

i want build using android phone: http://www.youtube.com/watch?v=wot9mb5qqrs i've built app sends sensor information via socket (still looking websocket implementation android). intend use information interact web app, example able move image based on phone movement. problem tried calculate distance based on accelerometer data results bad. wonder if me correct equation, first of all, possible this? till i'm using following equations: velocity = acceleration * time; distance = velocity * time + (acceleration * time^2) / 2; then translate distance meters per second pixels based on monitor screen resolution. that's calculated javascript in browser every time receive sensor data, every ~80ms. the basics simple. in analog world use continuous math is: velocity = integrate(acceleration) distance = integrate(velocity) and in digital world easier, use discrete math integration becomes summation: velocity = sum(acceleration) distance = sum(velocity)

jax rs - Problem with JAXB marshalling an object: javax.xml.bind.JAXBException: class ... or any of its super class is known to this context -

in jax-rs project (jersey) i'm having problem getting 1 of jaxb-annotated objects marshalled json. here error message see in logs: severe: internal server error javax.ws.rs.webapplicationexception: javax.xml.bind.jaxbexception: class com.dnb.applications.webservice.mobile.view.companiesandlocations nor of super class known context. does point specific problem? resource has method this: @path("/name/{companyname}/location/{location}") @produces("application/json; charset=utf-8;") @consumes("application/json") @post public viewable findcompanybycompanynameandlocationasjson(@pathparam("companyname") string companyname, @pathparam("location") string location, criteriaview criteria) { criteria = criteria != null ? criteria : new criteriaview(); criteria.getkeywords().setcompanyname(companyname); return getcompanylistshandler().listsbycompanynameandlocation(criteria, location); } viewable empty int

android - How to define Intent for call other applications? -

i got simple widget that's show label text. i'm trying give chance send text via sms, mail, tweet or set state message in gtalk. how should build intents objects? to give user choice of apps 'share' twitter, email, etc use this public static void launchnewshareintent(context c, string subject, string text, string dialogtitle){ intent shareintent = new intent(intent.action_send); shareintent.putextra(intent.extra_subject, subject); shareintent.putextra(intent.extra_text, text); shareintent.settype("text/plain"); shareintent.setflags(intent.flag_activity_new_task); c.startactivity(intent.createchooser(shareintent, dialogtitle)); }

c# - Selecting an item in a GridView and adding to the List -

i have written piece of code below productid gridview when user clicks on select link. convert.toint32(gridview1.selecteddatakey.values["productid"]))) however, if user clicks on more 1 click newer value replaces previous. there way keep adding cart list when user clicks on new item? hope makes sense thanks edit: here's code shopping page: public partial class _default : system.web.ui.page { list<basketclass> cart = new list<basketclass>(); protected void gridview1_selectedindexchanged1(object sender, eventargs e) { cart.add(new basketclass(convert.toint32(gridview1.selecteddatakey.values["bookid"]))); session.add("cartsess", cart); response.redirect("basket.aspx"); } } i dont know if location of creating list important? wasn't sure if placed in click event if keep creating new instance? then basket page have: protected void page_init(object sender, eventargs e

How do you do this (jQuery code) in MooTools? -

jquery code: $.get('/', function(d) { alert($(d).find('a').length); }); specifically running selector on returned content of xmlhttprequest... mootools code: var opt = { url : '/', oncomplete : function(d) { alert(d); } }; new request(opt).send(); what do d inside of oncomplete? you need use request.html though (so returns html tree selector can crawl through) new request.html({ url: '/', method: 'get', oncomplete: function() { // normalise collection can apply methods it. console.log($$(this.response.tree).getelement("a.foo")); // or getelements() } }).send(); http://www.jsfiddle.net/dimitar/nf2jz/477/ oncomplete: function(responsetree, responseelements, responsehtml, responsejavascript) first named arg response tree (if keeping this bound else) in case, can do: (within oncomplete) console.log(this.response) , inspect arrives. if no element collection (normal request)

c# - How do you maintain multiple versions of Databases? -

we have many environments trunk (dev integration) -> devel (team testing) -> qa (regression testing) -> live (customer use) each has own database works code in environment. part of contents of database metadata, , part data. example if building report, columns can choose build report metadata, reports user has built data. metadata flows promotion chain (get introduced in trunk, , goes devel->qa->live), along code gets tested. data not promoted. data in environment must not erased or corrupted , continue work after environment has been promoted to. what strategies exist out there manage , equally important, automate such setup? we using .net/c#/sql server think problem generic , has dealt across board mature application has large number of developers working on it, , cares data users generate on it. another product may wish @ red gate's sql source control . we're still in midst of evaluating it, tries handle @ least of requirements. rest of

osx - Play live stream -

is there gui or better yet via terminal mac (unix) can play rtmp live stream? able enter rtmp address , stream name? have tried vlc no luck. i'm on snow leopard. i want have window pop open , stream available view...like when play file via command line mplayer. why not create embed code in html page , point stream @ that? download jw flash player demo , change rtmp stream.

memcached - Expire option doesn't work in Rails.cache -

i use rails.cache.fetch method :expires_in option in rails 2.3.10. rails.cache.fetch "key", :expires_in => 2.seconds in development, cache never expired , rails hits cache. log: "cache hit" the default cache in rails 2 activesupport::cache::memorystore . not support expiration :expires_in option. in fact, only activesupport::cache::memcachestore has support cache expiration. in rails 3, :expires_in supported cache stores.

c# - Silverlight Browser back button to work -

in silverlight app how can determine if button pressed , not logout, doing. may have problem app grid drill down @ least if return start page, great. i think way trap javascript. , thing can way ok cancel standard messagebox. or can if want manage different pages silvelight; create silverlight navigation application (with appropritate template).

jni - java.lang.UnsatisfiedLinkError - loading multiple lib files? -

at first, error looked normal me, after trying known things, still have no luck running program. please let me explain in detail. i trying run tc(tokyocabinet) example using tc's java api on ubuntu. both tc , tc-java got built , installed in home directory. (not /usr/local/lib). i running program - $ java -djava.library.path=/home/siddharth/tools/tc-java/lib -classpath ./bin/:lib/tokyocabinet.jar hdbtest and getting following error - exception in thread "main" java.lang.unsatisfiedlinkerror: /home/siddharth/tools/tc-java/lib/libjtokyocabinet.so.1.1.0: /home/siddharth/tools/tc-java/lib/libjtokyocabinet.so.1.1.0: undefined symbol: tcversion @ java.lang.classloader$nativelibrary.load(native method) @ java.lang.classloader.loadlibrary0(classloader.java:1751) @ java.lang.classloader.loadlibrary(classloader.java:1676) @ java.lang.runtime.loadlibrary0(runtime.java:822) @ java.lang.system.loadlibrary(system.java:993) @ tokyocabinet.loader.load(loader.java:41)

php - Using Copy Directory Helper in Codeigniter to copy and move files -

i using copy directory helper addon directory helper me copy files different places on web server. it works if files copying , folder copying located within codeigniter install directory. i have codeigniter installation in subdirectory (http://domain.com/site) , able move , copy directories in root directory. directory_copy('./user_guide/', './test_copy/'); creates test_copy , copies contents of user_guide it. however doing (notice missing dot( . ) in destination directory) directory_copy('./user_guide/', '/test_copy/'); causes a php error encountered severity: warning message: mkdir() [function.mkdir]: permission denied filename: helpers/directory_helper.php line number: 91 php error encountered severity: warning message: mkdir() [function.mkdir]: no such file or directory filename: helpers/directory_helper.php line number: 91 php error encountered severity: warning message: copy(/test_copy/helpers/cookie_helper.html) [fun

asp.net mvc - Where to put validation annotations ViewModel or Domain object? -

my question is as passing usercreateviewmodel create controller means validation(modelstate.isvalid) work on usercreateviewmodel if annotation defined on it. can not define dataannotation on each of viewmodels because alot of work. instead want put on user domain model. how fix create method fix annotation work , mapper without adding more code controller. //my controller create method [httppost] public actionresult create(usercreateviewmodel user) { if (modelstate.isvalid) { var createuser = new user(); mapper.map(user, createuser); _repository.add(createuser); return redirecttoaction("details", new { id = createuser.userid }); } return view("edit", user); } //usercreateviewmodel -> create specific view model public class usercreateviewmodel { public string username { get; set; } public string password { get; set; } } //user -> domain object [metadatatype(typeof(user.uservalidation))