Posts

Showing posts from July, 2011

Original url from twitter short url -

i need base url or original url short url obtained twitter in form http://t.co ... is way original base url this...please suggest any kind of appreciated.. look @ link, https://dev.twitter.com/docs/tweet-entities especially "the media entity" part one of these api should solve problem. media_url url of media file (see sizes attribute available sizes) media_url_https ssl url of media file (see sizes attribute available sizes) url media url extracted display_url not url string display instead of media url expanded_url resolved media url

sql server 2008 r2 - How to modify this SQL Query to show the percentage of participation in the last sending quiz in each division in the company? -

i have following query shows number of participants in last sending quiz in each division. want keep instead of showing number of participants, want show percentage of participation in last sending quiz. for information, have following database design: employee table: username, name, job, divisioncode division table: sapcode, divisionname quiz table: quizid, title, description, issent userquiz table: userquizid, score, datetimecomplete, quizid, username note: first attribute in each table primary key. issent flag used determine quiz sent users , 1 not. so how modify query show percentage of participation? sql query: select dbo.divisions.divisionshortcut, count(distinct dbo.userquiz.username) [number of participants], dbo.quiz.quizid dbo.divisions inner join dbo.employee on dbo.divisions.sapcode = dbo.employee.divisioncode inner join dbo.userquiz on dbo.employee.username = dbo.userquiz.username inner join dbo.quiz on dbo.

Where is the "Store" menu in the Visual Studio 11 Beta? -

where "store" menu in visual studio 11 beta? downloaded , installed ultimate version , there's no "store" menu see in video tutorials . what see in installation what expect see open metro project. you'll find menu in project | store

.net - Where to run a duplicate check for an entity -

i'm looking advice on "best" place put validation logic, such duplicate check entity, when using entity framework code-first, in mvc application. to use simple example: public class jobrole { public int id { get; set; } public string name { get; set; } } the rule "name" field must unique. when add new jobrole, easy run check in job role repository name doesn't exist. but if user edits existing jobrole, , accidentally sets name 1 exists, how can check this? the issue there doesn't need "update" method on repository, job role entity automatically detect changes, there isn't logical place check before attempting save. i have considered 2 options far: override validateentry method on dbcontext, , when jobrole entity being saved entitystate.modified, run duplicate check then. create sort of duplicate-checking service, called controller, before attempting save. neither seems ideal. using validateentry seem

RTF number of pages Page x of y -

not sure if possible trying save text via plain text output rtf special coding. i have working except total number of pages. i want "page x of y", bottom of each page "page 1 of 3" example, can't find correct code total page number. some people said use \nofpages source says use of \nofpagesn specify number of pages in document. there formula or can use or maybe way put last page number? here example of code, if put rtf file via notepad save , open in wordpad or word see mean: {\rtf1\pagestart1 {\header\brdrt\brdrth\ql\b name: \b0last, first \par\b dob: \b0 1979/11/03 \par\b service date/time: \b0 2012/03/06 00:49:00 \par\b mrn: \b0 xxxxxx \par\b order date/time: \b0 2012/03/05 01:14:00 \par\b study id: \b0 } \par{\footer\pard\brdrt\brdrs\qc\fs16\b\ul confidentiality notice \par\par\pard\brdrt\brdrs\keepn\ql\fs20 date: \chdate\par\keepn\qc\fs20 page \chpgn of \nofpages\par}\b study id: \b0 000000000000 \par\pard\brdrb\brdrth bunch of

linux - How to redirect all internet traffic to local proxy in the same workstation -

i'm trying find way redirect internet traffic catch ip packets , work them. for example, webbrowser try connect www.google.com generates http request, ip packet. want packet in machine , it. is there way it? (i'm working linux os) thanks. if want capture network traffic on own machine, try tcpdump . dumps ip packets file (with -w flag). see http://linux.die.net/man/8/tcpdump

cordova - iFrame Changes window.innerHeight / window.innerWidth on Android + PhoneGap -

