Posts

Showing posts from April, 2011

sorting - Drying up Models for Solr Sunspot searchable with Concerns -

i want dry models; sunspot allows one(1) "searchable" block in model. making 2 ignores second one. failed example below: digital.rb class digital < activerecord::base include baseconcerns belongs_to :digitable, polymorphic: true # ignores searchable string :url text :url string :remark text :remark end end base_concerns.rb module baseconcerns extend activesupport::concern included before_create{ self.id = uuidtools::uuid.timestamp_create().to_s.downcase if id.blank? } self.primary_key = 'id' # searchable text :id time :created_at time :updated_at end end end i want dry models using concern , want named columns searchable; while others can specify; how can this?

linux - static route w/ next hop to VPN gets "Network is unreachable' -

ubuntu 14.04, linux kernel 3.13.0-77-generic i have 3 servers a, b, , c. servers , b in same network (rackspace) , server c in network (aws). have vpn connection goes server b vpc server c located in. vpn connection works, can send traffic across server b server c , vice versa. have not been able figure out how route traffic server server c. believe solution add static route on server a, so: $> route add -net 10.0.0.0 netmask 255.252.0.0 gw xxx.xxx.xxx.xxx where xxx.xxx.xxx.xxx private ip address of server b. however, output of command siocaddrt: network unreachable i can ping , route traffic server b server a, assume unreachable network 1 across vpn tunnel. #/ect/sysctl.conf on server b ----------------------------- net.ipv4.ip_forward=1 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.all.send_redirects = 1 net.ipv4.conf.eth0.arp_notify = 1 vm.swappiness = 0 net.ipv4.tcp_rmem = 4096 87380 33554432 net.ipv4.tcp_wmem = 4096 65536 33554432 net.core.rmem_max = 335

reactjs - Fetch not working on React Native Android debug -

