Posts

Showing posts from February, 2012

Java's Enumeration translated to C# IEnumerator -

in practice seems simple i'm getting confused it. java's enumeration hasmoreelements() , nextelement() methods related work differently c#'s ienumerator movenext() , current() properties of course. how translate this?: //class declaration, fields constructors, unrelated code etc. private vector atomlist = new vector(); public int getnumberbasis() { enumeration basis = this.getbasisenumeration(); int numberbasis = 0; while (basis.hasmoreelements()) { object temp = basis.nextelement(); numberbasis++; } return numberbasis; } public enumeration getbasisenumeration() { return new basisenumeration(this); } private class basisenumeration implements enumeration { enumeration atoms; enumeration basis; public basisenumeration(molecule molecule) { atoms = molecule.getatomenumeration(); basis = ((atom) atoms.nextelement()).getbasisenumeration(); } public boolean hasmoreelements() {

algorithm - Tic-Tac-Toe Strategy - 60's MiniVac 601 Logic -

tic-tac-toe seems solved problem space, 100% solutions seem search through finite tree of possibilities find path winning. however, came across computer-simulation toy 60's, minivac 601. http://en.wikipedia.org/wiki/minivac_601 this 'comptuer' consisted of 6 relays hooked solve various solutions. had game section, had description on program tic-tac-toe, claims unbeatable long minivac went first. since solutions seem require lots of memory or computational power, surprising see solution using computer of 6 relays. haven't seen algorithm before, not sure can figure out. attempts solve on pad , paper seem indicate easy win against computer. http://www.ccapitalia.net/descarga/docs/1961-minivac601-book5&6.pdf "with program, mini vac can not lose. human opponent may tie game, can never win. because of decision rules basis of program. the m in iv c programmed machine move 5 squares right of own last move if , if human opponent has blocked la

svn - Why does git only have 1 workspace? -

compared subversion can start many workspaces. why can't git repository have more 1 workspace switching branches doesn't necessitate restitution of state before throwing away current branch. if i'm frustrated svn checkout, blow away , start new one. in git, want maintain local repo (and haven't pushed remotely) can't clone new repo. with git, there couple of ways handle this: git stash store working copy temporary area allow switch branches without having committed. git stash apply lay changes down. 2 work in push/pop stack-style mechanism. possible keep multiple stashes , apply arbitrary stash, wouldn't recommend it. throwing out code little easier: git reset --hard head clear working state , revert last head in current branch you're working on. equivalent deleting working copy , checking out again.

algorithm - Haskell Recursion - finding largest difference between numbers in list -

here's problem @ hand: need find largest difference between adjacent numbers in list using recursion. take following list example: [1,2,5,6,7,9]. largest difference between 2 adjacent numbers 3 (between 2 , 5). i know recursion may not best solution, i'm trying improve ability use recursion in haskell. here's current code have: largestdiff (x:y:xs) = if (length (y:xs) > 1) max((x-y), largestdiff (y:xs)) else 0 basically - list keep getting shorter until reaches 1 (i.e. no more numbers can compared, returns 0). 0 passes call stack, max function used implement 'king of hill' type algorithm. - @ end of call stack, largest number should returned. trouble is, i'm getting error in code can't work around: occurs check: cannot construct infinite type: t1 = (t0, t1) -> (t0, t1) in return type of call of `largestdiff' probable cause: `largestdiff' applied few arguments in expression: largestdiff (y : xs) in first argument of `max',

google apps script - Why doesn't the javascript return and display text? -

in html , code.gs have page asking select date , try display calendar title event on date screen. here html: <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/redmond/jquery-ui.css"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script> <div class="container" > <div> <h1>welcome page</h1> <p>please select date below.</p> <p>click here: <input type="text" name="date" id="datepicker" /><p> </div> </div> <div id='test'></div> <script> $("#datepicker").datepicker(); $("#datepicker").on("change", function () { var dateselected = $(this).val() var displaytext = google.script.run.li

powershell - Check if user is a member of the local admins group on a remote server -

