Posts

Showing posts from April, 2013

Partial string matching in R -

this question has answer here: regular expression in base r regex identify email address 2 answers i trying remove 'bad' email addresses csv. have column of emails "abd@no.com," "123@none.com," "@," or "a". there wide range of email formats want try find , remove them all. my inital idea strictly @ end of email string - "@..." part. @ length of character, if email of length 1 or 2 not valid. if have list of bad emails, want generate new list of emails bad ones replaced na. below code have far not work , looks exact matches on pattern, not end of string. email_clean <- function(email, invalid = na) { email <- trimws(email) # remove whitespace email[nchar(email) %in% c(1,2)] <- invalid bad_email <- c("\\@no.com", "\\@none....

javascript - Angular how to set a model inside a factory service for use in a controller? -

is possible (and idea) set model (scope vars) in factory service? for example, have factory defines model below how can init in controller? (function () { 'use strict'; angular.module('services.auth', []) .factory('authorisationservice', function ($rootscope, $http) { // public variables var authservice = { user: { email: '', password: '' } }; return authservice; }); })(); controller: .controller('loginctrl', ['$scope', 'authorisationservice', function ($scope, authorisationservice) { authorisationservice(); }; }]); sure can way, love use service , keep controller clean. take @ demo: var app = angular.module('app', []); app.controller('mainctrl', function($scope, authorisationservice) { $scop...

types - Isabelle: generic datatypes and equivalence -

i'm starting making type generic in isabelle funny error messages once start using parenthesis. theory scratch imports main begin no_notation plus (infixl "+" 65) datatype typea = aa datatype typeb = bb datatype ('a, 'b) generictype = cc | plus 'a 'b (infixr "+" 35) lemma test1 : "x + y ≡ x + y" auto lemma test2 : "x + y + z ≡ x + y + z" auto lemma test3 : "x + (y + z) ≡ x + y + z" auto lemma test4 : "(x + y) + z ≡ x + y + z" lemma test5 : "(aa + aa) + aa ≡ aa + aa + aa" lemma test6 : "(cc + cc) + cc ≡ cc + cc + cc" lemma test7 : "(cc + aa) + cc ≡ cc + aa + cc" lemma test8 : "(aa + cc) + cc ≡ cc + aa + cc" everything fine test1-3, test 4 , 5 result in error: type unification failed: occurs check! type error in application: incompatible operand type operator: op ≡ ((x + y) + z) :: ((??'a, ??'b) generictype, ??...

vba - Outlook Custom Rule for Replying -

i'm getting e-mails through company e-mail server. because of of them coming forwarded mails info@mycompany.com. i'm looking rule when try reply mails reply forwarded e-mail address. thanks. you can create rule in outlook can trigger vba macro procedure. in code can whatever need using outlook object model. should following one: public sub test(mail mailitem) ' end sub where mail object passed parameter represents incoming email. instead of creating rules in outlook may consider handling incoming emails using newmailex event of application class. newmailex event fires when new message arrives in inbox , before client rule processing occurs. can use entry id returned in entryidcollection array call namespace.getitemfromid method , process item. finally, may find getting started vba in outlook 2010 article helpful.

html - Upload issue in MIME type while file open -

i have issue when try upload attachment application. when file still open on computer , try upload it, application/octet-stream mime type instead of application/sword. when close it, there no error while uploading. files have problem excel or word files , stocked in database. configuration of database allows save in binaries , text (depending of file) obviously, fix closing it. understand how/why file uploaded in mime type. edit : browser ie9 (compatibility ie7) , os windows 7. happends on each computer of service. (with same configuration)

clojure - Persisting State from a DRPC Spout in Trident -

i'm experimenting storm , trident project, , i'm using clojure , marceline so. i'm trying expand wordcount example given on the marceline page , such sentence spout comes drpc call rather local spout. i'm having problems think stem fact drpc stream needs have result return client, drpc call return null, , update persisted data. (defn build-topology ([] (let [trident-topology (tridenttopology.)] (let [ ;; ### 2 alternatives here ### ;collect-stream (t/new-stream trident-topology "words" (mk-fixed-batch-spout 3)) collect-stream (t/drpc-stream trident-topology "words") ] (-> collect-stream (t/group-by ["args"]) (t/persistent-aggregate (memorymapstate$factory.) ["args"] count-words ["count"])) (.build tr...

php - $_SESSION variables not passing between files -

i've got login script puts user details session variables. today moved website new host, , coding doesn't work. best can do, , still doesn't work main_login.php: (script above here gets $info database. far working) if($count==1){ session_start(); $_session['username'] = $info['username']; $_session['given'] = $info['given_name']; $_session['family'] = $info['family_name']; $_session['profile'] = $info['profile']; $_session['adultchild'] = $info['adultchild']; $_session['id'] = $info['id']; header("location:welcome.php"); } welcome.php: // check if session not registered , redirect main page. // put code in first line of web page. session_start(); if(!isset($_session['username'])){ header("location:main_login.php"); } the trouble when print of session variables nothing happens. i've tried doing var...

SQL Multiple Join/Sums on Product table -

i have following table containing product sales data chain store group. data big , ugly, way can stores. information table holds 22million records, growing 300k day , growth rate exponentially increase 100% on monthly basis. store_purchases( [id] [int] identity(1,1) not null, [storecode] [int] null, [dtdatum] [datetime] null, [barcode] [varchar](50) null, [desc] [varchar](100) null, [qty] [int] null, [amount] [money] null, [tillslipid] [int] null) the query need pull top 500 products according sum of sales on date range. each of these products need show barcode, description, sum of quantity sold, sum of sale amounts, number of till slips product on, , sum total of products. so far have managed come following. query takes 2m20s execute on server , think "basket sum" value incorrect. know if there better way of doing in single query, or in stored procedure. select a.barcode, a.desc, sum(b.amount) 'basket sum', count(distinct b.tillslipid) 'bask...

mysql - How to count rows by group by and and add this to subquery? -

i need count rows gouped hours , add select subquery, got error on line and date(created_at) = t.day_start , user_id = t.user_id here query: select count(*) ( select hour (call_start_at) hours, count(*) calls calls 1 , user_id = 8 , call_start_at >= '2016-01-06 00:00:00' , call_start_at <= '2016-01-06 23:59:59' group hour (call_start_at) ) t1 and try add select subquery, wrong on marked line t.day_start , t.user_id when changing. here test: select t2.name, t2.calls, round(calling_time * 100 / working_time, 2) percent, t2.calling_time, t2.working_time (select t.name, (select count(*) calls c date(c.created_at) = t.day_start , c.user_id = t.user_id) calls, (select count(*) (select hour(call_start_at) hours, count(*) calls ...

c# - selenium click not firing entire event - behavior is different than user interaction -

i have icon on web app. sending click sleeping bit. icon click opens window. when user clicks on icon, window opened, user controls displayed , populated @ top of page (filter selections) , grid of data displayed. when click issued in selenium test (c# binding if convenient examples or useful in anyway), window opened, filter controls displayed not populated. no grid of data displayed. only testing in ie @ time since our app runs in ie. the new window has javascript errors not experience in regular user execution. app developer asked indicates has seen these errors in debugging has never bothered research them since not affect user experience. does have insight ie web driver implementation might cause or thoughts on how work around it? thanks

java - Lambda expressions and higher-order functions -

how can write java 8 closures support method take argument function , return function value? in java lambda api main class java.util.function.function . you can use reference interface in same way other references: create variable, return result of computation , on. here quite simple example might you: public class higherorder { public static void main(string[] args) { function<integer, long> addone = add(1l); system.out.println(addone.apply(1)); //prints 2 arrays.aslist("test", "new") .parallelstream() // suggestion execution strategy .map(camelize) // call static reference .foreach(system.out::println); } private static function<integer, long> add(long l) { return (integer i) -> l + i; } private static function<string, string> camelize = (str) -> str.substr...

c# - Is it possible to have Thread.Sleep() in a single List<T> ForEach? -

is possible rewrite following code in single statement? foreach(var myvar in varenumerable) { mymethod(myvar); thread.sleep(2000); } without thread.sleep() , would've written as: varenumerable.tolist().foreach(x => mymethod(x)); yup, need curly braces (and whitespace measure): varenumerable.tolist().foreach(x => { mymethod(x); thread.sleep(2000); }); edit: it's been noted in comments on question less efficient plain foreach (due tolist() call), , time add braces , whitespace doesn't cleaner, it's not big win. how can asked for, it's not should :)

Python: why is zip(*) used instead of unzip()? -

given zen of python why zip(*) used unzip instead of function named unzip() ? example transpose/unzip function (inverse of zip)? shows how unzip list. >>> zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)]) [('a', 'b', 'c', 'd'), (1, 2, 3, 4)] how more: beautiful ugly explicit implicit simple complex readable etc. then >>> unzip([('a', 1), ('b', 2), ('c', 3), ('d', 4)]) ? what missing here? you're not unzipping when zip(*your_list) . you're still zipping. zip function can take many arguments want. in case, have 4 different sequences want zip: ('a', 1) , ('b', 2) , ('c', 3) , ('d', 4) . thus, want call zip this: >>> zip(('a', 1), ('b', 2), ('c', 3), ('d', 4)) [('a', 'b', 'c', 'd'), (1, 2, 3, 4)] but sequences aren't in ...

How can we find the Duplicate values in array using php? -

i know, how can detect duplicate entries in array... something $array = array("192.168.1.1", "192.168.2.1","192.168.3.1","192.168.4.1","192.168.2.1","192.168.2.1","192.168.10.1","192.168.2.1","192.168.11.1","192.168.1.4") ; i want number of duplicity used in array (c class unique). 192.168.1.1 = unique 192.168.2.1 = duplicate 192.168.3.1 = unique 192.168.4.1 = unique 192.168.2.1 = duplicate 192.168.2.1 = duplicate 192.168.10.1 = unique 192.168.2.1 = duplicate 192.168.11.1 = unique 192.168.1.4 = duplicate (modified) i tried code style $array2 = array() ; foreach($array $list ){ $ips = $list; $ip = explode(".",$ips); $rawip = $ip[0].".".$ip[1].".".$ip[2] ; array_push($array2,$rawip); } but unable set data in right manner , unable make loop matching data. modified values thanks sam try : give count of each value $array...

html - CSS – link:hover color inheritance issue -

i confused happening here. wondering why link white when cursor within button not directly on link? want red while cursor within button boundaries. think happening because @ point, page inheriting declared .links:a color value, wondering how override that? .links:hover doesn't seem transfer inheritance .links a:hover (?) appreciated!! .links a{ color:white; text-decoration:none; } .links:hover{ background-color:white; color:red; } .links a:hover{ background-color:white; color:red; } https://jsfiddle.net/3dujymlk/1/ your rules working way wrote them. if want a text red while hovering on entire div , need rule that. add this: .links:hover { color: red; } if isn't obvious, controls text-color of link while hovering on div.

c# - VB.net error in designer. -

i getting error message "the class pnlone can designed, not first class in file. visual studio requires designers use first class in file. move class code first class in file , try loading designer again. " code below. copied c# code found. namespace metropanelslide.panel partial public class pnlone inherits pnlslider implements imetrocontrol private sub pnlone_load(sender object, e eventargs) end sub public sub new(owner form) mybase.new(owner) me.stylemanager.update() end sub end class end namespace c# code is: namespace metropanelslide.panel { public partial class pnlone : pnlslider, imetrocontrol { public pnlone(form owner) : base(owner) { initializecomponent(); this.stylemanager.update(); } private void pnlone_load(object sender, eventargs e) { } } } found out issue. thank all. found other class referencing.

monk - Using the value of a MongoDB field to update another field -

i have mongodb document structure this: { testvalue: 10, maxvalue: 20 } i want set testvalue arbitrary integer value between 0 , maxvalue . ideally, this: db.collection.update( {}, { $set: { 'testvalue': newvalue }, $min: { 'testvalue': 0 }, $max: { 'textvalue': $maxvalue } } ) but doesn't work. there handful of threads relate question (e.g. update mongodb field using value of field ), they're few years old, , can't find pertinent information in official documentation. there way want, or have use find() maxvalue separate call database using update()? this still not possible in mongo 3.2 or lower, check example these jira tickets: self referential updates allow update compute expressions using referenced fields

C# WPF and Sqlite: Datagrid displays last table recording when trying to read from an sqlite database table -

i can't figure why data grid displaying last table recording sqlite database. here code i've writen. observablecollection<activity> _activitieslist = new observablecollection<activity>(); while (reader.read()) { _act.name = reader.getstring(reader.getordinal("activity")); _act.customer = reader.getstring(reader.getordinal("activitycustomer")); _act.activitytpe = reader.getstring(reader.getordinal("activitynature")); string st = reader.getstring(reader.getordinal("startedat")); _act.startedat = convert.todatetime(st); string et = reader.getstring(reader.getordinal("finishedat")); _act.endedat = convert.todatetime(et); //string _ratio = reader.getstring(reader.getordinal("activityratio")); //_act.activityratio = convert.todouble(_ratio); _act.notes = reader.getstring(reader.getordinal("notes")); string _hldy = reader.getstring(reader.getordinal("...

javascript - Polymer - Animating a DIV -

i learning polymer. have element includes div . want animate div's height. in attempt this, i've got following: my-element.html <dom-module id="my-element"> <template> <div id="container" style="height:100px; background-color:green; color:white;"> hello! </div> <paper-button on-click="_ontestclick">expand</paper-button> </template> <script> polymer({ is: 'my-element', _ontestclick: function() { // expand height of container } }); </script> </dom-module> i used grow height animation shown here inspiration. so, basically, have animation defined this: polymer({ is: 'grow-height-animation', behaviors: [ polymer.neonanimationbehavior ], configure: function(config) { var node = config.node; var rect = node.getboundingclientrect(); var height = rect.height; thi...

javascript - Temasys howto alter existing code -

i have piece of code in place passes constraints getusermedia. function captureusermedia(callback) { $('#videosource').css('display', 'none'); var videosource = videoselect.value; var constraints = null; constraints = { video: { optional: [{ sourceid: videosource }] }, audio: false } var htmlelement = document.getelementbyid('rtcvideo'); htmlelement.setattribute('autoplay', true); htmlelement.setattribute('controls', true); var mediaconfig = { video: htmlelement, onsuccess: function(stream) { config.attachstream = stream; callback && callback(); htmlelement.setattribute('muted', true); rotateincircle(htmlelement); }, onerror: function() { alert('unable access webcam'); } }; if (constraints) mediaconfig.constraints = constraints; getusermedia(mediaconfig); streamattached = true; } i.ve tried numerous th...

events - Corona SDK game scenes -

i looked in many other questions , tutorials, sadly, without result. trying go scene1 scene2 event listener , copying code given in project. difference between button , working 1 declare mine in lua file , not exist in scene1.ccscene have put image object in scene1.csscene in order use button? the code try: local composer = require( "composer" ) local scene = composer.newscene() -- ----------------------------------------------------------------------------------------------------------------- -- code outside of listener functions executed once unless "composer.removescene()" called. -- ----------------------------------------------------------------------------------------------------------------- -- local forward references should go here local start_button = display.newimage("start.png") --start button -- ------------------------------------------------------------------------------- -- "scene:create()" function scene:create( ...

ClassCastException with OSGI bundle -

i working on osgi bundle, uses javax.ws.rs-api (2.0.1). karaf having jsr311-api (1.1.1) loaded bundle. when try load osgi bundle, see following exception. there way can ignore loaded bundle? the activate method has thrown exception java.lang.linkageerror: classcastexception: attempting castbundle://137.0:1/javax/ws/rs/ext/runtimedelegate.class bundle://177.0:1/javax/ws/rs/ext/runtimedelegate.class @ javax.ws.rs.ext.runtimedelegate.finddelegate(runtimedelegate.java:146)[137:javax.ws.rs.jsr311-api:1.1.1] @ javax.ws.rs.ext.runtimedelegate.getinstance(runtimedelegate.java:120)[137:javax.ws.rs.jsr311-api:1.1.1] @ javax.ws.rs.core.uribuilder.newinstance(uribuilder.java:95)[137:javax.ws.rs.jsr311-api:1.1.1] @ javax.ws.rs.core.uribuilder.fromuri(uribuilder.java:119)[137:javax.ws.rs.jsr311-api:1.1.1] your bundle must import packages need versions. have create meta-inf\manifest.mf import-package header, contain list of packages required versions. import-package...

c++ - atomic fetch_add vs add performance -

the code below demonstrates curiosities of multi-threaded programming. in particular performance of std::memory_order_relaxed increment vs regular increment in single thread. not understand why fetch_add(relaxed) single-threaded twice slower regular increment. static void bm_incrementcounterlocal(benchmark::state& state) { volatile std::atomic_int val2; while (state.keeprunning()) { (int = 0; < 10; ++i) { donotoptimize(val2.fetch_add(1, std::memory_order_relaxed)); } } } benchmark(bm_incrementcounterlocal)->threadrange(1, 8); static void bm_incrementcounterlocalint(benchmark::state& state) { volatile int val3 = 0; while (state.keeprunning()) { (int = 0; < 10; ++i) { donotoptimize(++val3); } } } benchmark(bm_incrementcounterlocalint)->threadrange(1, 8); output: benchmark time(ns) cpu(ns) iterations ---------------------------------------------------------------------- ...

Why does Java Language Specification say that the expression (n > 2) is not a constant expression? -

in java language specifications chapter on definite assignment , example 16-2 says a java compiler must produce compile-time error code: { int k; int n = 5; if (n > 2) k = 3; system.out.println(k); /* k not "definitely assigned" before statement */ } even though value of n known @ compile time, , in principle can known @ compile time assignment k executed (more properly, evaluated). java compiler must operate according rules laid out in section. rules recognize constant expressions; in example, the expression n > 2 not constant expression defined in §15.28. but, if @ §15.28, says the relational operators <, <=, >, , >= can contribute constant expression. is expression n > 2 constant expression or not? how can determine this? it says because n not constant expression . a constant expression expression denoting value of primitive type or strin...

Cannot run MongoDB on Windows XP -

i downloaded mongodb (32 bit) zip , want run server. when run mongod.exe, system says this: mongod.exe not win32 application i have windows xp 32 bit. how can fix it? fixed downloading older mongodb release

Why is my javascript equals operator always return true? -

the following if statement evaluates true: if (a = b) { //... } why true? you need use comparing operator if(a == b) ... instead of assigning one

c# - EPPlus isn't honoring ExcelHorizontalAlignment Center or Right -

i've tried in epplus versions 3.1.3.0 , latest 4.0.4.0 , both exhibiting same behavior. i'm trying center align text in cells it's not working. numbers in cells work fine, strings not. following example of code fails produce desired excelhorizontalalignment: var newfile = new fileinfo(@"c:\temp\sample.xlsx"); using (var package = new excelpackage(newfile)) { var worksheet = package.workbook.worksheets.add("content"); worksheet.column(1).width = 50; worksheet.cells["a1"].value = "this should left-aligned"; worksheet.cells["a1"].style.horizontalalignment = excelhorizontalalignment.left; worksheet.cells["a2"].value = "this should center-aligned"; worksheet.cells["a2"].style.horizontalalignment = excelhorizontalalignment.center; // <- doesn't work. worksheet.cells["a3"].richtext.add("this should center-aligned"); worksheet...

javascript - Cocos2d-js hangs on bootscreen when trying to go fullscreen -

my cocos2d-js game hangs "failed execute 'requestfullscreen' on 'element': api can initiated user gesture" on loader-screen" on mobile. since seems cocos requests fullscreen withou me coding explicitly: how can prevent happening? thanks lot! i have found solution hidden in docs: cc.view.enableautofullscreen(false); edit: that seems not work on chrome... still getting: failed execute 'requestfullscreen' on 'element': api can initiated user gesture.

want to send email with attachment on rails 4 -

actually novice on ruby on rails. , want send email attachment pdf or excel file on rails 4 did not exact solution it. tell me solution it. are using actionmailer chance? if so, read this: http://guides.rubyonrails.org/action_mailer_basics.html , point 2.3.1 - adding attachments.

eclipse - How to run a postgressql function -

Image
i struggling execute postgressql function. trying read documentation on side still no use. using toad extension eclipse develop/run function so far, have written create or replace function dbname.function_name() returns void $body$ declare x_cur cursor select * dbname.x; x_row record; begin open x_cur; raise notice 'cursor opened'; loop fetch x_cur x_row; exit when not found; end loop; close x_cur; end; $body$ language plpgsql volatile; i executed script , ran select dbname.function_name(); in sql worksheet , don't see output. i remember writing functions on plsqldeveloper easy , interactive , struggling postgressql, guys me getting headstart. thanks i dont see problem using pgadmin. the function return void , raise notice show message. i simplify function create or replace function function_name() returns void $body$ declare begin raise notice 'cursor opened'; end; $body$ ...

javascript - How to access processing.js 'width' and 'height' outside processing.js functions -

i've made leap using khan academy's processing.js environment real deal , getting little confused. i have simple processing.js program draws circle, , want size of circle determined width of canvas. if print width within processing.js function, setup, i'm shown correct 500px width. unfortunately, whenever try access width property outside of processing.js function, shows default 100px size, though canvas 500px wide. i think might using ugly mix of processing , javascript, root of problems. appreciated! processing.js ///* processing.js setup */// void setup() { size(500, 500); println(width); // works! :) } println(width); // doesn't work... :( ///* global variables */// var moleculequantity = 1; ///* object constuctors */// var molecule = function(x, y) { this.x = x; this.y = y; this.width = width; this.height = height; }; molecule.prototype.draw = function() { nostroke(); fill(88, 91, 183); ellipse(this.x, this.y, 7...

java - i need to get MINx, MAXx, MINy, MAXy -

i need min x , max x , miny , max y .....i wrong value public static void main(string[] args) { double[][] matrix = new double [5][2]; matrix [0][0] = 1.0; matrix [0][1] = 2.5; matrix [1][0] = 3; matrix [1][1] = 4; matrix [2][0] = 5; matrix [2][1] = 6; matrix [3][0] = 7; matrix [3][1] = 8; matrix [4][0] = 9; matrix [4][1] = 10; double minx = matrix[0][0]; double maxx = matrix[0][0]; double miny = matrix[0][0]; double maxy = matrix[0][0]; (int = 0; < matrix.length; i++) { (int j = 0; j <matrix[0].length; j++) { if (minx > matrix[i][0]) { minx = matrix[i][0]; } if (maxx < matrix[i][0]) { maxx = matrix[i][0]; } if (maxy < matrix[i][0]) { maxy = matrix[0][j]; } if (miny > matrix[i][0]) { miny = matrix[0][j]; } } } system....

symfony - overriding template of password change fos user bundle -

hi im working on project using fosuserbundle manage users inside application, want - same thing - move/copy template of password change inside page contains profile of current user, works fine, displays me changepasswordformtype, when submit changes controller gives me error : catchable fatal error: argument 1 passed user\userbundle\entity\acces::checkallfields() must instance of symfony\component\validator\executioncontext, instance of symfony\component\validator\context\executioncontext given thats controller : $request = $this->get('request'); $em = $this->getdoctrine()->getmanager(); $roles = $em->getrepository('adminadminbundle:role')->findall(); $usermanager = $this->get('fos_user.user_manager'); $user = new \user\userbundle\entity\acces(); $user = $this->container->get('security.context')->gettoken()->getuser(); /** @var $dispatcher \symfony\component\eventdispatcher\eventdispat...

entity - How can I get all the modified fields before saving the editing in cake php? -

using $entity->errors(); //is returning errors. to find changes before upgrading there $entity = $this->controller->patchentity($entity , $this->request->data); echo $entity->diff (); // how? i guess looking for: $entity->dirty() if want array containing alla dirty properties can do $entity->name = 'foo'; $entity->description = 'bar'; debug($entity->extract($entity->visibleproperties(), true)); you'll [ 'name' => 'foo', 'abbreviation' => 'bar' ] see manual

javascript - Printing Popup Window after loading -

i've spent more 5 hours on this, i'm trying load link on popup window , after loading want print it. so did following <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> function printer(){ var link = 'file:///c:\\page0339.swf'; w = window.open(link, "_blank", "location=1,scrollbars=1,menubar=1,width=600, height=400"); w.onload = function() { this.print(); this.close(); }; } $(document).ready(function () { $("#print").click(function () { printer(); }); }); </script> <input type ="button" id = "print" value = 'print' /> inside onload i've tried alert message , shows both this.print();this.close(); never called, , didn't see javascript error. how can call print function inside ...

c# - How to call a file for picturebox -

i have form 6 arrays, 15 elements each. wrote them in way if search myself (being 1st element in string[] name array), form load 1st element of every array: age, gender, hobby, photo etc. here part of picturebox code i'm using //i have more arrays here, like: name,gender,age,hobby,place & talent string[] photo=new string[] { "764.jpg", " 765.jpg", " 766.jpg", " 767.jpg"," 765.jpg", " 767.jpg", " 768.jpg", " 769.jpg", " 770.jpg", " 771.jpg", " 772.jpg", " 773.jpg", " 774.jpg", " 775.jpg", " 776.jpg"}; string name="",gender="",place="",warning=""; int age = 0; string image=""; (int = 0; < 15; i++) { if (textbox6.text == emri[i]) { //i applied every element of every array declared variables ...

slot - Qt: Issuing a message before emitting a signal -

brief description of application , question: in qtabwidget have several groupboxes containing each 2 qradiobuttons. e.g. select menu (groupbox): (radiobutton:) (radiobutton:) b at 1 point of time, 1 menu can active. both radiobuttons connected each othe -> when click radiobutton , set true, radiobutton b automatically set false - , other way round. when trying change menu setting, before click signal emitted, issue qmessagebox warning "are sure want change menu? can cause severe damage device." -yes/no. when clicking yes, change menue setting. when clicking no, remain before. the problem have is: when issuing qmessagebox in on_radio_button_toggled slot, radiobutton state has changed true. if change state in slot again , correct them, looks state has changed when pop message shows up. don't want because implies state of menue has changed. where or how can let qmessagebox pop before emitting actual signal slot - when clicking radio button? thank help...

python - Django forms not showing error when empty -

i have django forms, don't become red or show error when empty (they required). sort of sure of do. views.py def lout(request): if request.user.is_authenticated(): context = { "extendvar":"baseloggedin.html", } if request.user.is_authenticated()==false: form=registerform(request.post or none) if form.is_valid(): email = form.cleaned_data['email'] print ("yup") elif form.is_valid()==false: print ("nup") print (form.errors) print("eh") context= { "extendvar":"basenotloggedin.html", "form":form, } base.html: {% extends extendvar %} {% block title %} {{ block.super }} lagro {% endblock %} {% block fname %} {{ form.fname }} {% endblock %} {% block lname %} {{ form.lname }} {% endblock %} {% block email %} {{ f...

How to forward TCP/UDP ports in Debian 7 (64BIT)? -

i have friend using ovh vps (debian 7, 64 bits) , want open tcp , udp ports dont know why. try access got timed_out, think firewall blocking connection. tried on different computers same issue. vps firewall? please command forward ports or add firewall exception in debian 7. thanks. welcome wonderful world of iptables information interested in surrounds iptables package, default firewall logic number of linux distributions. to answer question simply, following should permit traffic through port 80 "anywhere", example. modify see fit, , see basic port opening requirements met. sudo iptables -a input -p tcp --dport 80 -j accept similarly, if needed open udp port 9987 (default teamspeak), command this. sudo iptables -a input -p udp --dport 9987 -j accept lastly, iptables configuration commands saved in memory. "commit" changes persist reboot, must save them. sudo service iptables save here additional trustworthy resources on iptables educat...

css - Flask-Bootstrap custom theme -

i made flask app flask-bootstrap. using virtualenv well. find stylesheet edit customize colors? or there way have custom colors? add custom colors css file, e.g. mystyle.css , put under static folder, add custom css file template. {% block styles %} {{super()}} <link rel="stylesheet" href="{{url_for('.static', filename='mystyle.css')}}"> {% endblock %} check documentation here: adding custom css file:

php - header() not redirecting to another index page automatically -

when click login.. doesn't automatically redirect me home.php, have refresh page redirect me. i'm guess first header() working fine bc responding page refresh. what's not working second header() inside if statement. doing wrong? thank help. login.php <?php session_start(); if($_session['user']!=""){ header("location: home.php"); } include_once 'db.php'; if(isset($_post['login'])){ $uname = mysqli_real_escape_string($conn, $_post['uname']); $upass = mysqli_real_escape_string($conn, $_post['upass']); $sql = "select * users username='$uname'"; $result = $conn->query($sql); $row = $result->fetch_assoc(); if($row['password']==$upass){ $_session['user'] = $row['username']; header("location: home.php"); } else{ echo "unable log in, please try again."; } } ?> <html> <head> <meta charset="utf-8"...

java - TableView: one header with multiple columns -

Image
i trying create table contains column 1 header has several entries per row in javafx 8. result should more or less this: i tried add subcolumns works perfectly, not able hide headers of subcolums. found solutions hide header older versions of javafx , listview. also tried add whole listview 1 row, similar suggested jewelsea here: javafx table- how add components? of course used listview instead of button. tableview presents first entry of listview. here code callback class: public class ielistviewcallback implements callback<tablecolumn<connectedielist, connectedielist>, tablecell<connectedielist, connectedielist>> { @override public tablecell<connectedielist, connectedielist> call(tablecolumn<connectedielist, connectedielist> param) { return new tablecell<connectedielist, connectedielist>() { final listview<string> listview = new listview<string>(); { listview....

git - Ignored file still showing changes -

Image
my .gitignore follows: ## ignore visual studio temporary files, build results, , ## files generated popular visual studio add-ons. # project files *.sln *.vcxproj *.vcxproj.filters upgradelog.htm # user-specific files *.suo *.user *.userosscache *.sln.docstates # .... now of these files ignored properly, exception of solution file, main.sln . why not ignored when put in gitignore? is due main.sln existing before added ignore? thought stop tracking if placed within ignore guess that's not case. here's screenshot: how can stop tracking changes main.sln ? lines in .gitignore ignore files not part of repository. once added repository, tracked, , cannot ignored. if want stop traking file have remove git tree. do, command line: $ git rm --cached main.sln and commit change. on, file gitignored. note: --cached option keep real file in working directory. without file deleted.

c# - Silverlight Sidebar Gadget global variable -

i'm making sidebar gadget , need set variable combo-box in settings page. need make variable global variable can access other pages (docked, undocked etc.) have tried setup global class , adding global variable web.config page no luck. i'm stuck , out of ideas. here's global class have tried: using system; using system.collections.generic; using system.linq; using system.text; using system.collections; namespace silverlightgadgetdebugger { class globalclass { public static class staticclass { public static string mytime { get; set; } } } } i unable call global class (which in silverlightgadgetdebugger), , here's web.config file: <?xml version="1.0"?> <!-- more information on how configure asp.net application, please visit http://go.microsoft.com/fwlink/?linkid=169433 --> <configuration> <system.web> <com...

Issue with Ruby variables -

i expect code insert 4 variables (which contain numerical characters) table in sqlite database: on :"1" |m| local = m.params[1] local_max = m.params[2] end on :"2" |m| global = m.params[1] global_max = p m.params[2] db.execute( "insert t (local, local_max, global, global_max) values(#{local}, #{local_max}, #{global}, #{global_max})" ) end but instead, generates errors: > [2016/01/07 20:43:09.662] !! bot.rb:88:in `block (4 levels) in > <main>': undefined local variable or method `local' > #<cinch::callback:0x00000000c4fe00 @bot=#<bot nick="cinch">> (nameerror) the variables local , local_max exist in scope of first block (the first do ... end ). "declaring" variables outside block , letting block capture them should enough: local, local_max = nil, nil on :"1" |m| local = m.params[1] local_max = m.params[2] end on :"2" |m| glo...

sql server - How to Check MSDB for User Permissions/Roles -

i have connectionstring <add name="dbcon" connectionstring="data source=10.197.10.10,46512\games;initial catalog=games;user id=usera;password=;" providername="sqlmembershipprovider" /> before using sp_send_dbmail , through sql query, how check if usera has permissions or roles in msdb database? it's important understand difference between sql server login (instance level object) , database user (database level object). in connection string, login named usera , might confusing. "logins" don't have permissions within database. well, not directly . it's "user" login mapped has permissions. ok, enough of that... sql login if login has sysadmin role membership, you'll have free reign anything, including sending mail via sp_send_dbmail . query tell if login you're connected has membership (look return value of "1"): select is_srvrolemember('sysadmin', suser_name()) ...

java - Testing Logistic Regression. Doesn't converge using 1 or 0, but does using logit -

i have created simple logistic regression using gradient descent using linear regression code here: gradient descent linear regression in java now i'm adapting logistic regression changing hypothesis adding logit transform: 1/(1+e^(-z)), z original theta^t * x. , not scaling population size. when trying test results confusing behavior: set independent variables(x) random number * expected weight , dependent(y) logit of sum, y= logit(w0*1 + w1*x1 + w2*x2). now in case converges correct answer, , can recover expected weights. should have y 0 or 1. when round or down, no longer converge. here generating training data: @test public void testlogisticdescentmultiple() { //... //initialize independent xi //going create test data y= 10 + .5(x1) + .33(x2) for( int x=0;x<num_examples;x++) { independent.set(x, 0, 1); //x0 set 1 intercept independent.set(x, 1, random.nextgaussian()); //x1 independent.set(x, 2, random.nextgaussian() ); ...