Posts

Showing posts from January, 2011

php - How to achieve single sign on? -

i new single sign on. system has 3 different instances different applications 1.openerp 2.magneto 3.php web site , in applications user , password same. getting confused should start. can use oauth or simplest way achieve single sign on can have ldap necessary. assuming have common database this, can achieve writing few api's. and use kind of tokenization approach. means when user enters valid credentials, create token , store in db user , return same token response. use same token set browser session or cookie, , across different application i.e 1.openerp 2.magneto 3.php web site read above cookie/session, if set, log them in.

asp.net - Combining 2 regular expression in web.config passwordStrengthRegularExpression="" -

i not able combine below 2 regular expressions. password standard requirement: password cannot contain username or parts of full name exceeding 2 consecutive characters passwords must @ least 6 characters in length passwords must contain characters 3 of following categories uppercase characters (english a-z) lowercase characters (english a-z) base 10 digits (0-9) non-alphabetic characters (e.g., !, @, #, $, %, etc.) expression: passwordstrengthregularexpression="((?=.*\d)(?=.*[a-z])(?=.*[a-z])(?=.*[@#$%]).{6,20})" passwords cannot contain word “test” or “test” or variants of word passwordstrengthregularexpression="((?=.*\"^((?!test|test|test).*)$" both working fine individually. because second regexp uses negative lookahead, can remodel , stick right @ beginning of other expression. first, i'm going change second regex to: "(?!.*(?:test|test|test))" in english, string may not contain number of (or zero) char

c# - Multiple Bitwise Flag Combos -

i have method takes enum flags parameter of items display. items in database can have multiple flags set, , value passed method can have multiple flags set. eg: item1 = flag1 item2 = flag1 | flag3 item3 = flag2 | flag3 i want able pass these values method , have corresponding items returned. if pass flag2 | flag3, return item2 , item3 (because each flag matches 1 of flags set in entity) if pass flag1, return item1 , item2 ...etc. i've been experimenting .where , .any , still have absolutely no clue how this, if it's possible. i'm targetting .net 4.5 , using ef5. use bitwise and operator myflags value = myflags.flag2 | myflags.flag3; myflags item1 = myflags.flag1; myflags item2 = myflags.flag1 | myflags.flag3; myflags item3 = myflags.flag2 | myflags.flag3; bool matchitem1 = (value & item1) > 0; //false bool matchitem2 = (value & item2) > 0; //true bool matchitem3 = (value & item3) > 0; //true [flags] enum myflags { flag1

sitecore - Index building quits, how to continue from there -

in sitecore 7, if index building process quits (building indexes 20million+ items hours , hours), how continue index rebuilding there? if lastindexupdate timestamp value updated, you'll have no issues. indexing should continue on next scheduled indexing job.

Java consuming REST services -

i'm trying consume rest service using java client , obtain java.net.connectexception: connection timed out exception. if i'm using web client (chrome, firefox) i'm able retrieve right answer. i added in windows firewall exception java not solve problem. connection secured. sslcontext sslcontext = sslcontext.getinstance("tls"); x509trustmanager[] xtmarray = new x509trustmanager[] { new owntrustmanager() }; sslcontext.init(null, xtmarray, new java.security.securerandom()); if (sslcontext != null) { httpsurlconnection.setdefaultsslsocketfactory(sslcontext .getsocketfactory()); } httpsurlconnection .setdefaulthostnameverifier(new isahostnameverifier()); public class owntrustmanager implements x509trustmanager{ public void checkclienttrusted(x509certificate[] chain, string authtype) { } public void checkservertrusted(x509certificate[] chain, string authtype) { } publ

html - DIV does not move or scale via JQuery UI -

i'm getting started html 5 app. when page loads, have logo in center of screen. need logo in center of screen begin with. user can begin using app clicking "begin" button. when happens, want animate logo in 2 ways: i want logo move current location upper left corner (with bit of padding top , left) i want scale image down. in attempt this, i'm using jquery ui. here have: <body> <div id="wrapper"> <div id="content"> <div id="logo"></div> <input type='button' value='begin' onclick='return beginbutton_click();' /> </div> </div> <div id="footer"> <span id="greeting" class="footer-content"> hello </span> <span class="separator">|</span> <a href="#" target="_blank" class=&qu

php - Autoplay next embedded soundcloud track? -

i'm using http://ifttt.com grab public favourites soundcloud , post them wordpress site ( http://diversesounds.co.uk ). ifttt creates post on site following contents; <div class="trackurl" id="(ifttt grabs track url , places here)"> i have following block of js; <script src="//connect.soundcloud.com/sdk.js"></script> <script> <?php if(have_posts()): while (have_posts()) : the_post(); ?> <?php // exploding content track url div id $thecontent = get_the_content(); $explode = explode('"', $thecontent); $trackurl = $explode[3]; ?> sc.oembed( "<?php echo $trackurl; ?>", { color: "494e72", show_comments: false }, document.getelementbyid("<?php echo $trackurl; ?>") ); <?php endwhile; endif; ?> the above code works autoplay next track after finishing first manually played track. i know next nothing js (i gra

java - Android Open GL ES Textures messed up -

i have own method draw images. uses vertex , uvbuffers. i draw following: spritebatch.begin(blendmode) <- sets blending spritebatch.draw(parameters) <- add vertices list of vertex arrays spritebatch.end() <- sets buffers , draw out @ once and works charm. however when try drawstring method uses same draw method. texture uv maps or buffers screwed (everything draws solid rectangle missing pixels). i use angelcode bitmap font generator. i use same functinality difference set textures , uv maps according current character's data. i post draw functions in case messed in other functions. public void begin(int source, int destination) { gl.glenable(gl10.gl_blend); gl.glblendfunc(source, destination); } all buffers , variables (i didn't want declare in functions) arraylist<float[]> vertices = new arraylist<float[]>(); floatbuffer vertexbuffer; arraylist<short[]> indices = new arraylist<short[]>(); shortbuffer indexbuffer

