Posts

Showing posts from April, 2015

scala - Generically adding implicits to both TreeSet and TreeMaps -

i want add helpful implicits both mutable , immutable treemaps , treesets in scala. here attempt: first try define least upper bound of treemap , treeset has headoption / lastoption (from gentraversablelike ) , from / to / until (from sorted ): type sortedcollection[a, repr <: sortedcollection[a, repr]] = collection.generic.sorted[a, repr] collection.gentraversablelike[a, repr] write util: implicit class richsortedcollection[a, repr <: sortedcollection[a, repr]](s: sortedcollection[a, repr]) { def greaterthanorequalto(a: a): option[a] = s.from(a).headoption def lessthan(a: a): option[a] = s.until(a).lastoption def lessthanorequalto(a: a): option[a] = s.to(a).lastoption } this works partially: sortedset#greaterthan compiles treemap#greaterthan not. how fix it? treemap[a, b] (transitively) extends gentraversablelike[(a, b), treemap[a, b]] , sorted[a, treemap[a, b]] , it's a: sorted[a, treemap[a, b]] gentraversablelike[(a, b), treemap[a,

sql server - Database/Application Design for Group-able Entity -

just want ask input what's best database/application design following scenario i have table called computers each products can grouped following: vendor (e.g. 'sony', 'apple','hp'), type (e.g. 'laptop','personal desktop','server') size (e.g. 'small','medium','large')` more things come business requirement changes (maybe touchscreen in future) these computers can grouped repairers when 'pc repairers' can fix small personal desktops , small laptops 'better computers' can fix all sony computers 'repair less' can fix all hp servers not large as can see there may chances things can overlapped small sony laptops can fixed both 'pc repairers' , 'better computers' what term kind of database design? not know how search online would love hear answers ! thanks i don't know of name kind of design you're describing. might call

angularjs - Webservice Call using Angular in MVC -

