Posts

Showing posts from March, 2015

corruption - SQL Server CE SDF file corrupt. Fixing schema and understanding the repair log file -

i have received corrupt .sdf file client. used sqlceengine.engine method allow me repair point can connect database file , view schema. has recovered of data. although main table have called tablea empty. it created log file seems printing out rows not recover... interesting point "invalid number of columns". 2 years ago schema update pushed out adding 3 new columns. when checked schema on recovered .sdf file missing these 3 columns. assuming schema has corrupted , recovery method trying reinsert rows doesn't match table schema more. find odd cannot recover these 3 columns. can explain more going on log file? i guessing there no way of adding missing columns first , repairing it, rows match possible recovering more data table? many thanks. the log file contains reference tablea, , there 2 types of entry. snippet of log file: block page not found - pwsztable: tablea, idpage: 1465 block page not found - pwsztable: tablea, idpage: 1465 invalid number of

require - In PHP, when autoloading files, where PHP will look for these files? -

Image
i have mvc-based application basic url-rewriting rule, makes url this: website/controller/action/id . id optional. if user enters invalid action , should error handled in class errorcontroller . all of classes files required in autoloader file, should not require them every time want create object. use spl_autoload_register() autoloading. the problem occurs when try entering url invalid action . example, url website/main/inde (instead of index ) - instance of errorcontroller should created. instead, 2 php errors: warning : require( !core/errorcontroller.php ): failed open stream: no such file or directory in d:\programs\wamp\www\fanfics\v0.0.2!core\autoloader.php on line 5 and fatal error: require(): failed opening required ' !core/errorcontroller.php ' (include_path=' .;c:\php\pear ') in d:\programs\wamp\www\fanfics\v0.0.2!core\autoloader.php on line 5 here visual of files (the exclamation mark before core folder keeping on

haskell - Is there a better way than writing `lift`s before each `IO` in a nested `MonadTrans`? -

sometimes need use several nested monadtrans . example, put maybet inside of exceptt , mimick continue , break in imperative programming: runexceptt . form [1..] $ \ _ -> runmaybet $ ... mzero -- mimics continue lift $ throwe "..." -- mimics break lift . lift $ putstrln "hello!" ... however, above code shows, every time need io inside of "artificial loop", need put ugly lift . lift before it. imagine if have more complicated nestings, , lot of io operations, becomes anonyance. how make code cleaner , more concise? for particular case of io , can use liftio :: monadio m => io -> m a lift io action through arbitrarily deep monad transformer stack: liftio $ putstrln "hello" this expression has type monadio m => m () . transformer stack contains instance of monadio somewhere inside of should have monadio instance itself, why works stack of depth.

if / else if inside getter/setter Java -

i started education software engineering learning basics of java... have create simple text-based airport game , ran little trouble. i tried google , sof search function , found many "solutions" however; none seem fix problem. forgive me "noob" qeustion :p in game have several airports generates random amount of passengers each round, minimum of 100 , maximum of 999. used following code... works , doesnt give me errors still random results below 100. doing wrong? said tried many different ways seems neglect if / if else conditions... int paxgenerator; public int getpaxgenerator() { return this.paxgenerator = (int) (math.random() * 1000); } public void setpaxgenerator(int paxgenerator) { if (paxgenerator<100) { this.paxgenerator = 100; } else if (paxgenerator > 999) { this.paxgenerator = 999; } } edit: return this.paxgenerator = (int) (math.random() * 900) + 100; indeed fix problem, thx @user43219 however, sak

android - How to get detected barcode/QR automatically -

i have tried new google play services feature - barcode/qr scanner. in sample application scanning started taping on button , result returned on tap. is there way change behavior return first detected barcode/qr immediately? i not first 1 curious this . thank in advance. update ! for future readers can use this project , includes full screen preview on devices well. previous answer not solid implementation more of quick solution. github repository contains changes , check changelog well. mainacitivity.java barcodecaptureactivity.java camerasource.java barcodegraphictracker.java

java - Spring security4 /login doesn't pass through any filter -

the spring security version used 4.0.2 . main part of spring-security.xml <http pattern="/resources/**" security="none" /> <http pattern="/login" security="none"/> <http auto-config="true" use-expressions="true"> <!-- <intercept-url pattern="/login" access="permitall" /> --> <intercept-url pattern="/about" access="permitall" /> <intercept-url pattern="/**" access="hasrole('role_user')" /> <intercept-url pattern="/user/*" access="hasrole('role_user')" /> <intercept-url pattern="/admin/*" access="hasrole('role_admin')"/> <custom-filter ref="ipfilter" before="filter_security_interceptor"/> <remember-me remember-me-parameter="remember-me" token-vali

java - Spring Data equivalent of aggregation query -

i'm having hard time figuring out how write spring data implementation below aggregation query. background of problem can found here db.asset.aggregate([{$unwind:"$folderids"}, {$group:{_id: "$folderids",assets:{$push: {assets_id:"$_id",display_name:"$displayname"}}}}]) i have got below piece of code far aggregationoperation unwind = aggregation.unwind("folderids"); aggregationoperation groupfolderids = aggregation.group("folderids") .push(new basicdbobject().put("assetid", "$_id")).as("assets"); aggregation aggregation = aggregation.newaggregation(unwind, groupfolderids); aggregationresults<map> results = mongotemplate.aggregate(aggregation, "asset", map.class); i know argument .push() has fixed don't know how. extract few fields asset document in result. appreciated. thank you. if supplying basicdbobject $push use .append method add ad

c# - Wpf Nesting Databound TabControls -

i'm pretty new wpf , i'm trying series of nested tabcontrols in order filter data, nested tabs never seem want appear. <tabcontrol itemssource="{binding years}" selecteditem="{binding selectedyear, updatesourcetrigger=propertychanged}"> <tabcontrol.contenttemplate> <datatemplate> <tabcontrol itemssource="{binding customers}" selecteditem="{binding selectedcustomer, updatesourcetrigger=propertychanged}"> <tabcontrol.contenttemplate> <datatemplate> <!-- data filtered year , customer here --> </datatemplate> </tabcontrol.contenttemplate> </tabcontrol> </datatemplate> </tabcontrol.contenttemplate> </tabcontrol> if use defined tabitems without databinding within first datatemplate, show no problem. there trick

javascript - Jquery .html without deleting element content -

good day guys. my scenario want add new element ul li on tab correspond own id. code working fine.. find .append slower .html... see in code if change .append .html display last loop... since .html delete existing elements inside , replace new one... what want display them via .html regards id. objects groups = [{ groupid: 1, tabpaneid: "home" }, { groupid: 2, tabpaneid: "edit" }, { groupid: 3, tabpaneid: "view" }, { groupid: 4, tabpaneid: "home" }, { groupid: 5, tabpaneid: "home" } ]; items = [{ groupid: 1, item: "sampleitem1", qty: 21 }, { groupid: 1, item: "sampleitem2", qty: 21 }, { groupid: 2, item: "sampleitem3", qty: 22 }, { groupid: 3, item: "sampleitem4", qty: 23 }, { groupid: 4, item: "sampleitem5", qty: 24 }, { groupid: 4, item: "sampleitem6", qty: 25 }

Android Camera SurfaceView create bitmap -

hi i've been doing 4 days can't solve it. have class camera preview class , created bitmap function inside class , want call function in class bitmap. this coding calling bitmap function: public class stage extends glsurfaceview { private float w, h; private int screenwidth, screenheight; private string img; private boolean sc; private bitmap screen, imgb; private boolean c; myrenderer mrenderer; //here declare class of camera <<<<<<< camerasurfaceview csv; public stage(context context, attributeset attrs) { super(context, attrs); seteglconfigchooser(8, 8, 8, 8, 0, 0); getholder().setformat(pixelformat.transparent); setzorderontop(true); mrenderer = new myrenderer(); setrenderer(mrenderer); setrendermode(glsurfaceview.rendermode_when_dirty); //here camera class declare......... csv = new camerasurfaceview(context); } public class myrenderer implements glsurfaceview.renderer { public void setsc(boolean yn)

linux - chdir system call in C program -

this question has answer here: how set working directory of parent process? 6 answers program: #include<stdio.h> #include<unistd.h> int main() { char s[100]; printf("%s\n",getcwd(s,100)); chdir(".."); printf("%s\n",getcwd(s,100)); return 0; } output: $ ./a.out /home/guest /home $ the above program changes working directory of process. but, doesn't change working directory of current shell. because when program executed in shell, shell follows fork on exec mechanism. so, doesn't affect current shell. is there way change current working directory of shell via these program built-in (cd, echo) command used shell? is there way change current working directory of shell via these program buildin(cd,echo) command used shell

java - Override the Query String using a Servlet Filter -

i have requirement need to decrypt query string. planning via servlet filter , extending httpservletrequestwrapper shown below. @webfilter(filtername = "urldecryptionfilter", urlpatterns = {"/*"}) public class urldecryptionfilter implements filter { static class filteredrequest extends httpservletrequestwrapper { public filteredrequest(servletrequest request) { super((httpservletrequest)request); } public string getquerystring() { //here put logic transform existing string return "quertstr=modified"; } } @override public void init(filterconfig filterconfig) throws servletexception { } @override public void dofilter(servletrequest request, servletresponse response, filterchain chain) throws ioexception, servletexception { chain.dofilter(new filteredrequest(request), response); } @override public void destroy() { } } but doesn&

multithreading - Running program/function in background in Python -

i'm trying run program/function (whichever possible), python program, start , close. example. python script "parent.py" called input, input data passed function/program "child", take around 30 minutes complete. parent.py should closed after calling "child". is there way that? right i'm able start child, parent closed after completion of child. which, want avoid. as understand it, goal start background process in subprocess not have main program wait finish. here example program that: $ cat script.py import subprocess subprocess.popen("sleep 3; echo 'done!';", shell=true) here example of program in operation: $ python script.py $ $ $ done! as can see, shell script continued run after python exited. subprocess has many options , want customize subprocess call needs. in cases, child process lives after parent exits may leave zombie process. instructions on how avoid that, see here . the alterna

database - Delete all Contents from postgreSQL -

i have database lots of tables. is there way clear contents of tables without each table! mean way iterate database tables list , delete contents. thanx help. a simple database function iterates on tables in schema , clear content. warning: function clear tables without asking if sure :) use caution! no warranty! create or replace function clear_tables_in_schema(_schemaname text)returns void $$ declare _tablename text; begin _tablename in select tablename pg_catalog.pg_tables schemaname = _schemaname loop raise info 'clearing table %.%', _schemaname, _tablename ; execute format('truncate %i.%i cascade;', _schemaname, _tablename); end loop; if not found raise warning 'schema % not exist', _schemaname; end if; end; $$ language plpgsql; -- usage: select clear_tables_in_schema('your_schema');

javascript - select option function not working in iphone but working on all android devices and desktops -

select edited still not working here link website: cleanxcalgary.com on left side choose 1 of option upholstery cleaning , select option "dinning room chair seat" or "dinning room chair seat , back" have select quantity , on iphone whenever click on quantity field popup first dropdown again. it working fine on android , other windows devices problem on iphone. can please me this, here code, , if want can send complete website code. here js code: var total = 0; function putbox() { var temp = document.getelementbyid("upholstery").value; if(temp == "dinning room chair seat" || temp == "dinning room chair seat , back") { document.getelementbyid("quan").innerhtml = '<select name="quan" id="quanf" onchange="addupholsterycleaning()"> <option value="0">select quantity</option> <opti

PHP: Access Method in sub-class -

i want know how access method sub-class of class when i'm in sub-class of same class... example: class foo { } class bar extends foo { public function something() { //do here } } class soap extends foo { $this->something(); //this method wanna call... } as can see wanna access subclass's method sub class. how do in php? you can directly, if soap subclass of bar : class soap extends bar { public function somefunction() { $this->something(); // work } } if it's not , still have option: obtain instance of bar , call method on it: class soap extends foo { public function somefunction(bar $bar) { $bar->something(); // work } } barring that, there's not else can do. since bar not in soap 's inheritance chain, there no way reference something using $this within of soap 's methods.

c# - Delete admob by deleting gameobject. not working -

i new unity. made application , decide add advertisement it. user can delete advertisement when clicked button. put googlemobileadsdemoscript gameobject , button destroy gameobject when user click it. problem is.. not working. gameobject deleted advertisement still there. can guys me.. heres code. renamed disablead.cs using system; using unityengine; using googlemobileads; using googlemobileads.api; public class disablead : monobehaviour { private bannerview bannerview; private interstitialad interstitial; private static string outputmessage = ""; void awake() { requestbanner(); } public static string outputmessage { set { outputmessage = value; } } void requestbanner() { if(playerprefs.haskey("adfree")) return; #if unity_editor string adunitid = "unused"; #elif unity_android string adunitid = "ca-app-pub-3110192020641644/965142

c# - Call SelectedIndexChanged on ComboBox within User Control -

i using .net 4 , trying create customcontrol when add customcontrol onto windows form, want have access selectedindexchanged combobox within user control. basically, want when combo box triggers selected indexchanged, run code within windows form. below have far. public partial class customcontrol : usercontrol ... private void uicombobox_selectedindexchanged(object sender, eventargs e) { } what best way want? any appreciated. if uicombobox placed within user control (named customcontrol), can wire handler in constructor follows: uicombobox.selectedindexchanged += uicombobox_selectedindexchanged; if on other hand, uicombobox placed outside customcontrol, you'd need handle event using above technique , manually invoke method in customcontrol. public class myform:form { myform(){ uicombobox.selectedindexchanged += uicombobox_selectedindexchanged; } private void uicombobox_selectedindexchanged(object sender, eventargs e) {

javascript - Gender API jQuery with classic ASP -

i'm not expert in jquery/ajax - work classic asp. i'm using gender api - https://gender-api.com/en/ discover gender of user based on first name. they had api/jquery plugin: https://gender-api.com/en/jquery-plugin the api has limit of free use. because of idea gender of each user when log on site , record gender on sql table. then when same user returns - read sql table - , no more api (reducing free use) my great problem is, how can gender result jquery plugin (i think return result on client) if asp code work on server? it's possible? ideas? thanks lot! update 1: i got gender using ajax: $.get( "https://gender-api.com/get?name=daniel", function( data ) { $( "body" ) .append( data.gender ); // }, "json" ); this append gender on html body.. i think best way send gender asp redirect page "update.asp" page - like: "update.asp?gender=xxx" how can redirect page usign jquery?

ios - Local Notifications are working in the simulator, but doesn't work when i test it on my actual device -

i have timer function calls local notification timer ever set amount of seconds , supposed run until stopped button. everything in viewcontroller.m file. here code: -(void)timer{ //num slider value num1 = num*60.0; self.showertimer = [nstimer scheduledtimerwithtimeinterval:num1 target:self selector:@selector(notification) userinfo:nil repeats:yes]; } my notification should go off. -(void)notification{ //nsdate *alarmtime = [[nsdate date] datebyaddingtimeinterval:num]; uiapplication *app = [uiapplication sharedapplication]; uilocalnotification *notifyalarm = [[uilocalnotification alloc] init]; // current date/time nsdate *today = [nsdate date]; nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; // display in 12hr/24hr (i.e. 11:25pm or 23:25) format according user settings [dateformatter settimestyle:nsdateformattershortstyle]; ns

swift - Can we stop or remove animation effect on focus with UIButton and give other border effect tvOS -

in below delegate function trying did'nt desired result override func didupdatefocusincontext(context: uifocusupdatecontext,withanimationcoordinator coordinator: uifocusanimationcoordinator) { if (context.nextfocusedview == self) { coordinator.addcoordinatedanimations({ () -> void in self.animationdidstop(caanimation(), finished: true) }, completion: { () -> void in }) } else { // handle unfocused appearance changes coordinator.addcoordinatedanimations({ () -> void in self.animationdidstop(caanimation(), finished: true) }, completion: { () -> void in }) } context.nextfocusedview?.layer.shadowoffset = cgsizezero context.nextfocusedview?.layer.shadowopacity = 0.9; context.nextfocusedview?.layer.shadowradius = 0; context.nextfocusedview?.layer.shadowcolor= uicolor.orangecolor().cgcolor context.previouslyfocusedview?.layer.shadowopacity = 0;

PHP not exiting loop -

im trying return data php based on time. ie if current time greater publish time post data should sent user else should told that's scheduled.. problem if condition met still executes loop , gives 'success' result.any idea how overcome this? $sql = "select posts.post_title,posts.author_name,posts.publish_date,posts.post_content,comments.name,comments.comment,comments.time_posted " . "from posts left join comments " . "on posts.id=comments.post_id " . "where posts.id=$data->id " . "limit 5"; $result = mysql_query($sql) or trigger_error(mysql_error() . $sql); $count = mysql_num_rows($result); $index = 0; if ($count >= 1) { $temp = array(); while ($row = mysql_fetch_assoc($result)) { if (strtotime($data->now) > strtotime($row['publish_date'])) { if ($index == 0) { $results[$index]['post_

javascript - Typescript import from .d.ts file -

i wrote (at point) simple components angular2. here's code far: import {component, view} 'angular2/angular2'; export module skapp.core{ @component({ selector: 'sk-app-side-menu' }) @view({ template: ` <p>hello</p> ` }) export class skappsidemenu { menuactive: boolean; constructor(){ this.menuactive = false; } showmenu(){ this.menuactive = !this.menuactive; } } } of course there's no real functionality @ point. that's not point right now. i created own build process gulp. here's relevant part of it: gulp.task('script', ['clean'], function() { var tsresult = tsproject.src() .pipe(ts(tsproject)); return merge([ tsresult.dts.pipe(rename({dirname: ''})) .pipe(concat('sk-app.d.ts')) .pipe(gulp.dest('dist/')), tsresult.js .pipe(rename({dirname: ''})) .pipe(co

Java Refresh the access token to access google api -

when try run command refresh access token , access token value refreshed following error.please tell me how fix it java.lang.nullpointerexception @ com.google.api.client.repackaged.com.google.common.base.preconditions.checknotnull(preconditions.java:191) @ com.google.api.client.util.preconditions.checknotnull(preconditions.java:127) @ com.google.api.client.googleapis.auth.oauth2.googlecredential.<init>(googlecredential.java:320) @ com.google.api.client.googleapis.auth.oauth2.googlecredential$builder.build(googlecredential.java:515) @ demo.newclass2.main(newclass2.java:38) mycode : think because set missing googlecredential,so can't refresh token public static void main(string[] args) { try { string refreshtoken = ""; string clientid = ""; string cliensecret = ""; string p12 = ""; httptransport http_transport = new nethttptransport(); jsonf

scala - could not optimize @tailrec annotated method loop: it contains a recursive call not in tail position -

i have following recursive function want use tail recursion on it. compiler complains implementation error: error:(79, 7) not optimize @tailrec annotated method loop: contains recursive call not in tail position n match { ^ is because of loop assumes it's not in tail position? def dsl[n,e](qnodes:qnodelike[n,e]*) = { val markers = scala.collection.mutable.map.empty[string, n] @tailrec def loop(n:qnodelike[n,e]):unit = { n match { case qnode(head, kids:seq[halfedgelike[e,n]]) => { for(kid <- kids){ kid match { case emptyhalfedge() => case halfedge(e, n) => loop(n) } } } case qnodemarker(head, marker, kids:seq[halfedgelike[e,n]]) => { markers.update(marker,head) for(kid <- kids){ kid match { case emptyhalfedge() => case halfedge(e, n) => loop(n) }

javascript - fuelphp routes to angular routes -

i have routes , request handling mechanism written in fuelphp calculate template in server side. computing templates on server side slower in understanding , covert routes angular routing. most of fuelphp code outputs angularjs views. is there direct or quicker way convert php routes angular routes. try this: in public folder make .htaccess file , fill following <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.html$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.html [l] </ifmodule>

dictionary - Python script to map one string to another string -

i have file called file1.txt contents like: file1.txt python general-purpose, interpreted, interactive, object-oriented , high-level programming language. python developed guido van rossum in late eighties , nineties @ national research institute mathematics , computer science in netherlands. python derived many other languages, including abc, modula-3, c, c++, algol-68, smalltalk , unix shell , other scripting languages. python copyrighted. perl, python source code available under gnu general public license (gpl). i want map string eg. third sentence in file string -"python designed highly readable uses english keywords " . how mapping can done in python? got know dictionary equivalent hashmap in python can dictionary used map 1 string another?? i tried like: f=open("log5.txt") dict = {'f.readline()': 'python designed highly readable uses english keywords frequently'} print(f.readline()) print(dict['f.readline()']) but abov

Julia: How to replace SQLite.Null with NA in DataFrame -

i have sqlite database read dataframe in julia. when values missing, given type sqlite.null, difficult deal with. prefer nas. there easy way conversion? kludgy way follows: using dataframes, sqlite df = dataframe() df[:x1] = [1, sqlite.nulltype(), 3, 4] df[:x2] = ["a", "b", sqlite.nulltype(), "d"] function repnull(x) if isa(x, sqlite.nulltype) return(na) else return(x) end end df[:1] = map(repnull, df[:x1]) df[:2] = map(repnull, df[:x2]) is there more elegant and/or efficient way? i've looked question i'm new julia may have been using wrong terms. the following seems readable , fast. for col in df.columns col[col.==sqlite.null]=na end a curious thing note 'exceptional' behaviour of na under equality. thus, above solution may throw exception if there na s in dataframe (i.e. operation not idempotent).

rest - java client consuming API -

i trying use mail gun api getting bounce mail data. public static clientresponse getbounce() { client client = new client(); client.addfilter(new httpbasicauthfilter("api", "key-xxxxxxxxxxxxxxxxxxxxx")); webresource webresource = client.resource("https://api.mailgun.net/v3/xxxxxxxxxxxx.mailgun.org/" + "bounces/foo@bar.com"); return webresource.get(clientresponse.class);} it works fine api call ok not able convert clientresponse in appropriate type in cae emailerror . actual response server {"address":"a@gmail.com","code":"550","error":"550 5.2.1 email account tried reach disabled. lq5si9613879igb.63 - gsmtp","created_at":"tue, 18 aug 2015 12:23:35 utc"} i created pojo map response @jsonautodetect(gettervisibility = visibility.none, fieldvisibili

CMake compare_files sorted -

in workflow generated files stored source code support ancient build system (which can't fixed , won't go away because reasons). so, cmake build uses cmake -e compare_files ... check wsdl gives same *.h , *.cpp files. kdsoap kdwsdl2cpp generator not producing stable output: order of classes can different invocation invocation. that breaks check. 1 option sort lines of files before comparison. there portable way that? you can write cmake script that: # input variables: file1 , file2. # returns 0 if files same after sort. cmake_policy(set cmp0007 new) file(strings ${file1} v1) file(strings ${file2} v2) list(sort v1) list(sort v2) if(not v1 strequal v2) message( fatal_error "files '${file1}' , '${file2}' not equal." ) endif(not v1 strequal v2) and use command in add_custom_target : command ${cmake_command} -dfile1=${cmake_current_source_dir}/foo.cpp -dfile2=${cmake_current_binary_dir}/foo_generated.cpp -p ${cmake_curren

cassandra - Zeppelin spark RDD commands fail yet work in spark-shell -

i have setup standalone single node "cluster" running following: cassandra 2.2.2 spark 1.5.1 list item compiled fat jar spark-cassandra-connector 1.5.0-m2 compiled zeppelin 0.6 snapshot compiled with: mvn -pspark-1.5 -dspark.version=1.5.1 -dhadoop.version=2.6.0 -phadoop-2.4 -dskiptests clean package i can work fine spark shell retrieving data cassandra i have altered zeppelin-env.sh follow: export master=spark://localhost:7077 export spark_home=/root/spark-1.5.1-bin-hadoop2.6/ export zeppelin_port=8880 export zeppelin_java_opts="-dspark.jars=/opt/sparkconnector/spark-cassandra-connector-assembly-1.5.0-m2-snapshot.jar -dspark.cassandra.connection.host=localhost" export zeppelin_notebook_dir="/root/gowalla-spark-demo/notebooks/zeppelin" export spark_submit_options="--jars /opt/sparkconnector/spark-cassandra-connector-assembly-1.5.0-m2-snapshot.jar --deploy-mode cluster" export zeppelin_intp_java_opts=$zeppelin_java_opts i start