Posts

Showing posts from July, 2012

c# - Extending an application and accessing its functions -

i'm trying design lightweight service performs scheduled tasks. since want able add new\different tasks, i've been reading lot reflection , inversion of control\dependency injection. different options , frameworks though, i'm lost in simplest question: how access new functions can executed? most design/patterns adding extensibility application , frameworks based on them encourage, force use well-defined interfaces in parts need extend application, unified interfaces, accessing new functions should done through these well-defined interfaces , managing , calling new methods , execution flow should considered internal implementation of plugin/extension. so believe first step find requirements , unified them extension point, after implementing extensions based on framework of choice.

android - Delay while launching activity from service -

i have broadcast receiver receives screen off broadcast, , when screen turned off, launches activity. i've named activity lockscreenactivity. i've added getwindow().addflags(windowmanager.layoutparams.flag_show_when_locked); in oncreate() of activity, appears on top of android lockscreen, want. works enough, mostly. problem happens whenever press home button send any app background. when press home button return home screen app, , press power button turn off screen, , press power button in second turn in on, shows android lock screen. activity gets created 3-4 seconds later. huge delay , unacceptable. in other scenarios, delay not happen. if i've been in home screen time, or other app open, , click power button twice in quick succession, see lockscreenactivity before seeing android lockscreen. my app has few other normal activities (launched app drawer) , service shows persistent notification. same lockscreenactivity launched whenever notification clicked. inter

BigQuery loading batch folders error -

i'm trying load group of folders files in 1 time when set sourceuri = 'gs://ybbi/bi_landing_zone/files_to_load/app/reports/app_network_analytics_report/201409011*' all folders i'm want load start 20140911 but error: error: invalid path: gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/ 20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0 1 of these folders(don't know why it's print folder name of specific folder) in other folder tree cases it's works, in specific folder tree it's return same error . i know cloud storage don't have real folders , it's part of name of object, understand mean. is bug? without more information, looks have object file called gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/ not csv/json file. tools may create thes

Button click event not fire properly in <include> tag in ANDROID -

i have 3 xml files 1) header 2) firstactivity 3) secondactivity. header.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <button android:text="button 1" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onclick="first1" > </button> <button android:text="button 2" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onclick="second" > </button> </linearlayout> firstactivity.xml <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="h

java - Null resultsets when calling Sybase stored procedure through JDBC -

i'm calling sybase stored procedure returns multiple resultsets through jdbc. need specific result set has column named "result" code : callablestatement cs = conn.preparecall(sqlcall); cs.registeroutparameter(1, types.varchar); cs.execute(); resultset rs=null; int count = 1; boolean flag = true; while (count < 20000 && flag == true) { cs.getmoreresults(); rs = cs.getresultset(); if (rs != null) { resultsetmetadata resultsetmetadata = rs.getmetadata(); int columnscount = resultsetmetadata.getcolumncount(); if (resultsetmetadata.getcolumnname(1).equals("result")) { // action code resultset found flag = false; // loop on resultset , add elements returned array list while (rs.next()) { int x = 1; while (x <= columnscount) { result.add(rs.getstring(x)); x++; } }

regex - how to transforming pseudo xml into flat structure? -

i'm trying parse file looks xml not. actualy readable version of crd transformed asn1 format. looks this: <pin rownum="1"> <cgpa tag="3100.2.960.51" value="1"> <data tag="3100.2.962.56" name="cgpasubscriberidentifier" value="50212000000089804"/> <data tag="3100.2.962.60" name="cgparoaming" value="1"/> </cgpa> <aaa_common tag="3100.2.960.1" value="1"> <data tag="3100.2.962.12" name="sigsleeid" value="watbf102"/> <data tag="3100.2.962.34" name="scpaddress" value="48602888950"/> </aaa_common> <evt tag="3100.2.134.28" name="unsupported" value="0"/> <data tag="3100.2.112.1" name="eventdatetime" value="07/05/2014 19:45:18"/> <data tag="3100.2.137.4" name="intriggeringkey&q

vim - Load gtags with given gtags root -