can 1 please explain how can call action using angular in mvc project? i managed call action using ajax this: var app = angular.module('toprightsec', ['ng']); app.controller('nationalityctrl', ['$scope', function ($scope, $http) { $scope.items = []; var items = populatelistfromlocalstorage("offices", "login/getoffices", 24); var officelist = ""; (var = 0; < items.length; i++) { $scope.items[i] = { "name": read_prop(items[i], 'office_desc'), "guid": read_prop(items[i], 'office_guid') }; } $scope.reloadpage = function () { window.location.reload(); } $scope.getresult = function ($index, item) { $.ajax({ type: 'get', async: true, url: 'login/changeoffice', contenttype: "application/json; charset=utf-8", datatype: "json", data: { officeid: $scope.i

python 2.7 - import error; no module named Quandl -

i am trying run quandl module on virtualenv have uninstalled packages pandas , quandl, i running python 2.7.10 - have uninstalled other python versions, still giving me issue of 'importerror: no module named quandl'. know might wrong? thanks try lower case, import case sensitive , it's below: import quandl did install pip? if ensure quandl among listed installed modules with pip list otherwise try help('modules') to make sure installed properly. if don't see quandl listed , try reinstall.

Stream Audio from PC to Phone(Android) using SCO over Bluetooth -

on phone: // configure audio: bluetoothaudio = (audiomanager)this.getsystemservice(context.audioservice); bluetoothaudio.mode = mode.incall; bluetoothaudio.bluetoothscoon = true; bluetoothaudio.startbluetoothsco(); on pc: public byte[] audiobytedata { get; set; } public int streamstartposition { get; set; } public int streamendposition { get; set; } public streamaudio(byte[] audiodata) { this.audiobytedata = audiodata; audiotimer.elapsed += audiotimer_elapsed; audiotimer.interval = 20; audiotimer.enabled = true; audiotimer.start(); } private void audiotimer_elapsed(object sender, system.timers.elapsedeventargs e) { throw new notimplementedexception(); } according documentation have read, article: creating audio applications bluetooth example, sending byte chunks on period of time, way 'stream' if audio on bluetooth: in mp3 application, suppose device sending mp3 stream file encoded @ 128 kbit/sec , 48 khz sample frequency. means mp3 audio frame 384 bytes

BASH, How do you repeat a command if a user response is No? -

here talking how script jump first echo statement if no selected, thanks? echo "please enter input: " read input_variable echo "you entered: $input_variable" read -r -p "is correct? [y/n] " response case $response in [yy][ee][ss]|[yy] do_something ;; *) {return first line - echo "please enter input: "} ;; esac wrap prompts in while loop break out of once input confirmed: while :; # same as: `while true; do` - keep looping until exited `break` echo "please enter input: " read -r input_variable echo "you entered: $input_variable" read -r -p "is correct? [y/n] " response case $response in [yy][ee][ss]|[yy]) break ;; esac done do_something note not n , input other matched case handler cause loop remain active.

javafx - Tic Tac Toe Program -

i have tictactoe game , instructor wanted make wild tic tac toe. user needs able select if want x or o whenever. unsure of how this. have buttons need assign them actions, can please me out , how can make them play again? here tictactoe class. thank in advance. import javafx.application.application; import javafx.stage.stage; import javafx.scene.scene; import javafx.scene.control.label; import javafx.scene.layout.borderpane; import javafx.scene.layout.gridpane; import javafx.scene.layout.pane; import javafx.scene.paint.color; import javafx.scene.shape.line; import javafx.scene.shape.ellipse; import javafx.scene.control.button; import javafx.scene.layout.stackpane; import javafx.scene.layout.vbox; import javafx.scene.layout.hbox; import javafx.geometry.pos; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.application.platform; public class tictactoe extends application { private char whoseturn = 'x'; private

devise - Migrating passwords from PHP site to Rails site -

i have php site several thousand users using phpass password hashing. i've written new rails site using devise authentication. i'm trying seamlessly migrate users on new rails site. know way can migrate passwords on new site? i thought simple copying salt over, it's not simple. i found this question/answer, can't figure out phpass salt is, , how use translate passwords devise can understand. any appreciated! reading code, seems encrypt the salt , hash together. you'd have write custom code in ruby mimic hash, salting, , encrypting match password. i take different approach. i use opportunity clean house. i'd import users, , when ready switch over, send out e-mail users you've upgraded security of system, , b/c of need need reset passwords, , provide them one-time link reset passwords.

javascript - How to insert the value of dynamically radio button using PHP? -

i have html table, each table row have radio button dynamically generated. each option in radio button have unique id generated dynamically also. id not yet save in database. how insert option id? , how update option answer in option id? please me. tried insert values have no luck scenario: there's default value radio button, "no". when user change default value, there's confirmation box ask user if he/she want processed. if user click "ok" default value change "yes". php html table: echo '<td id="resumefile'.$optionid.'">' . $record_s->attachment_resume_id . '</td>'; echo '<td id="processedyes><label for="yes">yes</label> <input type="radio" id="processedoptionyes'.$optionid.'" name="processedoption" value="yes" onclick="proccessedcheck('.$optionid.',\'yes\'

Symbolic package is not found by octave (4.0.0) -

i have installed python (2.7.8), sympy (0.7.5) , symbolic package (2.3.0) in octave (4.0.0). in octave did pkg install symbolic-2.3.0.tar (without errors) pkg load symbolic (without errors) and trying use it: >> symbols error: 'symbols' undefined near line 1 column 1 windows 7, 64-bit. package seems in list of installed ones: package name | version | installation directory --------------+---------+----------------------- control *| 3.0.0 | c:\octave\octave-4.0.0\share\octave\packages\control-3.0.0 financial *| 0.5.0 | c:\octave\octave-4.0.0\share\octave\packages\financial-0.5.0 io *| 2.4.1 | c:\octave\octave-4.0.0\share\octave\packages\io-2.4.1 optim *| 1.5.1 | c:\octave\octave-4.0.0\share\octave\packages\optim-1.5.1 signal *| 1.3.2 | c:\octave\octave-4.0.0\share\octave\packages\signal-1.3.2 splines *| 1.2.9 | c:\octave\octave-4.0.0\share\octave\packages\splines-1.2.9 struct *| 1.0.13 | c:\octave\octave

php - Cannot Get My Data From MySQL Android Volley Response -

Image
can me one, i'm stuck login part. can register failed logged in. login.java //login volley request public void loginuser(){ final string useremail = edittextemailaddress.gettext().tostring().tolowercase().trim(); final string userpass = edittextpassword.gettext().tostring().trim(); //response true response.listener<string> listener = new response.listener<string>() { @override public void onresponse(string response) { //json response try { jsonobject jsonobject = new jsonobject(response); boolean recordfound = jsonobject.getboolean("success"); if (recordfound) { //get response server stored temporarily, shared preference //same order php code sequence string uniqueid = jsonobject.getstring("uniqueid"); string usertype = json

ios - How can get the unique id in iPhone -

need 1 unique id app. unique id should never change. when user uninstalls app or kills app should not changed. have searched something, don't need uuid. have decided device token using code: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { if ([[[uidevice currentdevice] systemversion] floatvalue] >= 8.0) { [[uiapplication sharedapplication] registerusernotificationsettings:[uiusernotificationsettings settingsfortypes:(uiusernotificationtypesound | uiusernotificationtypealert | uiusernotificationtypebadge) categories:nil]]; [[uiapplication sharedapplication] registerforremotenotifications]; } else { [[uiapplication sharedapplication] registerforremotenotificationtypes: (uiremotenotificationtypenewsstandcontentavailability| uiremotenotificationtypebadge | uiremotenotificationtypesound | uiremotenotificationtypealert)]; } return yes; } - (void)application:(uiap

php - Auto Suggest search implementation -

Image
i working on content oriented website, have implement web search, thinking of auto suggest search, this: how can done? want suggestions followed search term in image, using lamp stack. suggest me methods implement this. here steps: write php code take search keywords , return results in json format create form in html on every key stroke in search box take search keywords , make ajax request search code made in step 1 now display search response received in josn format http://www.bewebdeveloper.com/tutorial-about-autocomplete-using-php-mysql-and-jquery

parsing - Is there an email server that can do a REST POST to my end point when an email is received? -

i have application has requirement attach links emails client records in application. i need email server - in addition behaving email server, rest post application end point notifying application new email , needs provide atleast id of email (the id can open pop-up browser in application , view email) , subject on email. i have evaluated number of inbound parsing solutions either don't give me control pass authentication information or post of type json, , not basic form post. have evaluated following: http://sendgrid.com http://www.email2db.com http://mailparser.io/ http://mandrill.com/ any mail server, atleast popular mtas postfix, sendmail allow pipe email through stdin program. once have mail content in program, can magic. ( have requirement of parsing every incoming mail, updating database , leaving copy of mail in mailbox reference , through perl script )

javascript - How to find distance only between two places with Google Map API? -

i new use api. basically developing widget calculate freight between 2 places, need compute distance there no need of showing map. if 1 has simple explanation please share me. i have gone through this link not able identify part of code need use finding distance only. you can use geometry computedistancebetween() var placea = new google.maps.latlng(-33.873, 151.13); var placeb = new google.maps.latlng(-33.92, 151.05); console.log(google.maps.geometry.spherical.computedistancebetween(placea, placeb)); reference: https://developers.google.com/maps/documentation/javascript/geometry#sphericalgeometry

javascript - React.js not working -

Image
i've been trying react.js getting started when run example code happens here code you have typo in script tag, you're saying scipt

uistoryboard - Why separator inset value affecting table header title offset in iOS? -

in storyboard, have separator inset value set custom(left = 30) uitableview. moves tableview separator line right 30. in addition, shifting tableview header title text 30 such separator line , header text left aligned each other. how can change separator line offset without affecting offset of headertitle text? why separator offset affecting header title offset?

windows - Batch File Store Line Variables And Sum Them Up -

my input file count.txt contains following: ] /count 1 ] /count 2 i trying add numeric characters @ end of each line , store file or store variable. not able following batch file script: setlocal enabledelayedexpansion set count=0 /f "tokens=3 delims= " %%i in ('findstr count count.txt') ( set /a count=%%i + %count% echo !count! > finalcount.txt ) endlocal the output getting 2. please help. try this: @echo off &setlocal enabledelayedexpansion set count=0 (for /f "tokens=3" %%i in ('findstr "count" count.txt') ( set /a count+=%%i echo !count! ))> finalcount.txt

java - How to fix Solr serach result distortion in almost same queries? -

Image
here solr field type <fieldtype name="company_name" class="solr.textfield" positionincrementgap="100"> <analyzer type="index"> <tokenizer class="solr.standardtokenizerfactory"/> <filter class="solr.stopfilterfactory" ignorecase="true" words="stopwords.txt" /> <filter class="solr.lowercasefilterfactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.classictokenizerfactory"/> <filter class="solr.stopfilterfactory" ignorecase="true" words="stopwords.txt" /> <filter class="solr.lowercasefilterfactory"/> </analyzer> </fieldtype> if need find documents in field company_name equal "abibas sports", queries fq=company_name:abibas sport , fq=company_name:a

Pull select form options from database in Django -

i'm making simple 2-page website allow user use dropdown boxes or html select forms (make, model, trim) on front page information car stored in database. after pressing search button, user taken page provides information vehicle. i'm confused how go linking these dropdown boxes data database in django. the car model have resides in models.py of cardetails app , looks far: class car(models.model): make = models.charfield(max_length=50) model = models.charfield(max_length=50) trim = models.charfield(max_length=50) # other info here. # return actual name of car instead of "model-object" def __str__(self): return self.make + " " + self.model + " " + self.trim googling led me way of setting modelform, resides in forms.py of homepage app: from django import forms cardetails.models import car class carform(modelform): allcars = forms.modelchoicefield(queryset=car.objects.all()) of 3 dropdown boxes have

openstack - How to include or wrap the file or file content or file object when using Softlayer Object Storage REST API -

i using softlayer object storage rest api. told below command line using curl has been successful. $ curl -i -xput -h "x-auth-token: auth_tkabcd" --data-binary "created testing rest client" https://dal05.objectstorage.softlayer.net/v1/auth_abcd/container2/file10.txt i wish upload files using javascript have no clue how wrap file in request. please provide example? lot of thanks. here ideas , examples can you: cors how consume restful service using jquery javascript rest client library [closed] https://ricardo147.files.wordpress.com/2012/08/image001.png however, there customer not able make rest request through javascript. investigate it, let know news. (softlayer, open stack swift) how solve cross domain origin object storage api?

database - Multiple self-referencing foreign key -

i want create mapping table this: mis_report_struc_main ( m_id nvarchar2(3) not null, m_name nvarchar2(200), main_head nvarchar2(3), sub_head nvarchar2(3), tot_head nvarchar2(3), sub_tot_head nvarchar2(3) ); where m_id primary key , main_head , sub_head , tot_head , sub_tot_head self-referencing foreign keys. please me write sql. if should not possible, explain why. here example select * mis_report_struc_main t left outer join mis_report_struc_main t_mh on t.main_head = t_mh.m_id left outer join mis_report_struc_main t_sh on t.main_head = t_sh.m_id left outer join mis_report_struc_main t_th on t.main_head = t_th.m_id left outer join mis_report_struc_main t_sth on t.main_head = t_sth.m_id

c# - Monitor Wait for caching,... it this a good practice? -

i wrote code, , found out there issue monitor.wait, forcing me operation within locks, wanted if way keep thread waiting,.... i'm not sure if thread.join job, there lots of threads running within application, , each specific job, may terminate within time... here code: public static class taskmanager { private static readonly object updatelock = new object(); private static readonly object waitlock = new object(); private static readonly liaisondb _db = new liaisondb(); private static list<liaqueue> _liaqueuelist = new list<liaqueue>(); private static datetime _lastupdate = new datetime(); public static liaqueue gettask(string sessiontype) { liaqueue task; lock (updatelock) { if (_lastupdate < datetime.now.addseconds(-5)) { thread t = new thread(updatecache) {isbackground = true}; t.start(); lock (waitlock) {

android - RecyclerView not updating after adding when data was empty -

i'm facing strange problem when using recylerview inside linearlayout inside cardview. works when initial data i'm passing adapter/recyclerview not empty. when try add item dynamically (when initial data empty), adapter set's items, call's notifydatasetchanged, recyclerview stays empty. if add data dynamically, when initial collection not empty, works perfectly. it's working on other views well. idea problem be? thanks in advance! the xml file: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> </data> <linearlayout android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:orien

sql - Select multiple rows into a single row -

i have table columns "sequence-id", "event-id", "value" to 1 sequence belongs 5 events , each event has 1 value e.g.: |sequence-id | event-id | value | |------------|----------|-------| |1 | 1| 7| |1 | 2| 2| |1 | 3| 5| |1 | 4| 9| |1 | 5| 12| |2 | 1| 15| |2 | 2| 8| |2 | 3| 10| |2 | 4| 21| |2 | 5| 17| how can select each sequence 1 row, separated semicolon? |sequence-id |value | |------------|-------------| |1 |7;2;5;9;12 | |2 |15;8;10;21;17| use string_agg(col1) select sequence-id , string_agg(value , ';') newvalue table group sequence-id;

Implementing an RMI system in Java - no such object in table -

i trying implement simple rmi system in java using 3 pairs of client/servers. createdrecord test method now. client code: public class managerclient { public static void main(string[] args) { try{ system.setsecuritymanager(new rmisecuritymanager()); clinicserverinterface mtlserver = (clinicserverinterface)naming.lookup("rmi://localhost:2020/mtl"); clinicserverinterface lvlserver = (clinicserverinterface)naming.lookup("rmi://localhost:2021/lvl"); clinicserverinterface ddoserver = (clinicserverinterface)naming.lookup("rmi://localhost:2022/ddo"); mtlserver.createdrecord("asdf", "asfa", "asda", "as", "asd"); }catch(exception e){ e.printstacktrace(); } } } server code: public class clinicserver implements clinicserverinterface { private int port; private string location; public clinicserver(int port, string location){ this.port = port; this.loc

Should I use different HDD for Cassandra commit log and data? -

i started learning apache cassandra. in conf/cassandra.yaml noticed commitlog setting's comment following: commit log. when running on magnetic hdd, should separate spindle data directories. if not set, default directory $cassandra_home/data/commitlog. does mean should store commitlog in different hdd data ? if yes, what's reason behind this? , happen if don't comply. thanks. that recommendation days of spinning-disk. due log-based storage engine, cassandra dependent on disk i/o. recommended have commit log , data directories on separate disks avoid potential bottleneck (latency) due heavy disk activity. if using solid state drives (ssds, , cassandra should be) don't need worry this. note: why using nas or san cassandra considered anti-pattern.

typescript - Cannot load angular2 app correctly on Plunker -

plunker 1 fails following error: zone.js:323 error: error: xhr error (404 not found) loading http://run.plnkr.co/xaktrrlcpilcbysj/node_modules/rxjs/index.js(…) plunker 2 fails other error: angular2-polyfills.js:349 error: cannot read property 'prototype' of undefined(…) i'm stuck , no idea on how proceed... can help? you getting http 404 error the 404 or not found error message http standard response code, in computer network communications, indicate client able communicate given server, server not find requested. web site hosting server typically generate "404 not found" web page when user attempts follow broken or dead link; hence 404 error 1 of recognizable errors encountered on world wide web. so server not able locate resource "http: //run.plnkr.co/xaktrrlcpilcbysj/node_modules/rxjs/index.js". since response code return server, client can not resolve error. regards, sudhansu

angularjs - handle promises in javascript -

i having trouble when using promise. controller is angular.module('shoppingpad').controller('customerctrl', customerctrl); function customerctrl($scope, customerservice){ $scope.addcustomer=function() { alert("inside add customer function"); var customer={ name: $scope.name, number: $scope.number }; customerservice.addcustomer(customer).then(function(response){ console.log(response); }, function(error){ console.log(error) }); } this service angular.module('shoppingpad').service('customerservice', customerservice); function customerservice($q, $http,restservice) { //this deferred object resolve or resolve promise var deferred = $q.defer(); //a function add customer data backend used service.it takes customer object paramater. this.addcustomer = function(customer) { return restservice.postrequest('customer

c# - How to access a child window inside a main window in White Framework -

Image
i using white framework ui automation in windows desktop based application. not able find way access child window. uiaverify depicts properties of window as: below code reference: public class program { application app = application.launch("path application"); public program() { //getting main window window mainwindow = app.getwindow("mainform", initializeoption.nocache); mainwindow.waitwhilebusy(); **//here wanna child window can access controls on window. below code getting child windows controls** //getting firm box textbox firm = childwindow.get<textbox>(searchcriteria.byautomationid("1313948")); //setting value firm firm.setvalue("firm2"); //getting staffid text box textbox staffid = childwindow.get<textbox>(searchcriteria.byautomationid("723272")); staffid.setvalue("staff"); button ok = chi

maven - failed Jboss6.3 launch -

this difficulty run when tried launch jboss6.3 maven project deployment , whereas launch ok without deployment of project. besides,the project deployed , launched ok on tomcat7.x. the message returned like: failed enable apledi.war. unexpected http response: 500 request { "address" => [("deployment" => "apledi.war")], "operation" => "deploy" } response internal server error { "outcome" => "failed", "failure-description" => {"jbas014671: failed services" => {"jboss.deployment.unit.\"apledi.war\".dependencies" => "org.jboss.msc.service.startexception in service jboss.deployment.unit.\"apledi.war\".dependencies: jbas018733: failed process phase dependencies of deployment \"apledi.war\" caused by: org.jboss.as.server.deployment.deploymentunitprocessingexception: org.jboss.as.server.deployment.deploymentun