the user member of ad security group "domain\sql admins", , security group "domain\sql admins" member of local administrators group on windows server. i have tried following powershell script: $u = "username"; net localgroup administrators | {$_ -match $u} this script return user if added directly admin group. have cycle through of groups in admin group until find user? or there way? check out article, boe prox on microsoft hey scripting guy blog. describes how check if user local administrator or not. http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/11/check-for-admin-credentials-in-a-powershell-script.aspx this article points test-isadmin function posted onto technet gallery. http://gallery.technet.microsoft.com/scriptcenter/1b5df952-9e10-470f-ad7c-dc2bdc2ac946 the function contains following code, returns $true or $false . ([security.principal.windowsprincipal] [security.principal.windowsidentity]::getcurrent()

Grails Email Plugin Unit tests -

i used grails email plugin send email in grails project. however there no information how unit test in document. are there idea how unit test out? thanks. i use greenmail plugin ( http://grails.org/plugin/greenmail ). receive emails sent application (once configured) , can inspect greenmail's 'inbox' test.

Huge dictionary Python not working -

i have big dictionary in python . . . isn't compiling in coderunner or in xcode i have list that's not big i'm trying translate isn't working correctly because dictionary big . . 23124 keys in dictionary . is there way process large dictionaries creating database or ? when copy , paste dictionary coderunner or in xcode, colors not change different types of elements strings or integers. when run this, larger output input #d_ens_g = {"big" dictionary w/ >20k keys , values} def simple_reader(input,output='test.txt'): temp = [] query=open(input,'r').read().split('\r') q in query: print d_ens_g[q] test_2 = '~/desktop/list.txt' simple_reader(test_2) every element in list import in test_2 has particular id in keys of dictionary do need large dictionary? presumably pulling data file. need dictionary? real database might smarter joran says

php - Undefined variable in object -

i querying database define variables: $sth = $this->db->prepare( "select user_id users user_email = :user_email ;" ); $sth->execute( array( ':user_email' => $email_query ) ); $result = $sth->fetch(); however, when try use variable in function, returns $result->user_email undefined . $this->mp->createalias( $result->$user_email ); // $this->mp defined elsewhere select user_id, users user_email = :user_email your sql invalid, remove comma after user_id. select user_id users user_email = :user_email it's best use pdoexception. (e.g): try { $sth = $this->db->prepare(" select user_id users user_email = :user_email "); $sth->execute(array( ':user_email' => $email_query )); $result = $sth->fetch(pdo::fetch_assoc); } catch(pdoexception $e) { echo $e->getmessage(); var_dump($e); } the reason $user_email

Batch file to zip Apache Tomcat for windows file names that do not equal to today -

we have number of apache tomcat windows logs - example.. server.log.2014-02-04-10 server.log.2014-02-04-11 server.log.2014-02-04-12 server.log.2014-02-05-13 server.log.2014-02-05-14 server.log.2014-02-05-15 these defined file extension of .yyyy-mm-dd-hh , default apache has them date: .yyyy-mm-dd however, have define hh breakover because of system usage , other reasons. trying simple.. if file extension not equal today, archive (zip) up.. here have , no matter shows: 2014-02-05 though script showing .2014-02-04. here script , not sure if need setlocal enabledelayexpansion.. rem http://www.dostips.com/dttipsstringmanipulation.php#snippets.replace setlocal enabledelayedexpansion /f "skip=1" %%x in ('wmic os localdatetime') if not defined mydate set mydate=%%x set today=!mydate:~0,4!-!mydate:~4,2!-!mydate:~6,2! rem today=%mydate:~0,8% %%i in (d:\11\*.*) ( set filetime=%%~xi rem set dt=!filetime:~0,11! rem if not "!fldt!" == ".!today!" (

terminal - In Python, what does pydoc do? -

new programming , python altogether. in book i'm learning from, author suggested find out purpose of pydoc. i did google search on it, , found match (from gnome terminal) didn't make sense me. mind simplifying bit? thanks. pydoc / documentation module python. use on windows terminal understand function in python : python -m pydoc <function> eg. python -m pydoc raw_input if documentation particular function long, use 'q' out of it. e.g. in case of python -m pydoc tkinter

c# - Get Folder Path -

i want path of folder textbox , name of folder images12345 . tried this. //inside folder "images12345" string[] pics = { "1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg", "7.jpg", "8.jpg" }; int = 0; then in form load //i tried given me wrong path textbox1.text = path.getfullpath(@"images12345"); //then slideshow picturebox1.image = image.fromfile(textbox1.text+"/"+pics[0]); timer1.enabled = true; timer1.interval = 5000; = 0; first, use application folder plus images folder: string applicationpath = path.combine(appdomain.currentdomain.basedirectory, "images12345"); second, use path.combine work paths: picturebox1.image = image.fromfile(path.combine(myfolderpath, pics[0])); note you'll need copy images folder executable is. that's bin/degub while you're debugging. can navigate 2 folders up, must implement like in produc

python - Why does this input to int does not work properly? -

i'm trying solve in python , not sure why isn't working... x = int(input("enter value of x: ")) y = int(input("enter value of y: ")) print(y) input("...") the problem y. input follows without quotes: "2 * x" have tried lot of things , researched lot (as before asking) stumped here. perhaps it's because i'm such basic user. seems reading books python2, have installed python3. in python2, input equals eval(raw_input(prompt)) , that's why when input 2 * x , evaluates value of expression , assign y . in python3, input user input strings, not eval expression, may need explicitly eval , a bad practice , dangerous : in [7]: x=2 in [8]: y=eval(input('input y:')) input y:3*x in [9]: y out[9]: 6 all in all, use: raw_input in py2, input in py3, never use eval (or input in py2) in production code.

node.js - SIP Redirect via Proxy (SIP.js) -

i'm trying create minimal sip proxy serves 1 purpose: redirects requests domain. catch domain i'm redirecting requires authorization assume need rewrite sip attributes since sip authorization based partly on domain name of destination. i've tried issuing 302 redirect proxying , changing values of each sip request none seem quit trick. i'm using node.js library (sip.js) , have tried redirect , proxy modules ( https://github.com/kirm/sip.js/blob/master/doc/api.markdown ). any ideas how need modify sip data redirect requests domain , enable authentication take place against other domain? below basic node script got working own sip server. you'll need replace credentials , ip address fro own testing. the proxy script not send redirect response client instead initiates new transaction server on client's behalf. sip server operating in mode more correctly called back-to-back user agent (b2bua). haven't added functionality needed, such matching ,

Ruby on Rails Bundler activeadmin gem install error -

i running issues when trying install activeadmin gem. using ruby 2.0 , rails 4.0.2. here when run "bundle install" in project directory: c:\users\samuel\desktop\rubyonrailsworkspace\groupsrailsprojectnew>bundle install dl deprecated, please use fiddle updating git://github.com/gregbell/active_admin.git fatal: failed open '/cygdrive/c/users/samuel/desktop/rubyonrailsworkspace/gro upsrailsprojectnew/c:/ruby200-x64/lib/ruby/gems/2.0.0/cache/bundler/git/active_a dmin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca/objects': no such file or directory retrying git clone --no-checkout "c:/ruby200-x64/lib/ruby/gems/2.0.0/cache/bundl er/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca" "c:/ruby200-x64/li b/ruby/gems/2.0.0/bundler/gems/active_admin-60d8be97ec2c" due error (2/3): bu ndler::source::git::gitcommanderror git error: command `git clone --no-checkout "c:/ruby200-x64/lib/ruby/gems/2.0.0/cache/bundler/git/active_admin-d67faab65e9b7

jquery - javascript add two multipleevents on input field -

i trying add 2 events on input field onkeyup , onchange, purpose avoid longpress of characters other numbers..as field zipcode. @ present 1 event working either keypress/onchange. adding code refrence appreciated. function zipchange(obj, selector){ var code = obj.value; var isnum = /^\d+$/.test(code); if(!isnum) obj.value=""; }//onchange function autozip(obj, selector){ var code = obj.value; if(code.match(/\d/gi)) obj.value = code.replace(/\d/gi,''); if(code.length>4 && code.indexof('-')== -1){ var substr = code.substring(4); substr=substr.replace(/\d/gi,''); obj.value = code.substring(0,4)+'-'+substr; }//onkeypress //html <input id="pincode" type="text" data-validate="validate[required]" name="address.pincode" required="true" onkeyup="autozip(this)" onchange="zipchange(this)" msg="enter

Lock page fragment in ViewPager android -

how can lock paging in fragment activity of viewpager fragment swipe.i'm performing operations using progressbar in 1 fragment.while progressing progressbar fragment gets changes because of swipe action.so while progessing progressbar want stop swiping.how this?is there solution?? activity.xml file- <android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainfragmentactivity" > <android.support.v4.view.pagertitlestrip android:id="@+id/pager_title_strip" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:background="@drawable/title"

delphi - Draw a pie chart with special properties (alter style and starting point) -

Image
i want create pie chart has features: it's starting point changes 90 degree (like gauge component) it turns clockwise. a fixed marker shows value. donut style. i check pie chart properties. don't found corresponding feature. i have teechart shipped delphi. it's v2011.03.32815. , don't have donut chart. think it's need coded. it' can done placing circle on it's canvas color matches chart background. i can use gauge component. not have anti alias feature (teechart has teegdiplus ). i've drawn illustrator of mean: q1: how draw/code chart so? here have simple example showing how use teechart draw tdonutseries similar 1 in picture. here how looks like: and here code used generate it. it's tdonutseries 2 values , wide pen. , 2 tannotationtools texts: uses tecanvas, teedonut, teetools, series; procedure tform1.formcreate(sender: tobject); var donut1: tdonutseries; annot1, annot2: tannotationtool; tmpx, tmpy: int

sql - How to retrieve values stored in JSON array in MySQL query itself? -

i have following table product_id product_name image_path misc ---------- -------------- ------------ ------ 1 flex http://firstpl... {"course_level_id":19,"group_id":"40067"} 2 android http://firstpl... {"course_level_id":20,"group_id":"40072"} so how can retrieve product_name,image_path & "group_id" value "40067" "misc" column. i tried below query returning 1/0 in misc column. select product_name,image_path,misc regexp '(.*\"group_id\":*)' misc ref_products product_id=1 any idea guys how ? the regexp function returns 0 or 1. have use other string functions. try this: substr(misc,locate('group_id',misc)+11,5) misc . assumes group_id has 5 characters. so better: substring_index(substr(misc,locate('group_id',misc)+char

javascript - Error : missing new prefix when invoking a constructor -

i trying create function in node.js . following relevant code, gives me error when call function. function replaceplaceholders() { return 'success'; } exports.sendmailmsg = function (templatename, receiveremail, dataplaceholders) { replaceplaceholders(); } in node.js, function names camel cased, , should start lowercase character. starting function uppercase character tells jshint consider function constructor rather method. this error being generated jshint, code run correctly. the option in jshint , newcap , causes error depreciated, , disabling recommended. the relevant info why option in jshint: this option requires capitalize names of constructor functions. capitalizing functions intended used new operator convention helps programmers visually distinguish constructor functions other types of functions spot mistakes when using this. not doing won't break code in browsers or environments bit harde

php - Using require once or include to upload multiple scripts in a form -

so have php script handles uploading multiple sites. there 3 sites in all, using same class uploading different api array.. below 1 of scripts handles uploading... class apiupload { private $data; public function __construct( array $data ) { $this -> data = $data; } public function doupload() { $ch = curl_init(); if ( is_resource( $ch ) ) { curl_setopt( $ch, curlopt_url, 'http://example.com/upload_api/' ); curl_setopt( $ch, curlopt_returntransfer, true ); curl_setopt( $ch, curlopt_postfields, $this -> data ); curl_setopt( $ch, curlopt_timeout, 5 ); $data = curl_exec( $ch ); curl_close( $ch ); } if ( empty( $data ) ) { $this -> error = 'an unexpected error occured.'; return; } return $this -> parse( $data ); } private function parse( $data ) { if ( !

jsp - Using sendRedirect - hide parameters -

my problem is: have jsp application play role of tunnel redirect process externel application after gets login cookie. thus, jsp application doesn't contain forms. http://xxxxx:8080/who/app?login=" + userid); ?> told you, xxxxx remote host. when execute process, can see "userid" in url. question here how can hide login url configurutaion described. thank in advance

gooddata - Loading Google Analytics 2 Years historical data via API using CC Rest connector -

i wondering if there way pull google analytics un-sampled historical data 2 years via api using cc rest connector component. unfortunately ga account standard , not premium can not around 500k limit. it great if gooddata developer team can share etl graph file solve request. common use case per clients. thanks, andy i have discovered kind of solution . run ga_00_master graph run multiple time ga_01_sub graph . each day want have data send request google analytics , gives file data day. there few things do fill in ga_connection sub graph and link parameter file ga_params.prm and parameters for master graph: ga_min_date = "yyyy-mm-dd" for sub graph: profile_number

xml - how to select elements when the root element has a lot of attributes -

i have following xml: <?xml version="1.0" encoding="utf-8"?> <gbxml version="0.37" usesiunitsforresults="true" volumeunit="cubicmeters" areaunit="squaremeters" lengthunit="meters" temperatureunit="c" xmlns="http://www.gbxml.org/schema" xsi:schemalocation="http://www.gbxml.org/schema xsi.xsd" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <campus id="cmps-1"> <location> <name>trois-rivieres, pq canada</name> <latitude>46.210000</latitude> <longitude>-72.350000</longitude> </location> </campus> </gbxml> i want select "latitude" value. using below xpath expression not returning anything: <p><code><xsl:value-of select="gbxml/campus/location/latitude"/></code></p> i new in xpath, appreciate if me this you have default

How can I make this function loop with javascript? -

function argstoarray(args) { var r = []; (var = 0; < args.length; i++) r.push(args[i]); return r; } argstoarray(document.getelementsbytagname('img')).foreach(function(img) { img.src = img.src.split('vtlibolte8ycb').join('x0x810d0' + math.floor((math.random()*10)+1));; }); i tried adding setinterval(argstoarray,500); @ end seem have broken things. this quite archaic , crash browser, experiment might work. function reloadpage() { location.reload(); } setinterval(reloadpage,.5); i assume using native foreach you're targeting ie9+, instead of manually pushing collection contents array just: function argstoarray(args) { return array.prototype.slice.call(args) } the rest of code looks workable, maybe there's wrong split() or join() arguments. please explain trying achieve here. adding setinterval(argstoarray,500) call first function without arguments, should use anonymous function or pass arguments setinte

java - making an android activity run without ui -

i have startingactivity on google-glass i want run silently, meaning run, communicate server, get , send data - user won't see app. the user see static card time time, but can in context of app. my tries: i have thought create service instead of startingactivity,but there many things relays on main ui views if comment out setcontentview(), code refers view.findviewbyid() fail. no? , besides user see black screen instead of silent run desire. any other solution silent run, yet running startingactivity fully?

sql - Need unique value of a column while combining two tables -

this question has answer here: simulating group_concat mysql function in microsoft sql server 2005? 9 answers i'm getting 2 columns 2 different tables using sql server 2005.. used following query.. select [mhd].jobpostingid, [c].candidatename candidate c right join memberhiringdetails mhd on [mhd].memberid=[c].id it returns following data: jobpostingid candidatename 60 aaa 60 bbb 63 aaa null means, candidate erased table.. need output follows: jobpostingid candidatename 60 aaa, bbb 63 aaa how this..? if need stored procedure means, ok.. need solution.. agreed mahmoud gamal, duplicate. extracted post , changed tables: select c.name, stuff((select ','+ c.candidatename candidate c c.id = mhd.memberid

tfs2010 - TFS 2010 Can we set workflow for a work item field other than "State" field -

my requirement below . 1) items have ‘step’ field value of “code review” , ‘test group’ field value “uat only”, selection in ‘step’ field drop down “code review”, “unit test”, or “uat” 2) items have ‘step’ field value of “code review” , ‘test group’ field value “sit , uat”, selection in ‘step’ field drop down “code review”, “unit test”, or “sit” both "step" , "test group" user defined field. how acheive above scenario. can set workflow uder defined field "step" that sounds new sequence of items. start if step environment. add activities particular environment. workflow complex. this decent article on how this. (blog discussion items: overview; default template vs. upgrade template; template parameters. multiple build definitions using 1 template ) http://blogs.msdn.com/b/brandonhawbaker/archive/2011/03/25/team-foundation-server-2010-team-build-workflow.aspx expect spend lot of time on this. if have never done before it's hel

sql - Increase performance of SELECT * FROM # ORDER BY # ASC LIMIT # OFFSET #; -

basically, want effective , fast lazy loading sorted list on web page hsqldb. current sql query ineffective , slow: select o human o order o.firstname asc limit 500k offset 50; could increase performance of it? domain object: @roojpaactiverecord public class human { @notnull @column(name="firstname") string firstname; @notnull @column(name="lastname") string lastname; } sql table: id, firstname, lastname, version add index on firstname column , ready go (if gonna sort only/first firstname). of course depends on database. mysql see this page .

android - notifyDataSetChanged not working -

Image
my app uses multicolumnlistview ( https://github.com/huewu/pinterestlikeadapterview ) , name says helps creating multi column list views. the library great, specify, filtering not supported. so trying create own text-filter functionality simple edit text. finally achieve filter list need refresh listview , recall setadapter because pass list on it. myadapter adapter = new myadapter(this,mylist); listview.setadapter(adapter); when execute listview.invalidateviews() or adapter.notifydatasetchanged() listview refreshed old list. which best way of recalling setadapter? or maybe way of doing this.. thanks in advance edit: //method filters list log.i("on filter mylist.size()",""+mylist.size()); adapter.notifydatasetchanged(); //on adapter log.i("on adapter mylist.size()",""+mylist.size()); log: adapter class: public class miadaptadorlistacomercios extends baseadapter{ //textview , imageviews declarations priva

python - OPENERP: ValidateError Error occurred while validating the field(s) arch: Invalid XML for View Architecture -

i'm new programming openerp 7.0, when import module openerp gives me error:validateerror error occurred while validating field(s) arch: invalid xml view architecture!. i`m not locate error. grateful if me. thanks. _ init _.py # -*- encoding: utf-8 -*- import tipos_acceso_kaicen _ openerp _.py { "name" : "tipos acceso kaicen", "version" : "1.0", "author" : "kaicen", "category" : "gestionar tipos de acceso", "website" : "http://www.kacien.es", "description": "podremos dar de alta los tipos de acceso de los que disfrutarán nuestros socios", "depends" : ["base"], "init_xml" : ["tipos_acceso_kaicen_view.xml"], "demo xml" : [], "update_xml" : ["tipos_acceso_kaicen_view.xml"], "active": false, "installable": true, "data": ["tipos_acceso_kaicen_view.xml&q

c++ - MS VC++ 9 pcrecpp.lib linking error -

just built pcre-8.34 ms vc++ under windows x86, copied libs (pcrecpp.lib) , headers (pcrecpp.h, pcrecpparg.h, pcre_stringpiece.h) locations , wanted test simple code (that works under gnu linux c++) i'm getting linking errors: #define pcre_static 1 #include <pcrecpp.h> #include <iostream> #pragma comment(lib,"pcrecpp.lib") using namespace std; int main(void) { pcrecpp::re regex("(hello)"); std::string strbase = "hello hello hello"; pcrecpp::stringpiece input(strbase); std::string match; int count = 0; while (regex.findandconsume(&input, &match)) { count++; std::cout << count << " " << match << std::endl; } } building output: c:\documents , settings\administrator\desktop\coding\pcre>cl.exe /md /ehsc /o2 pc.cpp microsoft (r) 32-bit c/c++ optimizing compiler version 15.00.21022.08 80x86 copyright (c) microsoft corporation. rights reserved. pc.c

javascript - AngularJS: Share factory between multiple modules -

let's have module called app injects 2 other modules called factories , controllers : var app = angular.module("app", ["factroies", "controllers", "directives"]) .run(function ($rootscope, userfactory) { userfactory.property = "somekickstartvalue"; }); the factories module holds factories: var factories = angular.module("factories", []), factory = factories.factory("testfactory", { property: "somevalue" }); and controllers module holds controllers: var controllers = angular.module("controllers", ["factories"]), controller = controllers.controller("controller", function ($scope, testfactory) { console.log(testfactory.property); // returns "some value" , not // "somekickstartvalue" expected. }); the actual question: why "somekickstartvalue" not apply controllers? far unders

asp.net mvc - How to Implement OWIN and Katana in MVC 5Application -

i upgrade application mvc4 mvc5. using entity framework code first approach in application. confuse owin , katana. how implement these concept in web mvc5 application. please guide me. thank you asp.net mvc not designed work owin. it's asp.net web api , signalr built owin , provide specific host. cannot implement concepts in asp.net mvc application.

.htaccess - Using htaccess to show files from an inner directory -

this local dir structure -> app -> settings -> readme -> php -> entire app code now since app code in php/ dir, have localhost/app/php access app. access files in php/ dir justing typing localhost/app . thanks :) put code in document_root/.htaccess file: rewriteengine on rewriterule ^((?!php/).*)$ php/$1 [l,nc]

android - Can SQLite be used for online databases? -

i new topic question seem primitive people. know if can use sqlite offered in android access online databases rather create own offline database? any appreciated! no, sqlite local, embedded databases. to access databases on network need use whatever api offered, such web service api used on http(s).

Remove few HTML Tags while pasting the data from the clipboard in Tinymce -

i'm using tinymce 2.2 , need remove few html tags while pasting data in tinymce textarea. i have data in format: <div id="testid"> abcd </div> on paste event, when use window.clipboarddata.getdata("text") to data, "abcd" , need whole data <div id="testid"> abcd </div> where , how can whole htmldata in tinymce? use tinymce.get('your_textarea_id').getcontent(); ref : http://www.tinymce.com/wiki.php/api3:method.tinymce.editor.getcontent

hibernate - Hibernate3 many to many cascade deleting with cleanup -

i have problem cascade deleting in hibernate 3.6. have following many many relationship between 2 entity classes: menu , item. note uni-directional relationship. menu instance has reference set of items has. item instances not know menu instances belongs to. @entity public class menu { @id private long id; @manytomany(cascade = {cascadetype.all}) @jointable( name = "menu_item", joincolumns = {@joincolumn(name = "menu_id")} inversejoincolumns = {@joincolumn(name = "item_id")}, ) private set<item> items = new hashset<item>(); .... } @entity public class item { @id private long id; private string name; private string code; ... } my requirement: row in item table should exist in database if @ least 1 menu entry refers it. is, item not belong menu should not exist in database. now, assume following scenario, menu1 has [item1, item2] menu2 has [item1]

jsf - Jboss + EL - interpret null Integer as null instead of 0 -

i discovered el interpret null integer object 0 . how achieve problem? found can use system property org.apache.el.parser.coerce_to_zero didn't (as far know works tomcat use jboss). i use jboss 6.0.1 ga, jsf 2.1.

Vanishing webfonts in Google Chrome and WordPress 3.8 -

Image
i'm experiencing weird issue google chrome 32.0.1700.107 m on windows 7 64bit (but similar issue reported friends on mac , 32bit w7). fresh wordpress 3.8 couple plugins, default 2014 theme active, no caching enabled. in dashboard (menu item icons, metaboxes icons) , on front-end have set use webfonts (fontawesome icons or google webfont text/headings) chrome lost rendered , display content default font until hover cursor on text "lost" font, , chrome re-render text in webfont font. so, load page, go other tab, something, 1st tab , webfonts disappear, squares fontawesome icons , arial/helvetica/sans-serif regular text. you'll understand mean when on screenshot. as far know, part of this bug in chrome. it's supposed ready ship in next update.

php - Laravel takes server IP to load files and link URLs instead of accessing the requested URL -

my laravel site hosted on ip redirecting url. problem index page loads css, js , images being loaded ip , not url. internal links going ip. laravel creating urls based on host ip instead of taking request url acount. eg: suppose host ip website 1.2.3.4/xyz , url access sub.abc.com/xyz if load sub.abc.com/xyz page opens js css , images coming 1.2.3.4/xyz instead of sub.abc.com/xyz , links going 1.2.3.4/xyz/contact instead of abc.com/xyz/contact i using laravel's methods make these urls note: xyz folder being proxypassed ip ok laravel irc chat got know problem server configuration. thinking on configuration guess happening , causing problem we type sub.abc.com/xyz should go abc.com-->sub-->xyz folder request url sub.abc.com/xyz but in folder there no website files instead request(proxypassed) made location 1.2.3.4/xyz should folder xyz on 1.2.3.4 request url becomes 1.2.3.4/xyz so when comes laravel @ 1.2.3.4/xyz, request url 1.2.3.4/xyz , not sub

python - 'long' object has no attribute 'fetchall' -

i don't know wrong in code; working fine after database migration (sqlite3 mysql) no longer working. (i using mysql). traceback: file "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) file "/usr/lib/python2.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view 23. return view_func(request, *args, **kwargs) code: cursor = connection.cursor() data = cursor.execute(query) data_list = data.fetchall() return redirect("http://www.example.com?code=123" , code=302) result_count = len(data_list) if result_count==0: return httpresponse('<script type="text/javascript"> alert ("try again"); window.location.href = "/reports/custom/";</script>') data_desc = data.description j=0

java - Inserting schema Programmatically -

we have enterprise application based on spring-java offers each user(one corporation) own database.so when new user (corp.) registers give location of database (a postgresql) , need make blank database filled our schema , our data. ques: i need automate process of inserting schema in database programatically. how think should it: create procedure execute commands related inserting schema provided database not sure plausible way. are such kind of process can perform apis of database connectors? i'm afraid not. please people share thoughts, in advance you might want have @ flyaway , liquibase http://flywaydb.org/ http://www.liquibase.org/ both of these tools support creating schema scratch (run scripts) or running subset of scripts on existing database move version version b.

math - In JavaScript, why ( Number.MAX_VALUE - 1) < Number.MAX_VALUE always evaluate to false? -

in javascript , number.max_value represents maximum representable numeric value (which approximately 1.79e+308 , pretty big number) however, if evaluate (number.max_value - 1) < number.max_value in javascript console, returns me false . if use multiplication, works thought : (number.max_value * 0.99999) < number.max_value returns true maybe missing something, possible explanation ? the reason although allowable number range very large, precision of js number (ieee 754 double precision) insufficient represent every possible number in range. doing require 308 digits! hence max_value - 1 indistinguishable max_number .

ruby - Check if string contains only permitted characters -

the task: identifiers must contain @ least 1 non-digit , contain digit, letter, "_", , "-" characters. therefore 'qwerty', 'identifier-45', 'u_-_-', '-42-' valid identifiers. and '123456', 'w&1234', 'identifier 42' invalid. can achieve regular expression. id.match(/\w\d/) or more 1 match id.match(/\w/) && id.match(/\d/) or may make array of permitted characters , filter original string removing them (if rest more [], there forbidden ones)? id.to_a.select{|character| !((0..9) + (a..z) + ['-','_']).include?(character)}.count == 0 i.e. permitted characters excluded string, , if length more 1, there forbidden characters (like & ) using positive lookahead: pattern = /^(?=.*\d)[-\w]+$/ pattern =~ 'qwerty' # => 0 pattern =~ 'identifier-45' # => 0 pattern =~ 'u_-_-' # => 0 pattern =~ '-42-' # => 0 pattern =~

How to limit the number of results in jQuery autocomplete? -

this question has answer here: limit results in jquery ui autocomplete 11 answers i have searched enough, not able find solution this. please me out. i have table has around 700 records, , want autocomplete display not more 5 records in result. should have scroll bar. unfortunetely there no bulit in property set max limit. can use: $("#autocmplt").autocomplete({ source: function(req, response) { var results = $.ui.autocomplete.filter(myarray, req.term); response(results.slice(0, 5));//for getting 5 results } }); working demo

c# - Windows Phone - How can I center all items in a WrapPanel? -

i'm using wrappanel itemspaneltemplate of listbox.the items in control wrap this: |1234567 | |890 | i'd them wrap this: | 1234567 | | 890 | i found link wpf - how can center items in wrappanel? exemple wpf (i don't find frameworkpropertymetadata , frameworkpropertymetadataoptions).

php - Stub for formal parameter passed by reference in PHPSpec/Prophecy -

i have method in php looks this: <?php class someclass { public function isentitledtodiscount(guestmodel $who, $onwhat, &$discountamount = null) { $discountamount = 10; return true; } } is there way stub $discountamount in phpspec? let's have class i'm testing, , i've injected $someservice via constructor. in spec use: <?php $someservice->isentitledtodiscount($guest, $ticket, $discountamount)->willreturn(true); which creates stub method return value. how can $discountamount formal parameter? a method shouldn't modify arguments (shouldn't have side effects). getter-type method. you should rethink design. your problem related prohpecy, might want read docs: https://github.com/phpspec/prophecy prophecy (and phpspac) make things hard . in cases means you're trying take wrong turn design . you try following, don't think you'll reference variable: $someservice->isentitledtodiscount(

android - How to remove fragment when I rotate my tablet -

i have 2 fragments called action bar of activity. both gridviews, first 1 displays application list dedicated adapter, , second 1 displays file list adapter. problem when launch file when activity switch 1 fragment another, when come previous one, content disappears. , when rotate tablet have problem, because fragment restart think removing fragment give possibility create new fragment date. how can manage update content of first fragment while coming second 1 ? , how remove fragment after rotation in order recreate action new fragment? code of activity given code below: public class launchactivity extends activity { public static activity launch; private pageradapter mpageradapter; menu menu; public static boolean updated = false; private static final string tag = "launchactivity"; public static string path2; public static string[] mmenu; public static string file_name = "seconde"; public static string teacher_file =