i have log file(in /home/logs) file names , line numbers. want files in project rooted @ /x/projects/project12/ . how use gtags files while log file opened in vim ? 1 clumsy way copy log file in project directory. is there better way, while log file opened in vim set gtagsroot /x/projects/project12/ , lookups happen in project ? edit: gtags created gtags command in project root. the gtags-scope.vim plugin uses global -pq find location of gtags file. easiest solution set current working directory project directory via :cd ~/project . but there better way! use gf . can add project root 'path' option , gf , <c-w>f , :find , , friends work. doing following: :set path+=~/project or if want adjust 'path' option buffer do: :setlocal path+=~/project for more see: :h 'path :h gf :h :cd

html - Creating a footer that stays at the bottom of the page -

i have went through countless methods on answered questions. believe followed 1 ( http://www.cssreset.com/how-to-keep-footer-at-bottom-of-page-with-css/ ) t still cannot footer stay @ bottom of page. know has been asked countless times don't adjust code. appreciated. here code: html <body> <div id="wrapper"> <header> <div class="logo"><a href="index.html"><img src="http://i.imgur.com/ewlyoiy.png"/></a></div> <div class="chapter-logo"><a><img src="http://i.imgur.com/rpivgdd.png"/></a></div> </header> <nav> <ul class="menu"> <li><a href="index.html">home</a> <li class="dropdown"><a href="">about ▾</a> <ul class = "sub-menu&

mysqli - Multiple ORDER BY from multiple Tables -

alright ive been struggling 1 far long, assistance grateful. i have 2 tables: table name: column names. (only showing relevant column names) topics: topic_id, topic_cat, topic_stick replies: reply_id, reply_date, reply_topic im trying (topic_id)'s = 1, in want sorted latest (reply_date), , having (topic_stick) @ top. reply_topic = topic_id i have been trying statement after statement no success: has been closest attempt not sort table wishes. select topic_id topics, replies reply_topic = topic_id , topic_cat = 1 group topic_id order reply_date desc, topic_stick asc select t.topic_id, t.topic_cat, t.topic_stick, r.reply_id, r.reply_date, r.reply_topic replies r inner join topics t on t.topic_id = r.reply_topic t.topic_cat = 1 group r.reply_topic order r.reply_date desc

compilation - Compiling a Go program with C Libraries into a Standalone executable -

i'm trying compile go program standalone including c libraries. command i'm using [mm17@mm17 grogger]$ go build --ldflags '-extldflags "-static"' ./grogger.go # command-line-arguments /usr/bin/ld: cannot find -lgrok collect2: ld returned 1 exit status /home/mm17/go/pkg/tool/linux_amd64/6l: running gcc failed: unsuccessful exit status 0x100 so i'll modify file calls grok library have following header 1 package grok 2 3 /* 4 #cgo ldflags: -l /usr/lib/libgrok.so -lgrok 5 #include <grok.h> 6 */ 7 import "c" and running same command gives [mm17@mm17 grogger]$ go build --ldflags '-extldflags "-static"' ./grogger.go # github.com/blakesmith/go-grok /usr/bin/ld: warning: cannot find entry symbol _start; defaulting 0000000000400180 /tmp/go-build731085030/github.com/blakesmith/go-grok/_obj/grok.cgo2.o: in function `_cgo_4244208c3352_cfunc_strlen': ../../blakesmith/go-grok/grok.go:169: undefined referen

ios - Using Parse CloudCode to send a pdf attachment via mailgun? -

i using ios parse.com , mailgun. trying send email pdf attached. have read parse.com cloudcode doesn't allow attachments. have seen post, mailgun: sending image using parse cloud code ,saying instead of attaching place inline. first off, still case, cannot send attachments via cloud code? if so, give me hand in figuring out how pdf app email sent through mail gun? im not using built in mail view apple because need able set "from" address of email. i have pdf created dynamically in app , present in code this: nsstring* filename = @"invoice.pdf"; nsarray *arraypaths = nssearchpathfordirectoriesindomains( nsdocumentdirectory, nsuserdomainmask, yes); nsstring *path = [arraypaths objectatindex:0]; nsstring* pdffilename = [path stringbyappendingpathcomponent:filename]; uiwebview* webview = [[uiwebview alloc] initwithframe:cgrectmake(0, 60, 320, 4

android - Duplicated elements when dynamic loading them in horizontal scrollview -

i have main.xml have listview . row of listview defined in row.xml this: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="horizontal" > <imageview android:id="@+id/image" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="60" android:contentdescription="@string/app_name" android:src="@drawable/ic_launcher" /> <textview android:id="@+id/text" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="40&qu

reclassify a list of strings JAVA -

i need java code i have list saved in text file following : a b c d c h b e b f b g g l e e j f k k m 1 2 1 3 2 4 after reading file test.txt, lines added list ( named ch in code) composed of 2 parts, fist part source extracted variable src in code second part target extract trg in code for instance, in first line : b source (src) et target (trg) b now, want create new list (mylist in code) when there line target equal source of previous line. instance, let's stay fist line , see 5th line : a b b e the new list mylist must contain line : b e so in general ch list must reclassified following : a d c h b g l b e b e j b f k m 1 2 4 1 3 i obtain following exception : line:a b exception in thread "main" java.lang.nullpointerexception @ pathcreator.test.main(test.java:48) picked _java_options: -xmx512m this code not working basicly because building new list 3 elements mylist.add(src[a] +" "+trg[a]+" "+trg[b]); w

XSLT 2.0 validation fails with net.sf.saxon.TransformerFactoryImpl -

i have below sample validate xslt style sheet. in various forums mentioned should "net.sf.saxon.transformerfactoryimpl" xslt 2.0 style sheet. according have updated code. piece of code working few cases. example, code not work sample have attached below. if change sample style sheet version 1 (version="1.0"), code works fine. otherwise fails. believe sample style sheet valid xslt 2.0 document. this causing lot of problem, how validate style sheet before parse? package com.ibm.mq.id; import javax.xml.transform.transformerconfigurationexception; import javax.xml.transform.stream.streamsource; import net.sf.saxon.transformerfactoryimpl; public class xslttransformationex { /** * @param args */ public static void main(string[] args) { string path="c://work//ex.xsl"; transformerfactoryimpl factory = new transformerfactoryimpl(); try { javax.xml.transform.templates template = factory.newte

user interface - Creating a Login by linking login code with a java Gui -

i've been trying link login code java gui created i've been having problems when comes running it. 1) code doesn't read text file have created 2) when press login gui, nothing. want check entered username , password usernames , passwords in text file. please me, i've checked other solutions couldn't find relevant problem. don't think linked code right if that, great. first class: import java.awt.eventqueue; import javax.swing.jframe; import javax.swing.joptionpane; import javax.swing.jtextfield; import javax.swing.jpasswordfield; import javax.swing.jlabel; import javax.swing.jbutton; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; public class login extends jframe{ public jframe frame; public jpasswordfield passwordfield; public jtextfield textfield; public jbutton blogin; public jbutt

c# - Database connectivity error in Visual Studio? -

Image
i have lost connectivity using visual studio 2012 database... when try reconnect , run application here exception note: previous file deleted mistakenly, , trying attach new 1 says exist? solution? what kind of database running? specify: if have sqlexpress database: first need change data source name this. "data source=(localdb)\v11.0" "data source=.\sqlexpress" to connect local sql server instance, issue following string: server=.\sqlexpress;attachdbfilename=c:\myfolder\mydatafile.mdf;database=dbname trusted_connection=yes; to connect local sql server instance database file located in data directory, issue following string: server=.\sqlexpress;attachdbfilename=|datadirectory|mydbfile.mdf;database=dbname trusted_connection=yes; to connect localdb automatic instance, issue following string: server=(localdb)\v11.0;integrated security=true; to connect localdb automatic instance specific data, issue following string: server=(localdb)\

java - How do i access a specific object from with in the class it was created from -

im not going paste whole entire code here problem. keep things simple ill make code right here problem. okay have class called "exampleclass" has integer variable called "number" example , "number" has , set method. question is: if have multiple objects of "exampleclass" how specific object out of multiple objects can access specific object inside "exampleclass". "exampleclass" below public class exampleclass{ public int number; public int getnumber() { return number; } public void setnumber(int number) { this.number = number; } } assuming number makes instance of class "unique" purpose of comparison, should consider overriding equals , hashcode methods. that way, you'll able find instances of class within collection such arraylist using indexof(object o); for example: public class exampleclass { private int number; public exampleclass(in

c# - wcf workflow with parallel sub flows complex senario -

workflow scenario http://i61.tinypic.com/mmftz5.jpg according attached scenario have workflow: first user start request , requestid , assign request manager inbox. manager see request , select relevant approvers(1..n) , assign flow them. foreach approver see request, approver can reject , return request manager or accept , select relevant employees something.(the approval process parallel). every employee recieves work may , finish the assigned work. if employes finished assigned works workflow completed. in senario have difficulties: workflow in same time may in different states(aprovers state , employees state. approver(1) may assign flow employees approver(2) may not yet). wcf operation names in parallel foreach make duplicated bookmarks. i need best solution or simple example me implement scenario. (make sub workflow approver , employees?,how solve parallelism problems? use of external wcf flows?) tnx. take data design account , have data include st

symfony - Customizing Symfony2 forms -

i started using symfony2 framework. i apologize incorrect terminology using. i customize how forms presented in application. more specifically, in twig file rendering entire form with {{ form(forms) }} i customize layout of form. know each row of form can expanded as {{ form_start(forms) }} //... <div> {{ form_label(forms.field) }} {{ form_errors(forms.field) }} {{ form_widget(forms.field) }} </div> //... {{ form_end(forms) }} with form written in format add needed customization layout. here problem: form not have pre-defined number of rows, these depend on values stored in database. in twig this {{ form_start(forms) }} {% field in forms %} <div> {{ form_label(forms.field) }} {{ form_errors(forms.field) }} {{ form_widget(forms.field) }} </div> {% endfor %} {{ form_end(forms) }} unfortunately, loop not work. looked ( how customize form rendering ), think not suit case (does it?). any suggestion? thank in advanc

How to implement jquery file upload and carrierwave in rails 4? -

would implement these tools in rails 4, has been impossible. has done?. ask help. regards, refer link. #381 jquery file upload

python - How to brute force a tree of 'yes/no' decisions? -

Image
i want solve puzzle. don't know kind of code required it. problem exponential one. description: the player walks/runs 1 step @ time. there decision made; yes/no question. once question answered, player continues walking until next decision/question reached. continue until total distance covered. the problem want see every possible route through (many python lists such ['y','y','n','y','n']). here code have written far: (the player in player() class, have removed because unimportant here.) class solver(object): """ solver object. """ def __init__(self, field): self.field = field self.dinc = 113 self.distance = 128 def take_step(self, player): """ takes step , records players route. """ # adds 0 if there no decision made on step # adds 1 if there decision made on step player.run(self.dinc) if self._is_decision_time(player):

objective c - Front Camera switch goes black -

i making app that, in course, can take picture rear camera , take picture front camera 3 seconds after. dismissing previous uiimagepickercontroller , presenting uiimagepickercontroller, in completion block of presentviewcontroller:animated:completion: method start nstimer calls takepicture after 3 seconds. this worked charm in ios 7. in ios 8 fail see front camera view , receive in console: uiimagepickercontroller: ignoring request take picture; camera changing modes. what going on here? there api change? or x.0 bug? if code needed me out gladly provide it.

How to make a new line in this C printf code? -

this question has answer here: how split string literal across multiple lines in c / objective-c? 7 answers printf("%c trying forget love trying remember never knew \n\n",3); become in vb.net: printf("%c trying forget love trying to" & "remember never knew \n\n",3); we add next string on new line.... how connect string in c language. two ways: printf("%c trying forget love trying " "remember never knew \n\n",3); string literals can written multiple quoted parts. still 1 string. way can have indentation , comments in between. printf("%c trying forget love trying \ remember never knew \n\n",3); you can split string literal having backslash last char in line. there ne no newline in resulting string, if want use \n\ @ end. if indent 2nd line, whitespace go string, not want

java - Spring MVC Controller Test Case not working -

@runwith(springjunit4classrunner.class) @contextconfiguration(classes=basetestconfig.class) @webappconfiguration public class bookdetailscontrollertestcase { private mockmvc mockmvc; @autowired private webapplicationcontext wac; /** * */ private bookdetailscontroller fixture = new bookdetailscontroller(); public bookdetailscontroller getfixture() { return fixture; } public void setfixture(bookdetailscontroller fixture) { this.fixture = fixture; } /** * @throws java.lang.exception */ @beforeclass public static void setupbeforeclass() throws exception { } /** * @throws java.lang.exception */ @afterclass public static void teardownafterclass() throws exception { } /** * @throws java.lang.exception */ @before public void setup() throws exception { mockmvc = mockmvcbuilders.webappcontextsetup(this.wac).build(); } /** * @throws java.lang.exception */ @after public void teardown() throws exception { } @test public void testgetbookdetails() { fail(&qu

How do I mock validation in domain class for testing? -

i have domain class uses custom validator that's quite complex; requires separate collaborator. i'm creating controller want mock part validation. want able tell when validation error occurs control behavior. for example, have, class person { static constraint = { key validator: { //complex stuff goes here } } } in controller spec, want able tell when want validation pass or fail. tried doing person.metaclass.validate = { true } doesn't seem work. how test code looks like. void "test controller when validation passes"() { when: controller.json = new person(...) controller.dosomething() then: //test post condition, etc. } if nothing works, i'm thinking of mocking command object directly, like, void "test controller when validation passes"() { when: controller.dosomething(mock(person)) then: 1 * _.changestate(_) //test post condition, etc. } but if can fi

javascript - jQuery hover function not working and don't know why -

i have following code supposed show content of paragraph doesn't work: jquery <script> $(document).ready(function () { $('.portfolio-excerpt').hover(function () { $('.portfolio-text').addclass('portfolio-hover') }, function () { $('.portfolio-text').removeclass('portfolio-hover') }) }) </script> html <div class="portfolio-img"> <a href="images/portfolio-big.jpg"><img src="images/thumbnail.jpg"/></a> <p class="portfolio-excerpt">they thing better.</p> <p class="portfolio-text">lorem ipsum</p> </div> css .portfolio-hover { display:block; } p.portfolio-excerpt { display:block; height:30px; width:auto; } p.portfolio-text { display:none; } which not working , don't know why. can help? all need changing css declaration. p.portfolio-t

javascript - Custom directive for telephone format using angularjs -

i trying write custom directive usa telephone number using angularjs , need preserve data type of field integer.here jsfiddle directive , need complete directive. if user enters valid telephone no (exactly 10 numbers ie.1234567890) input should split 3 chunks 123-456-7890 when user moves next control.otherewise should show error message "not valid number". <div ng-app="myapp" ng-controller="myctrl"> <form name="myform"> <input type="text" ng-model="telephone" phoneformat name="input1" /> <span class="error" ng-show="myform.input1.$error.telephone">numbers only!</span> <span class="error" ng-show="myform.input1.$error.telephone">exact 10 numbers only!</span> </form> </div> var myapp = angular.module("myapp", []); var myctrl = myapp.controller("myctrl",["$scope", funct

c# - Allow custom control to correctly scroll out of view -

i have custom control consists of filled rounded rectangle text. (the actual control more complicated code shown here has sames symptoms.) attached instances of control panel, , made panel child of panel autoscroll = true. thought enough correct scroll behavior, if scroll such left side of control should go off left side of panel sticks , control shrinks. same scrolling such control should go off @ top. (bottom , right seem not problem.) here sample code (requires reference system.windows.forms , system.drawing.) using visual studio 2010 .net 4 client on windows. using system; using system.drawing; using system.drawing.drawing2d; using system.windows.forms; namespace customcontrolscrolltest { static class program { [stathread] static void main() { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); application.run(new form1()); } } // form dock = fill pane