i'm creating app using phonegap android. 1 of pages in app contains iframe (with local content) larger rest of pages (this single-page app). the problem i've run once iframe page viewed, window.innerheight , window.innerwidth javascript objects change values match iframe's width/height causing rest of 'pages' display incorrectly not same size. this persists after remove iframe dom. has run or has idea of workaround? first, sure there bug here ! i had same issue , resolved, here how. changed iframes & images width 100% or less wider window.innerwidth. here corresponding haxejs code: resizenodechildrentag(_contentcontainer,"iframe"); resizenodechildrentag(_contentcontainer,"img"); private function resizenodechildrentag(node:htmldom, tagname:string):void { var tagnodes:htmlcollection<htmldom> = node.getelementsbytagname(tagname); // nodes given tag name (i in 0...tagnodes.length) {

c# - Get entities that are not linked -

i have items , lines linked itemslines table. on web page, show item. want display in dropdownlist lines not linked item. this doesn't work : int itemid = convert.toint32(request.querystring["id"]); ddllines.datasource = context.lines.where(t => !t.itemlines.any(x => x.itemid == itemid)); i trying lines where(they not associated item). i can't figure out how this. thank much! edit : this error message get: the objectcontext instance has been disposed , can no longer used your error not because lambda expression incorrect. issue context object using connect database has been disposed of before call: ddllines.datasource = context.lines.where(t => !t.itemlines.any(x => x.itemid == itemid)); the solution add .tolist() end of expression. because .where lambda expression returns iqueryable interface , interface still has connection database. adding .tolist() remove connection database.

sql - Deleting a user and the user profile -