i'm trying create simple reactnative app play around graphql , rn on android (i'm familiar getting work on iphone). but i'm running problem -- root component places get request api. although request works when spin xcode simulator, fails when run android version on phone. the android/ios versions identical. 2 index files both use react-native-router-flux , identical, , import shared components. here's simplified code of component: constructor(props) { super(props); this.state = { source: 'mygraphqlendpoint' } } componentdidmount() { if (this.props.drill) { return null; } this.serverrequest = fetch(this.state.source) .then((result) => result.json()) .then((json) => { this.setstate({ drill: json.data.drill }); }); } componentwillunmount() { this.serverrequest.abort(); } render() { const { drill } = this.state; if (!drill) { return null; }

python - Split RDD for K-fold validation: pyspark -

i have dataset , want apply naive bayes on that. validating using k-fold technique. data has 2 classes , ordered i.e. if data set has 100 rows, first 50 of 1 class , next 50 of second class. hence, first want shuffle data , randomly form k-folds. problem when trying randomsplit on rdd, creating rdds of different sizes. code , example of dataset follows: documentdf = sqlcontext.createdataframe([ (0,"this cat".lower().split(" "), ), (0,"this dog".lower().split(" "), ), (0,"this pig".lower().split(" "), ), (0,"this mouse".lower().split(" "), ), (0,"this donkey".lower().split(" "), ), (0,"this monkey".lower().split(" "), ), (0,"this horse".lower().split(" "), ), (0,"this goat".lower().split(" "), ), (0,"this tiger".lower().split(" "), ), (0,"this lion".lower

windows 10 mobile - Is there any way to programmatically back out of an W10m app rather than exiting it? -

application.current.exit() exits app programmatically, need simulate same effect when press out of app, ie suspending it. possible? (yes know shouldn't mess around it's specific purpose) no, it's not possible exit app programmatically without terminating it.

Getting only the words starting with certain characters - autocomplete in jQuery -

i have following code perform auto-completion input. the problem i'm having function if type in "en" returns not words starting "en" (example: english, england, enterprise, etc) word contains string of characters "en" anywhere (example: central, century, calendar, etc) what change need make in code words start characters type in? thanks (function($){ $.fn.autocomplete = function(options){ var o = $.extend({}, $.fn.autocomplete.defaults, options); // public methods if (typeof options == 'string') { this.each(function(){ var = $(this); if (options == 'destroy') { $(window).off('resize.autocomplete', that.updatesc); that.off('blur.autocomplete focus.autocomplete keydown.autocomplete keyup.autocomplete'); if (that.data('autocomplete')) that.attr('autocomplete', that.data('autocomple

c - How can hacker take advantage of array or pointers -

i graduate looking find work have question code security. in java there no out-of-bound arrays , there no pointers suggests java more secure c. in c these out-of-bounds arrays can cause stack corruption or buffer overflow , dangling pointers. in interview may asked "how can hacker take advantages of these?" how go answering this? examples welcome. well, talk heartbleed (there ton of documentation out there). basically, there api call made via network, code request communication keep-alive, like: you: send me "potato", 6 chars. response: potato however, there no check text requested, , length of text sent in aligned, this: you: send me "potato", 512 chars. response potato&&&&#8388325099#((#(#)%#(((#%)password:1234#(%()#%((#%#(#%)(#)(%)(##()jfjfeoijf#)j(jf)(#j)(#j#)(j#))j#.... where responding computer send potato, plus 506 bytes of stack around local variable, contain anything, including passwords, etc. that en

powershell - Error while adding VHD as OS Disk in resource manager -

i trying create vm using existing vhd have on storage blob. ran below command add-azuredisk -diskname "keldc1" -medialocation "https://*****.blob.core.windows.net/essrestore/kel-dc01201611012647.vhd" -label "bootdisk" -os "windows" the error reeived add-azuredisk : badrequest: storage account name ***** specified in vhd uri https://*****.blob.core.windows.net/essrestore/kel-dc01201611012647.vhd not exists in current subscription i verified have subscription correct , storage account in same subscription. help please. you created resources in new portal, executing commands on classic one. try this, azure login azure config mode arm this execute commands on new portal.

r - Data Cleaning for Survival Analysis -

i’m in process of cleaning data survival analysis , trying make individual has single, sustained, transition symptom present (ss=1) symptom remitted (ss=0). individual must have complete sustained remission in order count remission. statistical problems/issues aside, i’m wondering how can go addressing issues detailed below. i’ve been trying break problem apart smaller, more manageable operations , objects, however, solutions keep coming force me use conditional formatting based on rows above , below missing value and, quite frankly, i’m @ bit of loss how this. love little guidance if think know of technique can use, experiment with, or if know of search terms can use when looking solution. the details below: #fake dataset creation id <- c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4) time <-c(0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6) ss <- c(1,1,1,1,na,0,0,1,1,0,na,0,0,0,1,1,1,1,1,1,na,1,1,0,na,na,0,0) mydat <- data.frame(id, time, ss)

javascript - Why is <select>'s attribute 'value' can't be set? -

i've searched web couldn't find answer. know can set value javascript, why can't html? there no valid attribute 'value' 'select' element. see http://www.w3schools.com/tags/tag_select.asp you can set property dom element via javascript, not saying property has valid counterpart in html. edit: better link here: https://www.w3.org/wiki/html/elements/select

deep linking - Integrating Branch.io in Ionic App -

i trying send app's link form website token in link : branch.link({ stage: 'new user', data: { token: 543322 }}, function(err, link) { console.log(err, link); }); then when app installed user after clicking on link, want token register user. tried reading branch.io docs , implementing it's not working. can tell me example how make work? code in app controller this (():void => { 'use strict'; angular .module('xyz') .controller('abc', abc); function abc ( $window ) { let vm = this; $window.branch.setdebug(true); $window.branch.initsession().then(function (res) { console.log(res); alert('response: ' + json.stringify(res)); }).catch(function (err) { console.error(err); alert('error: ' + json.stringify(err)); }); $window.branch.getfirstreferringparams().then(function (res) { // success callback

html - Angular Headers Fixed -

i trying make table on angular page fixed headers , footers. <table class="table table-bordered table-striped table-hover" fixed-header> <thead> <tr> <th>name</th> <th>amount</th> <th>id</th> </tr> </thead> <tbody> <tr class="info" ng-repeat="item in ctrl.items track $index"> <td> <input type="checkbox"/> <a>{{item.displayname}}</a> </td> <td> {{item.marketvalue}} </td> <td> {{item.positions}} </td> </tr> </tbody> <tfoot> <tr> <td>name</td> <td>amount</td> <td>id</td> </tr> </tfoot> </table> i have demo of angula

Migrating from jboss 4.2.3 to jboss 5.1.0 getting spring related errors -

getting below error while migrating through jboss 4.2.3 jboss 5.1.0. jboss 5.1.0 not able load spring configuration files. additionally have removed below errors creating object explicitly using new keyword in java class instead of using spring dependency injection “viewchactionhelper'”. and able resolve errors getting @ time of server startup. able see login page when click on login button calls action i.e. loginaction in creating object of service class through setter getter dependency injection in case throwing nullpointerexception . i believe there problem in loading spring configurations. any appreciated. org.springframework.beans.factory.beancreationexception: error creating bean name '/buildclient' defined in servletcontext resource [/web-inf/action-servlet.xml]: initialization of bean failed; nested exception org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'com.northstar.wms.cpm.ui.client.viewchaction

xml - How does match works in xsl template? -

i have xsl this: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" version="1.0"> <xsl:template match="wsdl:definitions"> <!-- code here --> </xsl:template> </xsl:stylesheet> in xsl , line do: <xsl:template match="wsdl:definitions"> from understanding going strictly match wsdl:definitions tags <wsdl:definitions> in given xml (correct me if i'm wrong here). but literally confused moment, give input xml: <xxx:definitions xmlns:xxx="http://schemas.xmlsoap.org/wsdl/" xmlns:xxxx1="http://www.w3.org/2006/05/addressing/wsdl" > </xxx:definitions> it still matches <xxx:definitions> , transform

objective c - Non-modular header inside framework module -

i creating cocoapod (framework) in swift needs import 3rd party objective-c framework. however, when adding #import <thirdpartyframework/thirdpartyframework.h> umbrella file of cocoapod, following error: include of non-modular header inside framework module 'mycocoapod' i tried setting allow non-modular includes in framework modules yes did not resolve error. the thirdpartyframework.h header has bunch of imports of other headers: #import <thirdpartyframework/header1.h> #import <thirdpartyframework/header2.h> ... i can't edit framework since it's 3rd party. there can use 3rd party framework in swift cocoapod? can not modularize header need import? i've read here library owner needs move imports .m file, not library owner. also, i'm using swift , library in objective-c don't have .m files, why have import in umbrella file. using xcode 7.3

primefaces - update <p:tab only in jsf page -

this question has answer here: how stay on same tab if field evalution failed 1 answer <p:tab title="temperature analysis" rendered="#{!userbean.user.temperaturenotallow}"> <p:outputpanel id="temperatureanalysispanel" > <h:form style="margin-left: 800px"> <h:outputtext value="select y-axis range"></h:outputtext> <h:panelgrid columns="5" cellspacing="9"> <h:panelgrid columns="1" style="margin-left: 0px"> <h:outputtext id="displayrange" value="between #{generatordatalogbean.minrangefortemp} , #{generatordatalogbe

EC2 Amazon High Availability Always On -

i using web & db instances in aws ec2 , want make them high available, if 1 server fails (primary server), 1 turned on (secondary server). i have found lots of information rds high availability not ec2 instances not rds. could please provide me links guide of how doing it? could please tell me in words process should in order achive high availability? thanks. the question should ask - how make application ha on aws, not how make ec2 ha. , short answer must tell aws how define , deploy application first. in case of rds, abundantly clear application - database server of choice. @ basic, aws can setup ha instance of rds default settings without input you. however, in case of application, need give aws more details. there several ways this: create elb bunch of ec2 instances in different availability zones create elb auto-scaling group lead down path of creating ami , launch configuration ; in mode, can tell asg use elb health check determine when ec2 in

PHP: Convert while loop in array -

how convert below result array? want make array can assign variable , use it if($handle = opendir($path)){ while(false != ($filename = readdir($handle))) { if($filename != "." && $filename != ".."){ $name = preg_replace("/\\.[^.\\s]{3,4}$/", "", $filename); $name = str_replace('_', ' ', $name); $name = ucwords($name); echo $name; } } closedir($handle); } simply add names array.... $files = array(); if($handle = opendir($path)){ while(false != ($filename = readdir($handle))) { if($filename != "." && $filename != ".."){ $name = preg_replace("/\\.[^.\\s]{3,4}$/", "", $filename); $name = str_replace('_', ' ', $name); $name = ucwords($name); $files[] = $name; } } closedir($

postgresql - How do I prevent sql alchemy from inserting the None value to field? -

the alembic migration script : def upgrade(): uuid_gen = saexp.text("uuid generate v1mc()") op.create_table( 'foo', sa.column('uuid', uuid, primary_key=true, server_default=uuid_gen), sa.column( 'inserted', sa.datetime(timezone=true), server_default=sa.text("not null now()")) sa.column('data', sa.text) ) this base class sql alchemy: class foo(base): __tablename__ = 'foo' inserted = column(timestamp) uuid = column(uuid, primary_key=true) data = column(text) it has static mehtod insert : @staticmethod def insert(session, jsondata): foo = foo() foo.data = jsondata['data'] if 'inserted' in jsondata: foo.inserted = jsondata['inserted'] if 'uuid' in jsondata: foo.uuid = jsondata['uuid'] session.add(foo) return foo the purpose of 2 if's simplify testing. wa

How to use TabIndent method for a word file using PHP COM -

i using php com export contents database word document. want left indent in word document using tabindent method. in vba is: selection.paragraphformat.tabindent(2) https://msdn.microsoft.com/en-us/library/office/ff839143.aspx i want use same method in php com not working. code below: $word = new variant(com_get_active_object("word.application")); $word->selection->paragraphformat->tabindent(2);

php - Laravel 5: Error: "Driver not found" while migrating the database(mysql) in laravel -

it's been around 5-6 hours since i've been trying use database in laravel 5. i've gone through of videos , confused me lot. i have created model , migration when try migrate gives me [ pdoexception ] driver not found i've made numerous changes .env , database.php nothing works. i using laravel 5 xampp server. kindly help thank .env file app_env=local app_debug=true app_key=zzfvju3bkjxmlkbl5gsvj3ymkivhbgnq db_connection=mysql db_host=localhost db_port=3306 db_database=medicaldb db_username=root db_password= cache_driver=file session_driver=file queue_driver=sync mail_driver=smtp mail_host=mailtrap.io mail_port=2525 mail_username=null mail_password=null mail_encryption=null database.php file <?php return [ 'fetch' => pdo::fetch_class, 'default' => env('db_connection', 'mysql'), 'connections' => [ 'sqlite' => [ 'driver' => 'sqlit

c# - Save data records and use it again without querying again into database -

i have 2 control, search button , export button. user 'search' data , data inserted datatable , bound gridview or repeater, , when user click export, datatable passed class generate excel file using data inside datatable. in current code, search button , export button both query fetch data database. need search button query, , store data datatable or something, , when export button clicked use earlier data generate excel file. here current code: report.aspx <asp:gridview id="gridview1" runat="server"> <columns> </columns> </asp:gridview> </body> report.aspx.cs protected void page_load(object sender, eventargs e) { /* page load */ } protected void btn_search_click(object sender, eventargs e) { datatable dt = getdata(); gridview1.datasource = dt; gridview1.databind(); } protected datatable g

how to stop receiving location update in google map android -

i making location tracking application. put 2 buttons stop , start, on start button click receiving location update enable, on stop button click stop receiving location update. but stop receiving location update not working. package com.jaygandhi.tracking; import android.manifest; import android.content.intentsender; import android.content.pm.packagemanager; import android.location.location; import android.os.bundle; import android.support.v4.app.activitycompat; import android.support.v4.app.fragmentactivity; import android.support.v7.app.appcompatactivity; import android.util.log; import android.view.view; import android.widget.button; import android.widget.toast; import com.google.android.

How to use shared variable in Laravel PHP -

class xyzcontroller extends controller { public $a; public function index(request $request){ $input =request::all(); print_r($input); $this->a =$input; return view('page_name', compact('array_name')); } public function abc(){ print_r($this->a); } } my code in laravel looks this. it's not working. want use variable in function abc() initialized in function index(). here variable $a public type , initialized in function index() $this->a =$input; , accessing in function abc() print_r($this->a); can not call function index() in function abc() it's returning other pages, while function abc returning other pages different index(). can correct me goes wrong in accessing variable $a in function abc() or can suggest me better way access $a in function without using global variable? do this: class xyzcontroller extends controller { public function index(reques

CrossOver in Matlab -

i ask how performe crossover in genetic algorithm using matlab. let suppose have following 2 sequences, sequence1 = 1 2 3 7 9 10 5 4 6 8 sequence2 = 4 3 9 2 1 7 6 10 8 5 now know how make code perform crossover in matlab such new child sequence cross-overed either @ single-point or two-point , result has no repetition of number in child sequence. regards, with 1 point crossover have unique points in range 1..numel(sequence)-1 . n unique numbers can use randperm . 2 point crossover bit more difficult, total number of unique combinations sum of arithmetical progression 1..numel(sequence)-2 . here example of single point crossover: function [result] = crossoveratpoint(sequence1, sequence2, point) result = [sequence1(1:point-1), sequence2(point:end)]; end function [result] = crossoversinglepoint(sequence1, sequence2, number) len = numel(sequence1); % calculate length points = randp

javascript - email validation function not working properly -

i have made function validate email using pattern. function not validating it. please , post ur answers in detail possible. thank you. function getemail(data){ var pattern= /^([a-z][a-z0-9\.]+[a-z0-9])@([a-z][a-z0-9\-]+[a-z0-9])\.([a-z]{2,})(\.[a-z]{2,})$/; if (data==="") { console.log("email-id cannot empty!"); } else if(pattern.test(data)===false) { console.log("enter valid emailid"); } else { var email= "<p>"+data+"</p>"; return email; } } function validation() { var regemail = /(.+)@(.+){2,}\.(.+){2,}/; //regex pattern email validation //email textbox validation if (regemail.test($('#<textboxid>').val())) { alert('entered email id correct'); } else { alert('please enter valid email address');

Files are getting corrupted when download using ftp in java -

files getting corrupted when trying pull compressed files. here code have used. not able understand going wrong. format of files .zip , inside has xml files. after downloading remote server,xml files tags changed , looks corrupted. public boolean pullconfirmationsftp(string host, string sftpusername, string sftppwd, string sftpport, string fromconfirmationdirectory, string archiveconfirmationdirectory, string todirectory) { try { // new ftp client ftpclient ftp = new ftpclient(); // try connect ftp.connect(host); // login server if (!ftp.login(sftpusername, sftppwd)) { ftp.logout(); log4j.error("authentication failed"); } int reply = ftp.getreplycode(); // ftpreply stores set of constants ftp reply codes. if (!ftpreply.ispositivecompletion(reply)) { ftp.disconnect(); } // enter passive mode ftp.enterlocalpassivemode(); // system name // sy

c# - WPF MVVM Change GUI after clicking Item -

i try visualize rss feed. have created 2 objects: feedchannel , feedelement . feedchannel may contain feedelement s. this feed may have multiple channels, displayed this: <grid> <scrollviewer> <listbox itemssource="{binding feed, isasync=true}" x:name="listfeed"> <i:interaction.triggers> <i:eventtrigger eventname="mouseleftbuttonup"> <i:invokecommandaction command="{binding channelclickcommand}" commandparameter="{binding elementname=listfeed, path=selecteditem}" /> </i:eventtrigger> </i:interaction.triggers> <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <grid horizontalalignment="stretch" verticalalignment="stretch">