c# - How to render Path geometry without Window Handle using Windows Store C++ -

in windows store application, have draw path geometry using direct2d in c++. in scenario instead of using basic polyline object, go direct2d better performance in application. c# application communicate c++ component direct2d drawing. this link helped more information direct2d drawing pathgeometry . draws geometry in window handle rather using window handle need drawing done ordinary uielement rendering. there sample available on net resolve problem ? there samples directx/xaml integration , think there might vs project template integrating these includes direct2d code, though possibly in single project natice c++ app, whereas need create native winrt component exposes c++/cx api application put in either swapchainpanel (best option, requires windows 8.1), swapchainbackgroundpanel (good option, full-screen only) or surfaceimagesource .

linux - Run emacs as separate process from terminal -

when run emacs text editor process not return cannot use terminal default behavior. i cannot find switch or command in man know simple. how can run emacs separate process can continue use terminal without opening second one? you can start program in background appending ampersand command, emacs & . there's whole framework working backgrounded processes, see example man jobs , disown , fg , bg , , try ctrl-z on running process, suspend , give terminal, allowing resume process either in foreground or background @ pleasure. when shell closes, programs end, disown allows tell program keep running after end session.

java - ActiveMQ stops sending messages to Queue Consumer in case of consumer not acknowledging messages -

we have use case wherein create 1 consumer process messages in queue. message processor accumulates number of messages before acknowledging. receiving messages in asynchronous way , using transacted session. size of message small. active mq stops sending further messages sole consumer after number of messages , waits acknowledgement. have tried solutions consumer.prefetchsize , consumer.maximumpendingmessagelimit ; nothing working. tried similar use case durable topic 1 subscriber , works fine. has encountered similar activemq issue/behavior? tried many things mentioned on different forums none of them helped. activemq version : activemq 5.6.0 queue configuration : durable queue consumer : asynchronous , uses transacted session acknowledgement mode any or suggestion appreciated. thanks. i had tried out lot of different configurations resolve issue setting different activemq attributes prefetch policy, maxpagesize etc. none of them helped. referring @jake's

unix - Shell Script to copy all files in a directory to a specified folder -

i'm new in shell script , trying figure out way write script copies files in current directory directory specified .txt file , if there matching names, adds current date in form of filename_yyyymmddmmss name of file being copied prevent overwritting. can me out? i saw thinking along lines of #!/bin/bash source=$pwd #i dont know wheter makes sense want #say source directory 1 in right destination=$1 #as said want read destination off of .txt file in $source #i pseudo coded part because didn't figure out. if(file name exists) copy changing name else copy fi done the problem have no idea how check whether name exist , copy , rename @ same time. thanks how this? supposing target directory in file new_dir.txt. #!/bin/bash new_dir=$(cat new_dir.txt) now=$(date +"%y%m%d%m%s") if [ ! -d $new_dir ]; echo "$new_dir doesn't exist" >&

