Posts

Showing posts from May, 2010

lucene - Stemming text in java -

this question has answer here: lucene porter stemmer not public 2 answers im searching possibility stemm strings in java. first wanted lucene examples found in web deprecated. (snowballanalyzer, porterstemmer, ...) want stemm whole sentences. public static string stemsentence(string sentence) { ... return stemmedsentence; } how can it? make this: public static string stem(string string) throws ioexception { tokenstream tokenizer = new standardtokenizer(version.lucene_47, new stringreader(string)); tokenizer = new standardfilter(version.lucene_47, tokenizer); tokenizer = new lowercasefilter(version.lucene_47, tokenizer); tokenizer = new porterstemfilter(tokenizer); chartermattribute token = tokenizer.getattribute(chartermattribute.class); tokenizer.reset(); stringbuilder stringbuilder = new stringbuilder(); w

jquery - How do i refresh the html form after successfully updated the data without page refresh -

i've html form updating form data using jquery/ajax method. after updated it's showing "success message". that's fine it's remain form contents. want reload/refresh form / form contents after update done without page refresh. how can ? can guys give solution or idea ? thank you. my jquery code following if need html form upload here. :) <script> $('body').on('click', '#upload', function(e){ e.preventdefault(); var formdata = new formdata($(this).parents('form')[0]); $.ajax({ url: 'editcontactdetails.php', type: 'post', xhr: function() { var myxhr = $.ajaxsettings.xhr(); return myxhr; }, success: function(data){ $("#success").html(data); //alert(response); }, data: formdata, cache: false,

c# - Best way to notify ui what's happening on another thread in wpf? -

i'm using mvvm, , in viewmodel start thread (it server application, connection thread), , i'm looking appropriate way (or ways (!)) notify ui what's happening on thread. way want it, have textbox of sort logs (lines stored in observablecollection probably), , each time happens on connection thread, want new line added textbox. here's how set command (the method starts thread listening connections): public viewmodel() { startcommand = new relaycommand(packethandler.start); } packethandler class: public static void start() { var connectionthread = new thread(startlistening); connectionthread.isbackground = true; connectionthread.start(); } private static void startlistening() { if (!isinitialized) initialize(); try { listener.start(); while (true) { client = listener.accepttcpclient(); // kind of logging here reaches ui

javascript - Getting access to deep nested image -

i have page set out thus: <body> <div class="header_div"> <object width="100%" height="30px" id="header" name="header" data="/cgi-bin/header.pl"></object> </div> <div class="page_div" id="page_div"> <object id="page" name="page" width="100%" height="100%" data="/cgi-bin/page.pl"></object> </div> <div class="menu_div" id="menu_div"> <object id="menu" data="/cgi-bin/menu.pl" width="250px" height="180px"></object> </div> <div class="login_div" id="login_div"> <object id="login" name="login" width="200px" height="300px" data="/cgi-bin/login.pl"></object> </div> within <object> tag of page script called "page.pl"

android - Host-based Card Emulation, any guidance please? -

i'm new field, got nexus s ( cyanogenmod11 = android kitkat 4.4.2) , need use hce (host-based card emulation) mode in order emulate contactless card. any guidance on steps , tips need follow in order accomplish this? ( - need program simulated secure element? put on cloud? ) p.s: have use new reader mode also, because app going read android nfc-enabled phone , not nfc reader. thank you. before cyanogenmod 11, cyanogenmod supported own host-based card emulation functionality. register foreground dispatch android.nfc.tech.isopcda technology , emulate smartcard using isopcda.transceive() method. see nikolay elenkov's blog post on how use api. however, browsing through cyanogenmod 11 source (specifically tht of nfc service) seems functionality has been dropped in version 11 in favor of android 4.4's official hce api. the official android 4.4 hce api permits apps emulate contactless smartcard (iso 14443-4 + iso 7816-4 apdus) in android service. servic

ios - Show Two view controllers on screen using Storyboard, like SplitViewController -

Image
i want show 2 view controllers on screen using storyboard, splitviewcontroller. apple splitviewcontroller not suitable me, because left menu large , need change width, apple doesn't not allow it. how this? thank answers! p.s. app ipad. !for case give try using 2containerview in viewcontroller , embed segue each of them . note have control segues selves check out example container view using container view this example using 1 container view . , can customize code , 2 container views. want try using container view in way have saparate navigation bar left , right viewcontrollers. i had made simple demo :d

database - about indexes created on primary keys referenced as foreign keys in a different table (SQLite3) -

scenario database design follows: people visit matchmakers network each other , propose matches. example, person visits matchmaker x, , person b visits matchmaker y, not equals b , no constraint on x, y i.e. can same or different. create table matchmaker ( id text primary key, address text ); create table people ( id text primary key, name text, gender text, matchmaker_id text, foreign key(matchmaker_id) references matchmaker(id)); create table married_couples ( id1 text, id2 text, foreign key (id1) references people(id), foreign key (id2) reference people(id)); then, faster database access: create index matchmaker_index on matchmaker(id); create index people_index on people(id); my question based on following query generate tuples of matchmaker pairs people they've paired. select a.id, b.id, e.id1, e.id2 matchmaker a, matchmaker b, people c, people d, married_couples e e.id1 = c.id , c.id = a.id , e.id2 = d.id , d.id = b.id; for query above, 2 mat

c - How Do I Attain Peak CPU Performance With Dot Product? -

problem i have been studying hpc, using matrix multiplication project (see other posts in profile). achieve performance in those, not enough. taking step see how can dot product calculation. dot product vs. matrix multiplication the dot product simpler, , allow me test hpc concepts without dealing packing , other related issues. cache blocking still issue, forms second question. algorithm multiply n corresponding elements in 2 double arrays a , b , sum them. double dot product in assembly series of movapd , mulpd , addpd . unrolled , arranged in clever way, possible have groups of movapd / mulpd / addpd operate on different xmm registers , independent, optimizing pipelining. of course, turns out not matter cpu has out-of-order execution. note re-arrangement requires peeling off last iteration. other assumptions i not writing code general dot products. code specific sizes , not handling fringe cases. test hpc concepts , see type of cpu usage can attain. result

javascript - Tell If A Multi-Word String Contains A Word -

goal: (the reason don't think duplicate involves matching start of each word in string, not in string) i'm using javascript/jquery. have sting, is: muncie south gateway project i'm creating live search box, checks input against string each keystroke. i'd return match if input matches beginning of word, not middle. example: mu = match muncie = match unc = no match cie = no match gatewa = match atewa = no match what have i using check: if (new regexp(input)).test(string.tolowercase()) {return '1';} however, matches letters including letters in middle of word. it, examples result: m = match mu = match mun = match muncie = match unc = match // should not match cie = match // should not match gatewa = match atewa = match // should not match question: i know can done breaking string apart separate words , testing each word. i'm not sure how efficient be. there way this? you can use word boundaries make sure given input matches

ios - Swift, add swipe to delete UITableViewCell -

i learning swift ios , making checklist application uitableview . wondering how add swipe delete uitableviewcell . this viewcontroller.swift: import uikit class viewcontroller: uiviewcontroller, uitextfielddelegate, uitableviewdelegate, uitableviewdatasource { var tableview: uitableview! var textfield: uitextfield! var tableviewdata:array<string> = [] // define colors let lightcolor: uicolor = uicolor(red: 0.996, green: 0.467, blue: 0.224, alpha: 1) let medcolor: uicolor = uicolor(red: 0.973, green: 0.388, blue: 0.173, alpha: 1) let darkcolor: uicolor = uicolor(red: 0.800, green: 0.263, blue: 0.106, alpha: 1) let greencolor: uicolor = uicolor(red: 0.251, green: 0.831, blue: 0.494, alpha: 1) init(nibname nibnameornil: string?, bundle nibbundleornil: nsbundle?) { super.init(nibname: nibnameornil, bundle: nibbundleornil) // custom initialization } override func viewdidload() { super.viewdidload() //set table view self.tableview = uitableview

java - What is the input error here? And how do I connect via IP -

i'm trying make simple echo server can basics down code doesn't run properly. prompts port scanner (keyboard) wigs out. can perpetually hit enter without errors breaking program. i've had problem before forgot how fixed then. additionally, i've been having trouble creating client socket inet4address. continually mismatch error saying numbers in ip large. appreciated public static void main(string[] args) { try { system.out.println("port: "); int port = keyboard.nextint(); service = new serversocket(port); clientsocket = service.accept(); input = new bufferedreader(new inputstreamreader(clientsocket.getinputstream())); output = new printstream(clientsocket.getoutputstream()); system.out.println(service.getinetaddress()); while(true) { line = input.readline(); output.println(line); } } catch(ioexception e) { system.out.print

angularjs - dropdown of Navbar is double-clicked. -

the used version following. ・angularjs 1.2.16 ・bootstrap3.1.1 ・angularui bootstratp 0.11.0 var myapp = angular.module('app', ['ngroute', 'ui.bootstrap']); <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">menu</a> <ul class="dropdown-menu" role="menu" aria-labelledby="usermenu"> <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#" class="">one</a></li> <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#" class="">two</a></li> <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#" class="">three

How to save user input and refresh page using Javascript? -

i writing function in js that's form in table (1 row, 3 columns). first cell input box, second 2 buttons. want once user enters text (say country), , clicks "submit", want save value entered in variable, once clicks "refresh", page refreshed country in mind. how write functions saves value , refreshes page? here's code have (some of code answer): function createtable(){ var body = document.body, tbl = document.createelement('table'); tbl.style.width='100%'; tbl.style.border = "0px solid black"; tbl.style.backgroundcolor = "green"; tbl.setattribute("style", "font-size:18px;position:absolute;top:0px;right:00px;"); for(var = 0; < 1; i++){ var tr = tbl.insertrow(); for(var j = 0; j < 3; j++){ if (j == 2) { var td = tr.insertcell(); input=document.createelement("input");

perl bless with fat comma -

i know perl bless can take in 1 or 2 arg stated in perlbless . however, not understand bless fat comma in below code doing? same bless \$value,$class; ? # construct tie. sub tiescalar { $class = shift; $value = shift || 0; bless \$value => $class; } the fat comma way of writing comma . can see : perl -mo=deparse -e 'bless \$value => $class' bless \$value, $class; -e syntax ok an interesting discussion can found here too.

django-debug-toolbar: 'list' does not support the buffer interface -

i made few modifications model, adding image fields , installing pillow, deleteing models or model fields. as site not yet in production, dropped database , re-created it, , synced it. got error. i can't figure out source of sudden error. in settings.py added media_root nothing else. environment: request method: request url: http://localhost:8000/ django version: 1.6.2 python version: 3.4.0 installed applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'backoffice', 'public', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.twitter', 'widget_tweaks', 'rose

asp.net - ASp .net Session variables persistance and modifications -

i using standard session in asp .net store user variables. problem in code change fields in variables fetch session. question is, should do? how should handle variables sure latest changed version stored in session. there kind of mechanism this? you should wrap session value in property read , write property public string myval{ get{ return session["myval"]; } set{ session["myval"]= value; } }

xml - how to design different layouts login form Android for handset and tablet? -

Image
i want know , how design different layouts login form android handset , tablet, image ...? :) your best choice go through these first http://developer.android.com/training/multiscreen/index.html http://developer.android.com/guide/practices/tablets-and-handsets.html http://developer.android.com/guide/practices/screens_support.html how can made layout work in both tablet , phone?

jquery - Fetch value of Dynamic textbox in javascript -

i dynamically creating textbox @ runtime using javascript , passing value servlet page using href(which created @ run time along textbox) somehow value being passed "null". not understanding why..can me on ?? here javascript code : //here creating textbox var td1 = document.createelement("td"); var strhtml1 = "<input type=\"text\" name=\"in_name\" id =\"in_nm\" size=\"18\" style=\"height:24;border: 1 solid;margin:0;\">"; td1.innerhtml = strhtml1.replace(/!count!/g, count); //here fetching value var nm=document.getelementbyid("in_nm");//this value being passed null //here passing through href tag var strhtml3 = "<a id=\"link\" href=\"userhandler?action=insert&&name="+nm+"\">add row</a>"; td3.innerhtml = strhtml3.replace(/!count!/g, count); var dt=document.getelementbyid('in_dt'); you never put html string

javascript - .on() jQuery click function won't work? -

i'm trying implement simple click function jsfiddle isn't working. here javascript/jquery: $(document).on("click", "#intropic", function () { $("#introduction").addclass("hide") $("#q1").removeclass("hide") }); i don't understand because works if take element in question ( #intropic ) out of divs nested in , place @ top of document. isn't solution because ruins html/css formatting. does .on() only work un-nested ids? here jsfiddle - http://jsfiddle.net/josephbyrne/hdpq4/2/ and here amended version #intropic moved top of html - http://jsfiddle.net/josephbyrne/krudm/ your code fine. problem #introduction put behind body element because of z-index:-99 set on #content container of #introduction . clicking on element in #content click on body element. remove z-index , should work fine. the interesting thing here background of body should cover #content happens when specify b

java - New .xhtml pages won't render any jsf tags but previously created ones still work fine in same project -

i have weird , stupid problem has stopped dead. have numerous xhtml pages use forms , work fine. created new xhtml page called registeruser.xhtml. created right clicking on "web pages" folder , selecting new > xhtml page have done other half dozen pages. put in code , when go view page in web browser, shows nothing. if view source, shows jsf tags, not html. if put code or plain text outside of form tags, displays form tag. if take working page , copy/past new page, still not work. here's 1 thing noticed, typically when create c:, h: or f: tag first time in page, error saying not bound, single click on , hit alt-enter , gives me option add something, adds xlmns:h html tag. don't understand how works namespaces...anyway, whatever reason option doesnt show up...the option shows "remove surrounding tag" not fix problem if click it. so no big deal doesnt auto-add xmlns, can add myself, copying have on page...but nope, still nothing. why doesnt work?

java - ANDROID - Populate custom ListView with Database on Fragment -

i have custom listview , database, i'm trying populate listview database, not work. my code: public class mainactivity extends listfragment { public sql mydbhelper; public sqlitedatabase db = null; public list<string> mostrar, mostrar2; adaptadortitulares adapter; public listview list; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // if extending activity view root = inflater.inflate(r.layout.activity_main, container, false); try { mydbhelper = new sql(getactivity()); mydbhelper.createdatabase(getactivity()); } catch (exception e) { } new threadbd().execute(); list = (listview) root.findviewbyid(android.r.id.list); list.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1, int posicion, long arg3) {

Has image downscaling improved in Safari 6 and 7? (5 used to be slightly blurred) -

has image downscaling improved in safari 6 , 7 (5 used blurred)? i tried use browserstack of them safari 5...cant see 7. yes has improved since version 6. remember safari 5 released in 2010. please make sure google searching before asking simpler questions.

c# - Import schemas / procedures from SQL Server 2012 database into LocalDB for unit-testing -

i'm pretty new unit-testing. hope can ideas guys how can solve "problems". here want do: we have sql server 2012 databases. unit-testing in visual studio 2012, want programmatically create localdb has same tables / functions / procedures "normal" databases. but tables in localdb should empty , populated data (only data needed test) in unit-tests (so after every test localdb empty) have @ http://dbsourcetools.codeplex.com/ designed purpose - re-create instance of database locally. point 2012 databases, , script entire database schema disk. can use run these scripts in correct order re-create database. can select data tables include ( config data ).

Android: How to remove fragments from backstack? -

i have situation want clear fragments backstack except 1 visible(i.e. on top) for example, there 4 fragments in backstack a->b->c->d (d on top) now want remove fragments a,b,c backstack. constraint there should not visible effect on fragment d while removing history backstack. this code. fragmentmanager fm = getactivity().getsupportfragmentmanager(); bundle bundle = new bundle(); orderreceiptfragment orderreceiptfragment = new orderreceiptfragment(); bundle.putserializable("orderhistory", orderhistory); orderreceiptfragment.setarguments(bundle); commonutil.clearbackstack(fm); fm.begintransaction().setcustomanimations(r.anim.enter_from_left, r.anim.exit_to_right) .replace(r.id.container, orderreceiptfragment).commit(); method clearbackstack public static void clearbackstack(fragmentmanager fragmentmanager) {

node.js - NodeJS and Express interceptors -

i'm trying code interceptor metrologie purpose. interceptor must called before http query (and before express job) put time informations , after express's job duration of call. i'm trying middleware , it's working fine "before" call not "after" call cause when route found, propagation through other middleware stopped. please provide clues interceptors working in cases. edit : what i'm trying have sort of aop javascript in fact... the 'before' interceptor middleware : // jmc add metrologie informations route called app.use(function (req, res, next) { var name = req.originalmethod + req.originalurl; log.trace('start metroinfo route : %s', name); metro.startmetrologie(name); return next(); }); thank's in advance. if need intercept response consider middleware express-interceptor it's quite easy use , enable respond requests usual.

excel - Ado multiple range select -

i need data excel sheet multiple range rng1 = "[" & sheetname & "$f1:g1000]," rng2 = "[" & sheetname & "$ai1:ai1000]" rng = rng1 & rng2 szsql = "select * " & rng$ & ";" but somthing wrong, how select multiple range copy data? something this, if don't have column headers: szsql = "select [f1], [f2], [f30] [" sheetname & "$f1:ai1000];" where f1, f2 etc indicates field1, field2 , on. if have column headers use in place of f1 , f2.

telerik - jQuery Validation Engine and RadComboBox -

i using jquery validation engine telerik`s radcombobox , not working. works perfect asp:textbox. did use engine radcombobox? myradcombobox webmethod

xml - XQuery or XPath expression explained -

Image
could break down xquery doing? 'for $i in . return count(../*[. << $i])' i can tell loop, confused ../* , [] . in sql code i'm working on. trying extract column-name nodes xml file: select distinct parent.items.value('for $i in . return count(../*[. << $i])', 'int') [index], parent.items.value('local-name(../.)', 'varchar(100)') 'parentitem', parent.items.value('local-name(.)', 'varchar(100)') 'childitem' dbo.myformresults cross apply xmlformfields.nodes('/form/*') parent(items) i want xquery iterate through xml nodes in order in xml file. sort of works, double counts , i'm not sure why... maybe if understand loop better can fix problem. as can see here indexes: 15, 16 , 17 duplicated. thanks! for $i in . a for $x in y return z expression assigns variable $x each item in sequence y in turn , evaluates expression z , returning

xcode instruments - How to load the debug symbol when profiling Swift -

Image
when profile swift code using time profiler not seeing of symbols. see screenshot below: i have editing scheme used profiling app, , have ensured uses debug build configuration, has not solved issue. this should fixed in xcode 6 beta 2. in beta 2 release notes: instruments find symbols when using time profiler ios simulator.

windows - Exporting Entire Registry To Relative Path -

Image
using following code regedit /e c:\output.reg a registry dump file created in c directory. overwrites automatically when file same name exists. when try changing output directory relative path this regedit /e output.reg it wouldn't work. no file created processing takes long usually. code can export whole registry using relative path? like requested, .bat code including debug code: echo %cd% regedit /e output.reg pause command line output: c:\users\username\desktop\new_folder>echo c:\users\username\desktop\new_folder c:\users\username\desktop\new_folder c:\users\username\desktop\new_folder>regedit /e output.reg c:\users\username\desktop\new_folder>pause press key exit . . . folder before (and after) .bat file execution: the syntax of command given in question fine. if supply relative path output file name file created relative current working directory. verified interactive command prompt. whatever going wrong batch script, problem not

plot - How can I set subplot size in MATLAB figure? -

Image
i need plot 10 images together, using code results in small images : img = rand(400,600); i=1:10 subplot(2,5,i); imshow(img); title(['image ' int2str(i)]); end as can see, images not use available space in screen. how can increase size, or decrease padding/margin between them? thanks help. i don't believe there easy way it. there 2 options: first, use position part of subplot: >> subplot(2,5, i, [l, b, w, h]) and calculate left, bottom, width, height. or, handle of returned axis: >> h(i) = subplot(2,5,i); and modify axis afterward. >> set(h(1), 'position', [l, b, w, h] ); there number of pages give more detail, e.g., http://www.briandalessandro.com/blog/how-to-make-a-borderless-subplot-of-images-in-matlab/ [update] the code below gives little more detail on can looking for. tad tedious. 0.95 , 0.02 give little padding. nothing magical. :-) one other thing note encourage use "ii" index var

arrays - Got surprised knowing that C# compiler can infer less informative declaration -

consider following code snippet follow mind chronologically. commented statements cannot compiled. var data1 = new int[3] { 1, 2, 3 }; var data2 = new int[] { 1, 2, 3 }; var data3 = new[] { 1, 2, 3 }; var data4 = new[] { 1, 2, 3.0f }; the simplification done data3 , data4 understandable. int[] data5 = { 1, 2, 3 }; //var data6 = { 1, 2, 3 }; unable infer declaration data6 understandable. var data7 = new int[] { }; //var data8 = new [] { }; //int[] data9 = new [] { }; unable infer declaration data8 understandable. what don't understand why data9 more informative cannot compiled while data10 less informative can compiled. int[] data10 = { }; //var data11 = { }; declaring data11 cannot compiled understandable. the cases there new keyword present, usual expressions can used in context expression required. use them declarations assignment, can used in other contexts, example: return new[] { 3 }; or:

Google Drive indexableText for a video in Python -

i trying add indexable text video in drive. drive sdk docs used patch method. def add_indexable_text(service, file_id, text_to_index): try: file = {'indexabletext': {'text': text_to_index}} updated_file = service.files().patch( fileid = file_id, body = file, fields = 'indexabletext').execute() return updated_file except errors.httperror, error: print 'an error occurred: %s' % error return none i'm not seeing errors in terminal when search in drive metadata text there no results. i've tried waiting while didn't seem help/matter. video says updated when ran script there's something. can provide. update: seems can add indexabletext video once not change afterward. the code looks fine me. try using "try it" function of docs, work? https://developers.google.com/drive/v2/reference/files/patch maybe request went through failed, causes no httperror. what's return

elasticsearch - Combining and with or conditions -

i stuck query has combine conditions. this properties of catalog following _id:integer parentid: integer path: string level: integer i have absolutely no clue how combine them, query returns need. a) _id has 1 of given list ( "_id": ["7","10"] ) or b) parentid has of given integer ( "_parentid": "1" ) or c) path has match special pattern ( "regexp": {"path": "/foobar.*"} ) , level has between 2 integer ( "range": {"level": {"gte": 2, "lte": 3 } } ) additionaly entries have 1 defined catalog i not write down attempts. tried use bool query must , should, not apply c): { "query": { "filtered": { "filter": { "bool": { "must": [ { "type": { "value": "category" } }