i'm new sql , stored procedures, , need stored procedure below. have tables connected each other: "user" , "profile". when deleting user user profile should deleted, , that's sp below does. however, when executing sp userids in table user shows (of course because of "select userid), , don't want. so, guess question how write sp works without using select? thanks in advance. create procedure usp_deleteuser @userid int begin begin try begin transaction; select u.userid [user] u inner join profile p on u.userid = p.userid; delete profile userid = @userid; delete [user] userid = @userid; commit transaction; end try begin catch rollback transaction raiserror ('borttagningen gick inte att genomföra!',16,1) end catch end go profile.userid should foreign key indicating one-to-one relationship user table, on delete cascade sp

c# - How do I pass information back to my application as part of the facebook login process? -

i'm looking @ .net code performs facebook login, using c#/.net library wrappers. i pass identifier log-in attempt, goal of having facebook pass me once user has been authenticated. i'm constructing redirect url request manually, , i've tried both of following without success: oauthclient.redirecturi = new uri( "http://localhost:3434/fboauth?token=" + httputility.urlencode( token ) ); //fails when attempting access token - //"oauthclient.exchangecodeforaccesstoken( code )" throws exception. var loginuri = oauthclient.getloginurl( new dictionary<string, object> { { "state", returnurl }, {"app_data", httputility.urlencode(token)} } ); //doesn't pass app_data application how pass arguments application part of facebook login process? i use facebook c# sdk building facebook apps too. don't use authentication stuff. in experience, authentication hardest part of overall facebook app impl

c# - How to add new row to datagridview? -

i have datagridview filled data datasource (sql). want add new row, can't, because new data can't added bounded datagridview... i trying : datagridview1.source = null; datagridview1.rows.add("1"); but clears previous data in table. how it, add new row without deleting previous data? when set datasource property null , removing all data datagridview (since doesn't know bind anymore). you have 2 options here. first update underlying data source. let's assume it's datatable . in case, you'd like: datatable dt = datagridview1.source datatable; dt.rows.add(new object[] { ... }); and datagridview pick on changes (note if not binding doesn't implement inotifycollectionchanged interface , you'll have call resetbindings method grid refresh). the other option let datagridview manage rows. can manually adding each item using add method on datagridviewrowcollection returned rows property : foreach (var item in

javascript - o From XMLHTTPRequest is Undefined -

so, lifted nice ajax code site. problem such lame javascript programmer can figure out how output onto page. startup() function says o undefined. see results of php on firebug console. tia help. var asyncrequest = function() { function handlereadystate(o, callback) { if (o && o.readystate == 4 && o.status == 200) { if (callback) { callback(o); } } } var getxhr = function() { var http; try { http = new xmlhttprequest; getxhr = function() { return new xmlhttprequest; }; } catch(e) { var msxml = [ 'msxml2.xmlhttp.3.0', 'msxml2.xmlhttp', 'microsoft.xmlhttp' ]; (var i=0, len = msxml.length; < len; ++i) { try { http = new activexobject(msxml[i]); getxhr = function() { return new activexobject(msxml[i]); }; break; } catch(e) {} }

android - Renderscript transparency / alpha -

i'm using ics , trying show transparent renderscript layer on regular view. use rs draw text on app. i'm using setalpha(8, 8); , can see layer generated it's bgra (dumpsys surfaceflinger). my rs script doing this: rsgclearcolor(0.0f, 0.0f, 0.0f, 0.0f); rsgdrawtext("hello!", 50,50); i able show renderscript layer drawing text, on regular view. my main activity uses setcontentview 2 times, 1 main view, , second 1 rs. if approach might wrong, should @ least able see background of app, while see black , "hello!" text in white covering everything. tried using 2 different activities, i've never been able make renderscript layer transparent. any ideas? you need set pixelformat , zorder of renderscript view. try adding when create renderscript view: view.getholder().setformat(pixelformat.translucent); view.setzorderontop(true);

javascript - Making a button fixed on a changing DIV -

is there way allign button center of div.i able make work different strategies using padding-top:2px , padding-bottom:2px or using margin-top , margin-bottom.but here comes problem,basically moving div i.e might differ if user have more inforamtion in it.for example user enters work number in input text field showing only work phone number.but if user enters work,home , additional number,it need show information entered,which vary size of div.what happens div increase in size , button still stays @ top of div.is there way make button fixed @ center after div varies in size.can achieved in css or need used javascript make work. vertical align tricky. however demo of moving centered button css , moved jquery. as moves, button remains @ center position has not been defined. #outer { text-align: center; width: 200px; background: #ddd; height: 200px; position: static; display: table; } #inner { line-height: 200px; display: table-cell;

windows phone 7 - Parsing out query parameters from Live Tile as NameValueCollection while in background agent -

i'm parsing out query parameters namevaluecollection uri based on shelltile.navigationuri property. while in context of background agent don't have access navigationcontext described here: parse uri arguments on shelltile on windows phone 7 . is there api available similar system.web.httputility.parsequerystring windows phone? achieved string operations, i'm curious know alternatives. as can uri tile, can still split query "&" , split each element returns "=" create namevaluecollection yourself.

javascript - Cross-origin resource sharing for Tomcat 5.5 -

i new cross-origin resource sharing , want enable in tomcat 5.5 server. can give me hint how can achieved? i want set header universally requests, , allow origins ( access-control-allow-origin: * ) if it's static site, starting tomcat 7.0.41, can control cors behavior via built-in filter . pretty thing have edit global web.xml in catalina_home/conf , add filter definition: <!-- ================== built in filter definitions ===================== --> ... <filter> <filter-name>corsfilter</filter-name> <filter-class>org.apache.catalina.filters.corsfilter</filter-class> </filter> <filter-mapping> <filter-name>corsfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- ==================== built in filter mappings ====================== --> be aware, though, firefox not access-control-allow-origin

JQuery XML Parsing on error -

Image
i'm trying parse xml in ajax response. when server returns 200 works fine. seems xml parsing in jquery disabled on error. statuscode:{ 200:function(xml){alert($(xml).find("error").text());}, 404:function(xml){alert($(xml).find("error").text());} } if send 200 correct alert. if change response code whatever error like, empty alert box. plain stupid sending text/xml on error, bug in jquery or going wrong? hope can help. thanks according jquery documentation , if request successful, status code functions take same parameters success callback "success(data, textstatus, jqxhr)"; if results in error, take same parameters error callback "error(jqxhr, textstatus, errorthrown)" that means in 404 callback "function(xml){alert($(xml).find("error").text());" 'xml' jqxhr object , understandably $(xml).find("error").text() nothing. share | improve answer

java - Static Utility Class in spring 3 application -

is violation if go ahead utility methods static rather depending on di of spring? i have maintain hashmap below: private static map<string,jmsmessage> messagemap = collections.synchronizedmap(new hashmap<string,jmsmessage>()); messagemap can accessed multiple threads. have utility methods play around messagemap. made class final , declared utility methods static. violation according spring ioc? i argue that, though possible , work correctly in spring ioc, violation of principals of inversion-of-control. it better use singleton bean managed ioc use static field, this @component @scope(configurablebeanfactory.scope_singleton) public class simplemessagemanager implements messagemanager { private map messagemap = collections.synchronizedmap(new hashmap()); @override void addmessage(...) { ... } @override void getmessage(...) { ... } } you inject messagemanager this: public class somebean { @resource

.net - C# ODBC Driver's SQLSetConnectAttr failed -

i'm trying connect access 2007 database (.accdb) .net console application. setup system dsn in odbc manager. how i'm setting connection: conn = new odbcconnection(); conn.connectionstring = "dsn=hu-fu"; conn.open(); on development machine works perfectly, today tried install on client machine , i'm getting following error: error [im006] [microsoft][odbc driver manager] driver's sqlsetconnectattr failed anyone has idea problem? here odbc trace source: upsshipmentserv 1454-6f0 enter sqldriverconnectw hdbc 0x00424070 hwnd 0x00000000 wchar * 0x69938b34 [ -3] "******\ 0" sword -3 wchar * 0x69938b34 sword -3 sword * 0x00000000 uword 0 <sql_driver_noprompt> upsshipmentserv 1454-6f0 exit sqldriverconnectw return code -1 (sql_error) hdbc 0x00424070 hwnd

java - Showing toast before an intesive work of processor -

i need show toast message before method using intense processor work. problem toast shows after method, calling method in thread. how can show toast before ? edit: code long showing here ... resume ... ... toast.maketext(getbasecontext(),"text", toast.length_short).show(); proccess.setrun(); //in proccess class implements runnable ... public void setrun(){ thread= new thread(this); thread.setpriority(thread.norm_priority); thread.start(); running=true; } public void run() { bytes=bytegroovemaker(); prepare(grbytes); } //bytegroovemaker() method in proccess class requires lot of processor work. just use async task. on onpreexecute show toast, , in doinbackground method execute heavy process :)

xml - cvc-pattern-valid: Value 'A' is not facet-valid with respect to pattern '^[A-Za-z]?$' for type 'whatever' -

here's particular xml tag validation failing: <middlename>a</middlename> the xsd tag: <xsd:element name="middlename" type="middleinitial" /> <xsd:simpletype name="middleinitial"> <xsd:restriction base="xsd:string"> <xsd:pattern value="^[a-za-z]?$" /> </xsd:restriction> </xsd:simpletype> the error i'm getting: cvc-pattern-valid: value 'a' not facet-valid respect pattern '^[a-za-z]?$' type 'middleinitial'. the validator i'm using: http://tools.decisionsoft.com/schemavalidate/ the regular expression looks good. ^ matches start, $, end, ? 0 or 1 times letters a-z or a-z. any ideas? from w3 spec regular expressions (appendix d) : ...expressions matched against entire lexical representations rather user-scoped lexical representations such line , paragraph. reason, expression language not contain metac

How to use Content-Encoding: gzip with Python SimpleHTTPServer -

i'm using python -m simplehttpserver serve directory local testing in web browser. of content includes large data files. able gzip them , have simplehttpserver serve them content-encoding: gzip. is there easy way this? since top google result figured post simple modification script got gzip work. https://github.com/ksmith97/gzipsimplehttpserver

ios - Rearranging tab views doesnt work -

Image
i have tab bar controller 8 tabs (views). when tap more... , edit modal view lets me rearrange tabs appear, rearranging not work. tabs not stay place dragging them. do need enable something? when drag them, trying rearrange them in cluster view pops up? if won't work, drag 1 want move down tabbar, , replace existing one.

jQuery mobile not displayed correctly -

Image
i'm attempting use jquery mobile described @ a bottom navbar in jquery mobile looking iphone navbar, possible? . heres code, tried adding code 1 file : <html> <head> <style type="text/css"> .nav-glyphish-example .ui-btn .ui-btn-inner { padding-top: 40px !important; } .nav-glyphish-example .ui-btn .ui-icon { width: 45px!important; height: 35px!important; margin-left: -24px !important; box-shadow: none!important; -moz-box-shadow: none!important; -webkit-box-shadow: none!important; -webkit-border-radius: none !important; border-radius: none !important; } #favorite .ui-icon { background-image: url(http://glyphish.com/images/demo.png); background-position: -345px -112px; background-repeat: no-repeat; } #recent .ui-icon { background-image: url(http://glyphish.com/images/demo.png); background-position: -9px -61px; background-repeat: no-repeat; } #contacts .ui-icon { backg

c# - How to replace or remove the spl character in xml -

am creating xml file using xmlwriter,i thought works fine when try validate fails bcoz there spl character (bom) appears below,just gone thru forum seen lot of people adive me use "securityelement.escape". not sure how , where.some 1 please guide me remove spl charecter xml file. ï»Â¿<?xml version="1.0" encoding="utf-8"?> if found code above symbol it &#195;&#175;&#194;&#187;&#194;&#191;&#060; my code xmlwriter xmlwrite; xmlwritersettings settings = new xmlwritersettings(); settings.omitxmldeclaration = true; xmlwrite = xmlwriter.create(@"c:\test.xml",settings); xmlwrite.writestartelement("metadata"); xmlwrite.writeelementstring("story", story); xmlwrite.close(); i can succesfully remove version still spl characters there . stuck now. any ? this answer me rid of spl char

javascript - Catch input earlier than onChange and preferably only numbers -

i have table of input fields. form used inexperienced users want prepared worst. i have created code highlight table row it's input field has changed. downside here code triggered after user has clicked outside inputfield. what looking achieve following. as user types in something, triggered, after every digit , enter/backspace, etc. event highlight table row. later on want extend function automatically save form locally, figure out code later on. secondly, price form, great if user can only type in numbers the browsers using have full html5 , css3 support , , javascript engine use newest version of jquery. ps. if there downsides on implmenting please let me know also. use keyup event, value of input have been updated time event fires can change value before user blur s element. update you can limit input numbers using regular expression: //bind `keyup` event `input` element(s) $('input').on('keyup', function () { //replace valu

How to write a C Program which can convert Volwels in the given string to lower if it were upper and upper if it were lower? -

#include <ctype.h> #include <stdio.h> #include <conio.h> int main(void) { char input[50]; char i; int j = 0; printf("please enter sentence: "); fgets(input, 50 , stdin); (j = 0; input[i] != '\0'; j++) if (input[i]=='a'||input[i]=='e'||input[i]=='i'||input[i]=='o'||input[i]=='u') { input[i]=toupper(input[i]); printf("your new sentence is: %s", input); } else if (input[i]=='a'||input[i]=='e'||input[i]=='i'||input[i]=='o'||input[i]=='u') { input[i]=tolower(input[i]); printf("your new sentence is: %s", input); } return 0; } this not home work .i beginner in c .i can not find out mistake in code have googled cant locate useful data correct mistake.the error getting printf("your new sentence is: %s", input)

if statement - Trouble with formatting input as JSON format with java -

hi have trouble java program. i'm writing program asks user book's title, author, price, , isbn. takes input stores book class stores input , has tostring method prints out contents similar json formatting. books class uses array list store book objects , has tostring method prints out entire set of books in json format. problem doesn't format properly. problem lies within if , else statement in code. heres code: import java.util.arraylist; public class books { private arraylist<book> books; public books() { books = new arraylist<book>(); } public void add(book bk) { books.add(bk); } public string tostring() { string temp = "{\n "; temp = temp + " \"books:\": [\n"; int bookcount = 0; (book bk : books) { temp += bk.tostring(); bookcount++;//add +1 bookcount if (bookcount < books.size()-1) { temp += ",\n"; } else { temp += &q

objective c - Why does calling a property on NSObject pointer gives build errors? -

i have nsmutablearray returns me object. object added had properties name,age. now when use these properties on object returned ( obj.name or obj.age ), compiler says, no such member, use ( -> ) instead of ( . ) i understand nsobject wont have these members , hence wont understand property. but if use setters, , getters method ( [obj name] or [obj age] ) syntax instead of properties, dont errors. but using property means calling setter or getter ? ad objective c suppose dynamic language, right ? that's right - dot syntax not supported in such case. you need cast pointer actual class: ((myobject*)[array objectatindex: 0]).name = @"bill";

java - Inconsistent Transaction behavior in Appengine Local Datastore? -

the appengine docs transactions in datastore: http://code.google.com/appengine/docs/java/datastore/transactions.html#isolation_and_consistency in transaction, reads reflect current, consistent state of datastore @ time transaction started. not include previous puts , deletes inside transaction. queries , gets inside transaction guaranteed see single, consistent snapshot of datastore of beginning of transaction. with in mind, have created following 2 unit tests test (against local datastore). expecte both of tests below pass. however, "test1" passes, whereas "test2" fails. difference commit of tx1 in "test1". is bug in local datastore, misunderstanding of gae docs, or bug in unit tests? or else? thanks! @test(expected = entitynotfoundexception.class) public void test1() throws entitynotfoundexception { datastoreservice datastore = datastoreservicefactory.getdatastoreservice(); // create 2 transactions... transaction txn1 = d

Handling and passing large group of variables to functions\objects in python -

i find myself in need of working functions , objects take large number of variables. for specific case, consider function separated module takes n different variables, pass them on newly instanced object: def function(variables): of variables object1 = someobject(some of variables) object2 = anotherobject(some of variables, not in object1) while can pass long list of variables, time time find myself making changes 1 function, requires making changes in other functions might call, or objects might create. list of variables might change little. is there nice elegant way pass large group of variables , maintain flexibility? i tried using kwargs in following way: def function(**kwargs): rest of function and calling function(**somedict), somedict dictionary has keys , values of variables need pass function (and maybe more). error undefined global variables. edit1: i post piece of code later since not @ home or lab now. till try better explain situatio

Performance of asp.net WebAPI vs. asp.net MVC controller emmiting JSON? -

does know if there performance benefits using webapi rather using mvc controller returns json? i think benefits more related flexibility performance. can implement rest service using mvc way, web api provides cleaner model: actions implicit in http verbs, content can delivered both in json , xml, there native support return iqueryable< t > (this can seen small performance improvement), , can integrated asp.net web forms application (or console app, no asp.net @ all).

development environment - Starting Eclipse on AIX throws java/lang/OutOfMemoryError -

i've installed eclipse (eclipse-sdk-3.6.2-aix-gtk-ppc64.zip) on aix instance. appeared starting buttons stop working. tracked down eclipse throwing following exception: jvmdump006i processing dump event "systhrow", detail "java/lang/outofmemoryerror" - please wait. jvmdump032i jvm requested snap dump using '/home/atginst/eclipse/snap.20120309.111040.8650798.0001.trc' in response event jvmdump010i snap dump written /home/atginst/eclipse/snap.20120309.111040.8650798.0001.trc jvmdump032i jvm requested heap dump using '/home/atginst/eclipse/heapdump.20120309.111040.8650798.0002.phd' in response event jvmdump010i heap dump written /home/atginst/eclipse/heapdump.20120309.111040.8650798.0002.phd jvmdump032i jvm requested java dump using '/home/atginst/eclipse/javacore.20120309.111040.8650798.0003.txt' in response event jvmdump010i java dump written /home/atginst/eclipse/javacore.20120309.111040.8650798.0003.txt jvmdump013i processed dump e

typoscript - Typo3: classes for elements -

i have 3 different kinds of in website, , want give able give different classes backend using rte text element. should this: <ul class="type2"> .... </ul`> i thought should use 1 of 3 boxes rte, "blockstyle", im not sure how add new options dropdow. can please me? thanks! do speak german? this article help.