Importing Compass styles with Sass using Yeoman -

i created project using yo webapp (with generator-webapp installed obviously). fine, i'm still missing something. i'm sure it's such easy answer i'll never come because i'll embarrassed. i want use compass, comes out of box yeoman, don't know how. mean, @import "compass...etc" inside sass files won't work since inside app/bower_components (the default path sass @import s specified inside gruntfile.js ) there's no compass directory. what should in order import compass stylesheets? you can use compass do. if set vanilla compass project compass create , there compass folder either. if want use of helpers compass ships with, can import them described in documentation, e.g. @import "compass/css3"; .mybox { @include box-shadow(red 2px 2px 10px); } main.scss

Are there limits on string length in Arduino? -

i've been trying hours put simple json object string on arduino send raspberry pi running node. i cannot seem build string. have tried building string in 1 go: "{" + string1 + "," + string2 + "," + string3 + "}" etc... i've tried using string.replace function. each time end bit of string, or none @ all. below code shows what's happening: string msg = "{ \"message\" : \"statusupdate\", "; string active = " \"active\" : token, "; string intaketemp = " \"intaketemp\" : token, "; string intakehumid = " \"intakehumid\" : token, "; string exhausttemp = " \"exhausttemp\" : token, "; string exhausthumid = " \"exhausthumid\" : token, "; string targethumid = " \"targethumid\" : token, "; string completed = " \"taskcompleted\" : token }"; if(isactive) active.repl

java - SSLSocket ignores domain mismatch -

i reading ssl socket host doesn't match certificate (eg. host = "localhost" ). expect exception following code happily talks remote server without problems. try ( final socket socket = sslsocketfactory.getdefault().createsocket(host, port); final outputstream os = socket.getoutputstream(); final inputstream = socket.getinputstream()) { os.write(("head / http/1.1\r\nhost: " + host + "\r\nconnection: close\r\n\r\n").getbytes()); os.flush(); final byte[] bytes = new byte[1024]; int n; while ((n = is.read(bytes)) != -1) { system.out.print(new string(bytes, 0, n)); } system.out.println(); } catch (final ioexception e) { // todo auto-generated catch block e.printstacktrace(); } therefore i've tried approach: try { final httpurlconnection conn = (httpurlconnection) new url("https://" + host + ":" + port + "/").openconnection(); try (inputstream = con

jquery - How to tell if caret is within H1 tag? -

i building wysiwyg content editable. want bold button highlight when caret within bold text, etc. have working, can't figure out how same h1 & h2. commandstate doesn't seem work items. my js code: setinterval(function () { var isbold = document.querycommandstate("bold"); var isitalic = document.querycommandstate("italic"); var isunderlined = document.querycommandstate("underline"); if (isbold) { $('button[rel=bold]').addclass('active'); } else { $('button[rel=bold]').removeclass('active'); } if (isitalic) { $('button[rel=italic]').addclass('active'); } else { $('button[rel=italic]').removeclass('active'); } if (isunderlined) { $('button[rel=underline]').addclass('active'); } else { $('button[rel=underline]').removeclass('active'); } }, 100); si

android - No default value in sharedpreferences -

a code snippet: if (mgameprefs.contains(game_pref_name)) { thename = mgameprefs.getstring(game_pref_name, "jane doe"); } but when retrieve preference without previous storage, there's no default value. retrieval code: preferencelastgame gamesettings = new preferencelastgame(this); string gamename = gamesettings.getthename(); i have code default value if(gamename == null) gamename = "jane doe"; every thing else in place , works fine. why failing? game_pref_name define as: public class memoinfoactivity extends fragmentactivity { public static final string game_preferences = "gameprefs"; public static final string game_pref_name = "thename"; // key string ........ preferencelastgame class put code regarding handling of preferences. if (mgameprefs.contains(game_pref_name)) { thename = mgameprefs.getstring(game_pref_name, "jane doe"); } you won't default value code. first thi

db2 - SQL using CASE in SELECT with GROUP BY. Need CASE-value but get row-value -

so basicially there 1 question , 1 problem: 1. question - when have 100 columns in table(and no key or uindex set) , want join or subselect table itself, have write out every column name? 2. problem - example below shows 1. question , actual sql-statement problem example: a.field1, (select case when b.field2 = 1 b.field3 else null table b a.* = b.*) casefield1 (select case when b.field2 = 2 b.field4 else null table b a.* = b.*) casefield2 table group a.field1 the story is: if don't put case own select statement have put actual rowname group , group doesn't group null-value case actual value row. , because of have either join or subselect columns, since there no key , no uindex, or somehow find solution. dbserver db2. so describing words , no sql: have "order items" can divided "zd" , "ek" (1 = zd, 2 = ek) , can grouped "distributor". though "order items" can have 1 of 2 different "departements"(zd,

Calculate price from two different table + using php and mysql -

i have 2 tables in database, 1 table has trip/user related information: such trip_id , username , leave_date , return_date , flight_estimate , registration_fee etc, , second table expense table trip_id fk, , expenses such hotelcost, bf,lunch each date... each trip_ip has more 1 record in table. now, i'm trying create summary table total price using php user , when used following code, gives records of trip 1 date right, if has multiple dates, if creates 2 different records.. want 1 record (since i'm calculating grand total of particular trip) if(isset($user)) { $sql = " select trip.trip_id new_tripid" . " , destination" . " , leave_date" . " , return_date" . " , date(last_updatedate) updateddate" . " , flight_estimate" . " , registration_fee" . " , hotel_cost" . " ,

audio - How to extract video's file volume information using FFMPEG? -

we need extract volume information every second video file in order produce graphical representation of volume changes during video progress. i'm trying use ffmpeg audio filter stucked in how extract volume information every second (or frame) , export information report file. thanks in advance.

java - How to use Latin letters in Eclipse? -

Image
i have text in progressdialog, , other places , after save , run on phone works fine. restart eclipse situation on screenshot below: how make eclipse remember suppose be? right click on project , select properties. click on resource, , change text file encoding utf-8 or else support characters want use. to change default encoding setting .java files (or other file types), go window > preferences > content types. under text, select java source file. set default encoding want.

c# - Linq filter using List<int> -

i have database column: year (nvarchar) , want add values of column dropbox, sorted descending. this code using: list<string>years = db.tbl1.select(w => w.year).distinct().tolist(); years.reverse(); foreach (string year in years) { drop_years.items.add(year);} it not working because beeing string have this: 2012, 2010, 2009, 2011, etc .. if use: list<int> years = db.tbl1.select(w => w.year).distinct().tolist(); the compiler tell me cannot immplicitly convert type ..< string > ..< int >... i biginer , not know how resolve issue. please me? i serched similar topics mine did not me figure out. to manage problem used unprofessional method: var years = db.tbl1.select(w => w.year).distinct(); list<int> yearslist = new list<int>(); foreach (string year in years) { yearslist.add(convert.toint32(year)); } yearslist.sort(); //i used sort() because doesn't work reverse(); yearslist.reverse(); but kn

Is it possible to do client side logging of downloaded HTML code? -

i'm trying find way log html downloaded onto someone's machine, may plugin, may stand-alone program. we have customers reporting popups advertisers don't get. it's geo-targeted script responsible this. want filter out these advertisers , ban them our site. it's hard find responsible party without being able replicate problem , people reporting problem have not enough technical skills able figure out who's responsible. want able offer them plugin or logs downloaded html until problem arises again @ point send me logs , easy know problem came from.

tsql - T-SQL Group by / Order by + SQL Server Reporting Service Parameters -

select users.userid ,users.firstname + ' ' + users.lastname ,[month] ,[day] ,x.[przych] ,x.[wych] ,x.[przych] + [wych] [ogół] (select caseactionhistory.userid ,month(caseactionhistory.dateadded) [month] ,day(caseactionhistory.dateadded) [day] ,sum(case when caseactionhistory.caseactiondefinitionid in (14,15,16) 1 else 0 end) [przych] ,sum(case when caseactionhistory.caseactiondefinitionid in (20,21,22,23,26) 1 else 0 end) [wych] caseactionhistory caseactionhistory.caseactiondefinitionid in (14,15,16,20,21,22,23,26) group month(caseactionhistory.dateadded),day(caseactionhistory.dateadded), caseactionhistory.userid order month(caseactionhistory.dateadded) desc,day(caseactionhistory.dateadded) desc offset 0 rows ) x inner join users on x.userid = users.userid i'm trying run out out of this. problem is: results of such query displayed this: user month day x user1 7 31 6 user

ios - Read data from iPhone Documents in javascript -

in app made json file , stored in folder documents in iphone. wanted know if it's possible read json file using javascript function embedded in uiwebview. made little mobile site in html5 , javascript need read json show html pages stored in folder documents. hope understand mean , hope can me solve issue.

css - editable div in table exceeds its percentage-width when content is very long -

i'm using chrome. have editable div inside table, width defined percentage. css below. div#editable { width:20%; white-space:nowrap; overflow:hidden; border:1px solid darkgrey; } when adding long content div, width begins increase regardless of css definition. here demo link: http://jsfiddle.net/k5erc/ . can try input more content div , see width growing. however, if width defined px or em, there no such problem. could tell me how fix width? thanks! if wish text wrap, width stays same need rid off white-space:nowrap; otherwise add table-layout:fixed; table css see updated fiddle here http://jsfiddle.net/k5erc/1/

serial port - How to know when enter key is pressed in C -

i trying communicate computer through serial communication micro-controller (avr). programming in c, , cannot figure out how determine if user has pressed enter key in terminal , wondering if able me out. this question more details. sounds want detect @ avr when user presses enter @ pc? , using serial line between two. please provide copy of c code running on avr. if possible distill or simplify as possible highlight particular question. finally, on avr setting led on, after avr receives cr or cr + lf ?

Blackberry Package project issue -1.debug -

i'm using blackberry_jde_pluginfull_1.1.2.201003212304-12 (bb 5 so). when rich click project -> blackberry -> package project its, generates files on deliverable folder. files 1 u use put app on web client can download app , install on blackberry. now i'm facing problem, times, create file prevent me install app on bb. file projectname-1.debug. what making error why here. don't know why happening. my code works fine: public void agendar(){ string msg = "asdasd"; boolean seguir = true; if(_cedula.gettext() == null){ seguir = false; } if(seguir && _fechanac.getdate() < 1){ seguir = false; } if(seguir && _tel.gettext() == null){ seguir = false; } if(seguir && _pnombre.gettext() == null ){ seguir = false; } if(seguir && _papellido.gettext() != null){ seguir = false; } int = dialog.ask(dialog.d_ok, msg); } same code

MySQL multi-layer filtering based on criteria from one column -

in table i've got list of names, email addresses , column called referrer. users name , email entered multiple times table contest. referrer column tells me how contestant heard contest. how recordset of contestants shows if referrer web and/or email choose 1 record each? example, contestant entered 10 times under email , 100 times under web . i'm trying single instance of each record. this current query: select * table_contestants referrer in ('email', 'web') group email order referrer; of course, when use group by gives me 1 instance of record regardless of whether it's found have email or web . removing group by give me instances, lot... how write query give me 1 record of each contestant has both email , web ? there various solution depending on need: if need distinct (name, email) pairs regardless of referer, use distinct keyword: select distinct name, email tbl referer in ("email", "web");

sql server 2008 - Execute multiple sql scripts in order using web deploy -

Image
i using ssdt project keep current schema. have scripts need run during deployment of sql database. how can setup scripts execute in order on picture below? currently deploy fails when have added publish data post deploy, means steps 1,2 did not execute hoped. see order need execute below:

c# - parsing an xmldocument from a webrequest -

i'm having heck of time parsing layout: <string xmlns="http://www.namespaceuri.com/admin/ws"> <cardtrxsummary> <paymentmethod> <payment_type_id>visa </payment_type_id> <authorization>0.0000</authorization> <capture>0.0000</capture> <forcecapture>0.0000</forcecapture> <postauth>0.0000</postauth> <return>0.0000</return> <sale>3419.2700</sale> <receipt>0.0000</receipt> <repeatsale>0.0000</repeatsale> <activate>0.0000</activate> <deactivate>0.0000</deactivate> <reload>0.0000</reload> <authorization_cnt>0</authorization_cnt> <capture_cnt>0</capture_cnt> <forcecapture_cnt>0</forcecapture_cnt> <po

Javascript minification and obfuscation changed numbers in code -

i ran code through online js minified/obfuscator , changed numbers in code short of shorthand format. example 30000 became 3e4 , 15000 became 15e3, e replaces 0 , following number amount of zeros? has occurred , fine keep numbers in format within code, example: settimeout(function () {myfunction();}, 3e4); maybe stupid question i'd learn happened, thanks. it's scientific notation. it's part of basic syntax of language. numeric literals (that is, numeric constants in code) can expressed exponent part, implicitly indicates power of 10 first part of value should multiplied. minifier takes advantage of more compact source notation when possible. the same sort of notation common among many programming languages.

java - How to write a junit testcase for a void method that creates a new object -

public class supportcontroller{ public void disableuseraccount(string username) throws exception { useraccount useraccount = new useraccount(constants.system, constants.container, username); useraccount.disableaccount(); } } how test useraccount created disabled? i suggest using mock objects . besides that, can check junit faq , can find section testing methods return void . often if method doesn't return value, have side effect. actually, if doesn't return value , doesn't have side effect, isn't doing anything. there may way verify side effect occurred expected

symfony - Render a form with some join entity -

i have 3 entities: customer contract (every customer have 1 or more contract, contract 1 customer: there onetomany relation between customer , contract) invoice (every invoice refer 1 or more contract, every contract have 1 or more invoice: there manytomany relation between contract , invoice). now want render invoice form checkbox. write: ->add('contracts',null, array( 'multiple' => true, 'expanded' => true )) in invoiceformtype contracts not specific customer. how it? thanks in advance. v. you can't give null form type. use own contractstype instead: $builder->add('contracts', new contractstype(), array( 'multiple' => true, 'expanded' => true )); see docs more information.

c# - How to check typeof parameters in method? -

how check typeof parameters in method code contracts? i need check type argument in method how about public void mymethod(object parameter) { if (parameter.gettype() == typeof(int32)) { //do stuff } } in continuation other question class managercar : iblalba { public void render(iviewtemplate template) { if (template.gettype() == typeof(carviewtemplate)) { //do stuff } } }

c# - I get a "Microsoft JScript runtime error: Object doesn't support this property or method" error for anything with autopostback=true on one of my pages -

i have .net application following aspx code: <%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="webapplication1.default"%> <%@ register tagprefix="asp" namespace="ajaxcontroltoolkit" assembly="ajaxcontroltoolkit"%> <%@ register assembly="telerik.web.ui" namespace="telerik.web.ui" tagprefix="telerik"%> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <body> <form id="form1" runat="server"> <asp:toolkitscriptmanager id="scriptmanager1" runat="server" enablepartialrendering="true"> </asp:toolkitscriptmanager> <table> <tr> <td> <asp:radiobuttonlist id="rbltest" runat

java - <jsp:forward> or <jsp:include> actions in a JSP needs buffering to be enabled? -

i came across post says that, <jsp:forward> or <jsp:include> actions in jsp, needs buffering enabled. can please tell me why that? the jsp contains <jsp:forward> action stops processing, clears buffer, , forwards request target resource. note calling jsp should not write response prior action the include action, on other hand, executes each client request of jsp, means file not parsed included in place. provides capability dynamically change not content want include, output of content. syntax include action <jsp:include page="some-filename" flush="true" />. note flush attribute must included (in jsp 1.1) force flush of buffer in output stream.

background - Android: Back key press to stop following activity -

at beginning, apologize bad english. there problem: below timer showing message @ every 3 second , when getting out program (using button) message still pop out. public runnable mupdatetimetask = new runnable(){ @override public void run() { // todo auto-generated method stub while (true) { try { thread.sleep(3000);} catch (exception e) { // todo: handle exception } mhandler.post(new runnable(){ @override public void run() { toast.maketext(getapplicationcontext(), "testing 3 seconds", toast.length_long).show(); } }); } } }; i use mhandler.removecallbacks(mupdatetimetask); still can't stop it. thanks in advance. the call has been made runnable thread class, still active when button pressed. pop messages un

using xml dotted line in android TextView -

i have created xml dotted line explained in how make dotted/dashed line in android? . if use background of textview shows up. <textview android:id="@+id/segment" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/dotted_lines" android:gravity="left" android:text="first segment" android:textsize="12sp" /> but if use accompanying drawable, not show up. <textview android:id="@+id/segment" android:layout_width="match_parent" android:layout_height="match_parent" android:drawablebottom="@drawable/dotted_lines" android:gravity="left" android:text="first segment" android:textsize="12sp" /> essentially, couldn't care less either way, except: need dotted lines appear below text in textview. please help. use followin

gcc - Mex generates error for // while compiling C code in Linux -

i want compile c code in ubuntu using mex configured gcc. can smoothly compile code in osx. however, when want compile in linux, compiler generates error on comment lines starting // (it works fine /* */ . since program includes several header files third-party libraries, cannot substitute // /* */ . know whether there way around overcome problem. matlab version: r2012b gcc version in linux: 4.7.2 gcc version in osx: 4.2.1 any appreciated edit: here command use compile code: mex -g -largearraydims -ldl tdsvdhngateway.c here error generated mex: in file included tdsvdhngateway.c:2:0: tds.h:17:1: error: expected identifier or ‘(’ before ‘/’ token tds.h:26:2: error: unknown type name ‘index_t’ tds.h:27:2: error: unknown type name ‘index_t’ in file included tdsvdhngateway.c:2:0: tds.h:146:3: error: unknown type name ‘index_t’ tdsvdhngateway.c:37:3: error: unknown type name ‘index_t’ tdsvdhngateway.c: in function ‘mexfunction’: tdsvdhngateway.c:166:25: error: ‘index_t’ un

import - Python: importing another .py file -

i have class , want import def function doing: import <file> but when try call it, says def can not found. tried: from <file> import <def> but says global name 'x' not defined. so how can this? edit: here example of trying do. in file1.py have: var = "hi" class a: def __init__(self): self.b() import file2 a() and in file2.py have: def b(self): print(var) it giving me error though. import file2 loads module file2 , binds name file2 in current namespace. b file2 available file2.b , not b , isn't recognized method. fix with from file2 import b which load module , assign b function module name b . wouldn't recommend it, though. import file2 @ top level , define method delegates file2.b , or define mixin superclass can inherit if need use same methods in unrelated classes. importing function use method confusing, , breaks if function you're trying use implemented in c.

iOS Memory Leak with Activity View -

Image
i discovered memory leak in app i'm not sure how go fixing it. involves activity view used share url of current article being viewed rss feed. i'm not sure why leak happening. ideas or advice? the method in question iphone version is: - (void) showmenu { nsurl *urltoshare = hackyurl; nsarray *activityitems = @[urltoshare]; tusafariactivity *activity = [[tusafariactivity alloc] init]; uiactivityviewcontroller *activityvc = [[uiactivityviewcontroller alloc]initwithactivityitems:activityitems applicationactivities:@[activity]]; activityvc.excludedactivitytypes = @[uiactivitytypeassigntocontact, uiactivitytypeposttoweibo, uiactivitytypesavetocameraroll]; [self presentviewcontroller:activityvc animated:true completion:nil]; } edit: i've fixed iphone leak changing above code this: __block uiactivityviewcontroller *activityvc = [[uiactivityviewcontroller alloc]initwithactivityitems:activityitems applicationactivities:@[activity]]; a

c# - Add a New ViewModel to ViewModelLocator in MVVM Light Toolkit -

i know question basic, @ current moment, lost how should add new viewmodel viewmodellocator class in mvvm light toolkit. my current implementation looks so: first assume have window named settings , viewmodel named settingsviewmodel , viewmodellocator viewmodellocator . first call createsettings() in viemodellocator constructor: public viewmodellocator() { if (viewmodelbase.isindesignmodestatic) { } else { createsettings(); } createmain(); } note run i'm not using blend , build application each time try run it. `createsettings() method. i had no idea doing tried play safe , model after methods used creating , managing mainviewmodel. public static void createsettings() { if (_settings == null) { _settings = new settingsviewmodel(); } } then few methods modeled after used mainviewmodel: [system.diagnostics.codeanalysis.suppressmessage("microsoft.performance", "ca1822:markmembersassta

java - How to get realative path for database? -

i developing jframe store data in database using textfields , all. have following code database connection. using sqlite database. **connectdatabase.java** /* * change template, choose tools | templates * , open template in editor. */ package shreesai; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import javax.swing.joptionpane; /** * * @author deeprocks */ public class connectdatabase { connection con = null; public static connection connecrdb(){ try{ class.forname("org.sqlite.jdbc"); connection con = drivermanager.getconnection("jdbc:sqlite:g:\\development\\project\\database\\shreesai.sqlite"); return con; } catch(classnotfoundexception | sqlexception e){ joptionpane.showmessagedialog(null,"problem connection of database");

java - Struts XSS Prevention - Prevent a GET XSS -

i have been able prevent xss attack in struts 1.2 through combination of filter="true" in bean:write messages , using stringescapeutils.escapehtml4(string) in tag libs using. can attack site through attack in url in following form... www.mysite.com/app/start.do?logo=mylogo'><script>alert("attack")</script> any advice on best way prevent this. tried using servlet filter don't want convert request inputs special characters. easiest way i've found block xss replacing > , < , " characters &lt; , &gt; , &quot; before writing webpage. should protect xss long aren't placing user input inside places such script tags, image tags (xss has been possible src= of image tags) etc won't able create own tags. in php htmlspecialchars method encodes characters that. java doesn't have method quickest way replace those, should go through entire list yourself. shouldn't hard implement 5 replaceall(

Is Android + PhoneGap/Cordova always a headache? -

i've been developing mobile app both ios , android. due time/budget constraints, selected phonegap/cordova mobile app framework write once , deploy both platforms. this plan has worked fine ios, we're finding android's browser/engine kind-of piece of garbage (to put nicely). every time add new feature, find 1 more thing android browser doesn't support, or partially supports, or supports randomly fail time time, etc. once code around android issues , things working smoothly, test on multiple devices/versions, , deploy new app android market, start getting emails , reports customers can't app work on device. have them uninstall/reinstall, reboot phone clear memory, etc., , device still consistently fails (and "fail", mean typically freezes and/or won't respond touch input - doesn't crash, or anything). app works fine people, there still quite few devices inexplicably fail. i don't mean rant, i'm trying analyze whether android+phon

visual c++ - Running MSVC via CMake using ssh to Cygwin works if using a password to login but not with a public key -

we have windows 7 desktop we're hoping use run automated tests of windows port of our c++ code. it's using cmake build system, compiling visual studio 10.0, if logged in locally. automated test system we're using needs ssh build machines using public-key authentication, i've installed cygwin , have sshd running service in separate account (cyg_server). can connect fine, logging in build account using password, , run build without issues. however, if add public-key authentication, can still log in fine, build fails, if i'm logged in , running build manually, it's login interactive bash shell working case! error message is 3>link : fatal error lnk1101: incorrect mspdb100.dll version; recheck installation of product for every link step. what different in environment between password , public-key authentication that's causing this? note else identical between working , failing case - authentication method has changed, , repeatable it's not

Bug in ffmpeg resampling_audio.c -

i trying compile , run resampling_audio.c in ffmpeg 1.2. seems there bug , code segfaults. debugged code , seems crashing on /* convert destination format */ ret = swr_convert(swr_ctx, dst_data, dst_nb_samples, (const uint8_t **)src_data, src_nb_samples); if (ret < 0) { fprintf(stderr, "error while converting\n"); goto end; } dst_bufsize = av_samples_get_buffer_size(&dst_linesize, dst_nb_channels, ret, dst_sample_fmt, 1); the stack trace is #0 malloc_consolidate (av=0xb7f6f440) @ malloc.c:4251 #1 malloc_consolidate (av=0xb7f6f440) @ malloc.c:4203 #2 0xb7e4122f in _int_malloc (av=0xb7f6f440, bytes=8248) @ malloc.c:3543 #3 0xb7e42418 in _int_memalign (av=0xb7f6f440, alignment=32, bytes=8192) @ malloc.c:4503 #4 0xb7e446a0 in __gi___libc_memalign (alignment=32, bytes=8192) @ malloc.c:3104 #5 0xb7e45714 in __posix_memalign (memptr=memptr@entry=0xbfffed7c, alignment=alignment@entry=32, size=size@entry=8192