Posts

Showing posts from May, 2014

python 3.x - Using c++ complex functions in Cython -

i trying complex exponential in cython. i have been able cobble following code pyx : from libc.math cimport sin, cos, acos, exp, sqrt, fabs, m_pi, floor, ceil cdef extern "complex.h": double complex cexp(double complex z) import numpy np cimport numpy np import cython cython.parallel cimport prange, parallel def try_cexp(): cdef: double complex rr1 double complex rr2 rr1 = 1j rr2 = 2j print(rr1*rr2) #print(cexp(rr1)) note print(cexp(rr1)) commented. when line active, following error when running setup.py : error: command 'c:\\winpython\\winpython-64bit-3.4.3.6\\python-3.4.3.amd64\\scripts\\gcc.exe' failed exit status 1 note when cexp commented out, runs expected... can run setup.py , , when test function prints out product of 2 complex numbers. here setup.py file. note includes code run openmp in cython using g++: from distutils.core import setup cython.build import cythonize distutils.extension import

arduino - Python doesn't parse Serial data to an array -

i working on project in have collect voltages teensy 2.0(which programming arduino) , send voltages python. have send microsecond data taken on. using pyserial communicate teensy. first read in data array of length 3998. have 2 other arrays, timedata array, keeps track of microseconds, , radardata array, keeps track of voltages. each array carries half data, or 1999 points. sample portion of serialdata: b'1468095384\r\n' b'0.01\r\n' this repeated 1999 times. python code takes these inputs , writes them , array "serialdata". after done reading data separates points 2 arrays so: for in range (0,3998): if(i % 2 == 0): radardata[samples] = float(str(serialdata[i], 'utf-8')) samples = samples + 1 else: timedata[samples1] = float(str(serialdata[i], 'utf-8')) samples1 = samples1 + 1 sample , sample1 counter variables. from printing out float(str(serialdata[i], 'utf-8')) , know parsing s

pass C++ double array to embedded python efficiently without NumPy -

i extending c++ embedded python. how efficiently pass array of doubles? currently create tuple: std::vector<double> a(len); ... pyobject* pinput = pytuple_new(len); (int i=0; i<len; ++i) pytuple_setitem(pinput, i, pyfloat_fromdouble(a[i])); is there more efficient way large arrays (e.g. len > 1000000 )? not want use numpy. datatype use on python side then? possible construct object of type array.array (binary python array)? or other (python) type should construct in c++ code, converted array.array on python side.

Japanese text in Symfony form titles -

i'm working on project requires using symfony form component, , need able add kanji of field names. using english works fine: $form = $this->createformbuilder() ->add('name', texttype::class) ->add('price', texttype::class) ->getform(); when try name of fields in japanese though, error: fatal error: uncaught exception 'symfony\component\form\exception\invalidargumentexception' message 'the name "名" contains illegal characters. names should start letter, digit or underscore , contain letters, digits, numbers, underscores ("_"), hyphens ("-") , colons (":"). is there way change display name of field? $form = $this->createformbuilder() ->add('name', texttype::class, [ 'label' => '名', ])->... this should job, , or use resource file if avoid including language specific characters. $form = $this->createformbuilder() ->add('name', t

c++ - glMatrixMode(GL_MODELVIEW) use giving segmentation fault -

i trying implement camera fps project , having trouble when using camera class on main.cpp when calling glmatrixmode(gl_modelview) . here relevant functions: void camera::init() { m_yaw = 0.0; m_pitch = 0.0; set_pos(0,0,0); } void camera::set_pos(float x, float y, float z) { m_x = x; m_y = y; m_z = z; refresh(); } void camera::refresh() { m_lx = cos(m_yaw) * cos(m_pitch); m_ly = sin(m_pitch); m_lz = sin(m_yaw) * cos(m_pitch); m_strafe_lx = cos(m_yaw - m_pi_2); m_strafe_lz = sin(m_yaw - m_pi_2); glmatrixmode(gl_modelview); glloadidentity(); printf("the segmentation fault above!\n"); glulookat(m_x, m_y, m_z, m_x + m_lx, m_y + m_ly, m_z + m_lz, 0.0, 1.0, 0.0); //printf("camera: %f %f %f direction vector: %f %f %f\n", m_x, m_y, m_z, m_lx, m_ly, m_lz); } in case if include glew.h, need initialize beforehand, otherwise gl api calls replaced null function pointers , causes segfaults

C#: What's the behavior of the fixed statement on empty strings? -

this document , part of c# language spec, says behavior of fixed in c# implementation-defined if used on null/empty array reference. quote it: an expression of array-type elements of unmanaged type t, provided type t* implicitly convertible pointer type given in fixed statement. in case, initializer computes address of first element in array, , entire array guaranteed remain @ fixed address duration of fixed statement. the behavior of fixed statement implementation-defined if array expression null or if array has 0 elements. however, not make same claim empty strings, saying behavior isn't defined if string null. here's next paragraph detailing how works strings: an expression of type string, provided type char* implicitly convertible pointer type given in fixed statement. in case, initializer computes address of first character in string, , entire string guaranteed remain @ fixed address duration of fixed statement. the behavior of fixed statement implementat

jasper reports - Group several same value field into a single cell -

Image
first of all, records shown in table table component not in report one. the results looks this: years months summonth sumquarter ----- ------ -------- ---------- 2009 jan 130984 432041 feb 146503 mar 154554 apr 147917 435150 may 131822 jun 155411 jul 144000 424806 aug 130369 sep 150437 oct 112137 400114 nov 152057 dec 135920 ===================================== jan-dec 1692111 ===================================== 2010 jan 139927 417564 feb 154940 mar 122697 apr 163257 413305 may 124999 jun 125049 jul 145127 427612 aug 138804 sep 143681 oct 143398 406381 nov 125351 dec 137632

ios - Adding an image broke my Xcode project. Anyone know why/how? -

so here link youtube video describing happened. https://youtu.be/zckq1q6kahe i'll continue under assumption saw video. important note image not used in code anywhere of yet. image in question png had created using gimp editing software. added image project , broke movement , contact. these things unrelated picture. after removing picture project work again , movement , contact fine. however; if added other picture unrelated first project break it. xcode project ruined because couldn't add new pictures it. i opened new project in xcode , copied entire thing on , got running again. worked until added picture project again broke project. first project, new 1 break when adding additional images. i need create on 150 images app , while people on @ reddit.com/r/picrequests have been able cropping me, need able myself. unfortunately somehow doing myself tanked project. ideas why? thanks

Calculating turret angle 2D, C++ -

so i'm trying figure out how turret on little space ship figure out angle @ relative world , rotate point target both turret , ship have relative coord , rotation, ship's coord , rotation relative world , turret's relative parent(may not body of ship, might wing or such) all parts calculate local , global 3x3 transformation matrix if helps

c# - Transform xml to xml using XSLT - Advices -

i have 1 xml file : <?xml version="1.0" encoding="utf-8" standalone="no"?> <cars> <car> <color>blue</color> <model>car2</model> <year>1988</year> <speed>250</speed> </car> <car> <color>blue</color> <model>car2</model> <year>1988</year> <speed>250</speed> </car> </cars> i want transform using xslt have : <?xml version="1.0" encoding="utf-8" standalone="no"?> <vehicles> <vehicle> <vehiclecolor>blue</vehiclecolor> <vehiclemodel>car2</vehiclemodel> <vehicleyear>1988</vehicleyear> <vehiclespeed>250</vehiclespeed> </vehicle> <vehicle> <vehiclecolor>blue</vehiclecolor>

ios - Change UIScrollView contentSize with animation -

is possible change uiscrollview 's contentsize animation size decreases / increases on period, like uiview.animatewithduration(0.3, animations: { scrollview.contentsize.width -= 100.0 } doesn't work. don't know if there's way ?

Generate all permutation of a string in recursion in java -

this question has answer here: generating permutations of given string 41 answers i know how create permutation of given string in recursive way. lets string = "abcdefghijklmnopqrstxyz"; . i generate string of length 5 (for example) a using recursion , meaning: aaaaa aaaab aaaba aaaca zabfg thanks in advance. first, store unique characters using hashmap or so, transfer them list, call chars, ease of use. your recursive method building on string. when string reaches length 5, done, , want keep it. can return string or store in global list. in case, assume list called permutations. void generatepermutation(string current) { if (current.length == 5) { permutations.add(current); } else { (int = 0; < chars.size(); i++) { generatepermutation(current + chars.get(i)); } } }

Why can external JavaScript files access other external JavaScript files functions and how to stop it? -

i no means guru javascript, apologies if questions sounds "beginner". why if have 3 javascript files in project, of 3 javascript files can call of other functions in other javascript files? bigger question how can stopped? example if, of these 3 hypothetical javascript files, named managerjs.js, teamajs.js , teambjs.js, don't want teamajs able access teambjs want them both able access managerjs. all scripts on page evaluated in global scope. there single shared global scope per page. you can prevent access not defining stuff in global scope. can use iife create private scope each script: // myscript.js (function() { // declared here *local* function var localvalue = 42; // expose values explicitly creating global variables // (but there other, more elaborate ways) window.globalvalue = 21; }()); only expose values want other code / scripts access. there various ways that, 1 of them revealing module pattern . see what purpose of self ex

concatenation - MS Excel copy integers on same spreadsheet -

i have integers copied excel spreadsheet: 1 2 3 4 5 6 7 8 9 10 with formula, i'd copied somewhere else on same excel sheet. =a1:a10 doesn't helpful , reports 1 of values, a1 field. what's trick have data copied different set of fields? i've tried =text(a1:a10), =concatenate(a1:a10), rows, columns so point , laugh @ me, please tell me what's simple trick duplicate data on same exact spreadsheet! edit... work if =e4 in 1 cell followed =e5, =e6 in own cells, still need have commas between each value. example: 1,2,3,4,5,6,7,8,9,10. as see below, concatenate worked me. thanks! turns out needed comma between each entry. figured out how concatenate works , use that. works me: =concatanate(a1,",",a2,",",a3,",",a4,",",a5,",",a6,",",a7,",",a8) result: 1,2,3,4,5,6,7,8

node.js - One database, supports multi-region application -

Image
is there way have 1 database (mongodb) able support multi-region applications minimal latency? this perfect use case use replica set 3 members (one per region) one of them become master - means receive writes , propagate them others. this introduce layer of safety data in more 1 place, network outage in 1 area not stop entire application. more here

Why express on Node.js processes http requests "serially"? -

Image
i tried below 2 codes. accessed these programs 2 browsers @ same time. in sample1, res.send executed after processings , general implementation. mean, these "settimeout" can database access or that. in sample2, res.send executed @ first, , after that, rest of processings happen. according output of sample1, every http requests processed serially. if people access website @ same time, need wait every prior people. @ first, thought reason because node.js processes serially. noticed it's wrong understanding according result of sample2. result, node.js can simultaneously process bunch of functions include non-blocking code settimeout. so can't understand why express implemented such way. result, need use cluster pm2 process http request @ same time. could teach me why express behaves such way? , solution process http requests @ same time using cluster? sample1 var express = require('express'); var app = express(); app.get('/', function (

c# - Linq for a hierarchical relationship model with Entity Framework, Filtering nested tables -

Image
i have got following database model, need query company entity specific username table aspnetusers. not how filter , drill related hierarchical tables using linq lambda expression entity framework. domain classes have foreign keys , navigation properties required.i appreciate help. from understand given solution . hope may you. //test data datatable companies = new datatable(); companies.columns.add("companyid", typeof(string)); companies.columns.add("companyname", typeof(string)); datatable teams = new datatable(); teams.columns.add("companyid", typeof(string)); teams.columns.add("teamid", typeof(string)); datatable applicationuserteam = new datatable(); applicationuserteam.columns.add("teamid", typeof(string)); applicationuserteam.columns.add("applicationuserid", typeof(string)); datatable aspnetusers = new datatable

jquery - javascript image map resizing issue -

i trying use dynamic resize. know javascript new @ it. getting following error: index.html:20 uncaught typeerror: cannot read property 'getelementsbytagname' of null this error line: areas = map.getelementsbytagname('area'), thanks teemu script dynamically resizing image-maps , images <html> <head> <link rel="stylesheet" type="text/css" href="pb.css"> </head> <body> <script> window.onload = function () { var imagemap = function (map) { var n, areas = map.getelementsbytagname('area'), len = areas.length, coords = [], previouswidth = 1280; (n = 0; n < len; n++) { coords[n] = areas[n].coords.split(','); } this.resize = function () { var n, m, clen, x = document.body.clientwidth / previouswidth;

amazon web services - AWS CLI CloudFront Invalidate All Files -

i attempting invalidate entire static website. following command not seem invalidate /index.html , gives odd output of items invalided, shown below. aws cli behaviour normal or missing something? thanks! aws cloudfront create-invalidation --distribution-id $distribution_id --paths /* output: { "invalidation": { "status": "inprogress", "invalidationbatch": { "paths": { "items": [ "/lib32", "/home", "/vmlinuz", "/core", "/proc", "/var", "/dev", "/usr", "/etc", "/initrd.img", "/cdrom", "/lost+found",

scala - Better dao design with Anorm -

i'm working on code base has lots of singleton daos getting new connection pool in each method db.withconnection executes block. dao methods use anorm parsers parse result set. there cases each dao method run other dao methods in anorm parsers nested related items business model. let's assume have data structure this; user -> posts -> comments each posts dao work this; userdao.getuser postdao.getuserposts commentsdao.getpostcomments because each dao method calling db.withconnection, multiple connections used simple operations. i want use same connection. can done implicit connection passing through each dao method. need maintain connection allocation in upper layer. right daos accessed directly rest actions, there not kind of service layer sitting between api , dao. feel it's not have connection around in api layer. so having services userservice calling daos , handling connection , transaction better. then requirement make me uncomfor

ios - Removing All Items Under A Node Firebase -

i trying remove children under node. there way delete items under node? structure like: lastmessages - mainid - timestampedid - keys:values what want is, using mainid , delete items under it. there's 1 timestampedid @ time lastmessages. that's why thought should delete items under mainid before writing new value. there way achieve that; or there better ways thought? let ref = firebase(url: path) let myref = ref.childbyappendingpath(mainid) // how delete items under myref? simply call myref.removevalue() explained in docs the simplest way delete data call removevalue on reference location of data.

c - reverse a linkedlist recursively -

my linkedlist reverse function gives correct result. am confused. linked list= 12->5->4->3 per reverse function result should 4->5->12 fortunately produces correct reversed list 3->4->5->12. pls me understand happening //head_ref global variable struct n* reverse(struct n *head){ struct n *pre,*cur; //temp variable first , second node if(head->next==null){ head_ref = head; // head_ref global variable initialized head pointer return; } pre = head; cur = head->next; reverse(cur); cur->next = pre ; pre->next = null; } first call pre = 12 cur = 5 second call pre = 5 cur = 4 3rd call pre = 4 cur = 3 3->next = null //base condition fullfilled exit ( 3rd call ) reverse start second call pre = 5 cur = 4 my reversed linked list should 4->5->12 but produces 3->4->5->

java - Code runs fine in Eclipse but throws NumberFormatException in CodeChef -

the code working fine on eclipse ide on codechef, compiler showing error: exception in thread "main" java.lang.numberformatexception: null @ java.lang.integer.parseint(integer.java:542) @ java.lang.integer.parseint(integer.java:615) @ codechef.main(main.java:19) here's code: import java.util.*; import java.lang.*; import java.io.*; class codechef { public static void main(string[] args) throws ioexception { int x = 0, j = 0; string s; int counta = 0, countb = 0; int countf[] = new int[5]; bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); int = integer.parseint(br.readline()); while (j < i) { s = br.readline(); (int k = 0; k < s.length(); k++) { if (s.charat(k) == 'a') { counta++; } else { countb++; } } if (co

spring - Managing users BPMN/Activity for multiple tenants (departments) -

i have several process definitions in bpmn , using activity start them. process definitions includes users responsible perform tasks. internet full of examples how manage such schemes. but need start multiple process instances of same process against multiple departments. each department has near same organization structure, persons not same. example after shipping goods head of department must send report customer . in case head of department behaves same each time different person. , following bpmn definition cannot manage this: <resourceassignmentexpression> <formalexpression>head</formalexpression> </resourceassignmentexpression> because each department has own head. so question: how manage user in separate instances of bpmn process? if building solution, pass department process instance businesskey on startup. then, use task listener attached assign event determine task should assigned based on business key. other advantages of app

database - Mysql <= is giving the wrong output -

my table starttime | endtime | id 10:30 11:30 1 11:30 12:30 2 14:30 16:30 3 15:30 16:30 4 if wanted select id's between 10:30 12:30 use below command select id table str_to_date(starttime,'%h:%i')>='10:30' , str_to_date(endtime,'%h:%i')<='12:30'; this gives me id 1 ,but not giving me 2 , if change 12:30 12:40 gives me 1 & 2.but using less or equal should give me both id's right? why not working that? the problem trying compare date object against string. precise, in following expression str_to_date(starttime,'%h:%i') >= '10:30' str_to_date returns date, '10:30' varchar (which coincidentally looks time). if want continue down road, should cast both sides of comparison using str_to_date : select id table str_to_date(starttime,'%h:%i') >= str_to_date('10:30','%h:%i') ,

android - How to get sofar downloaded byte? -

i use library downloading files , awesome library , need sofar downloaded byte (its parameter of progress) in oncreate updating progress bar in oncreate . this code : public class mainactivity extends appcompatactivity { private button btndownload; private progressbar prgdownload; private int downloadid; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //////////////////////////////////////////////////////////// //================== init views =========== //////////////////////////////////////////////////////////// btndownload = (button) findviewbyid(r.id.btndownload); prgdownload = (progressbar) findviewbyid(r.id.prgdownload); final string savepath = filedownloadutils.getdefaultsaverootpath() + file.separator + "angry.apk"; final string url = "http://dl2.soft98.ir/mobile/a

android - ListViews Behind ActionBar -

Image
i made 1 activity navigationview. when select 1 item of navigationview loads 1 fragment. .xml contains layouts activity , fragment: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> //layout activity <relativelayout android:id="@+id/separator" android:layout_w

html - Align text with a picture -

Image
i wish align text picture. text cannot go outside borders of picture , should placed under it. have tried putting in containers , divs have not yet succeeded. on picture see current situation (picture 1) , wanted situation (picture 2). current code (after changing lot) <div style="text-align:center"> <a href="testing"><img src="test.jpg" width="800px" height="150px"></a><br/> <p align="left"> test. </p> </div> <br> set width <div> instead of <img> , center margin:auto; : <div style="text-align:center;width:300px;margin:auto;"> see jsfiddle you can make div display:inline-block; , set text-align:center; containing element: <div style="text-align:center;"> <div style="text-align:center;width:300px;display:inline-block;"> see jsfiddle

ios - How to switch to a existing, non-Navigation Controller-View programmable? -

i trying switch view (a totally normal view) view (also normal) programmable. here existing code: - (ibaction)login:(id)sender { if([_username.text isequaltostring:name] && [_password.text isequaltostring:pw]) { dashboardviewcontroller *destinationcontroller = [[dashboardviewcontroller alloc] init]; [self.navigationcontroller pushviewcontroller:destinationcontroller animated:yes]; }else { uialertview *message = [[uialertview alloc] initwithtitle:@"wrong username or password!" message:@"sorry." delegate:nil cancelbuttontitle:@"okay" otherbuttontitles:nil, nil]; [message show]; _password.text = nil; } } so, want directed dashboardviewcontroller . if try code, black, empty view shown. wrong

C++ x+=1 x++ and x = x +1 are not the same? -

this question has answer here: post-increment , pre-increment concept? 9 answers i can not grasp concept how these statements produce different values. far know x+=1, means x = x + 1. know x++ should equivalent x + 1. i've searched topic , found posts ask same question, posts answered stating statements/expressions same, different result due code mistake. example provide don't see how there code mistake please explain, thank you. int x = 0; x++; x should 1 @ point because x++ adds 1 x. so why if assign x 0, , proceed code "cout << x++;" value of 0 on screen?!. how x++ become 0 if x++ equal x+1 , if x 0 1+0=1? i've been told due ++ being put after x, why matter if dealing addition 1 + 0 same 0 + 1? cout << x++; outputs value of x before increment using postfix increment operator. cout << ++x; expect.

sql server - Round 916.984800 to 916.99 -

is possible round 916.984800 916.99 in sql server? i've tried below don't want '+ 0.1' solution. round((((424.53 - 0) * 36) * (6 / 100)),2) + .01 [amount] or round((((424.53 - 0) * 36) * (0.06)),2) + .01 [amount] thanks this produces expected output: select ceiling((424.53 - 0) * 36 * 0.06 * 100) / 100 [amount] amount ---------- 916.990000 what happens? select (424.53 - 0) * 36 * 0.06 * 100 this returns 91698.4800 , ceiling returns smallest integer greater than, or equal to, specified numeric expression, in case 91699 , , later divide 100, brings expected result.

java - Dot function for android calculator -

i not able figure out way find method implement possibilities put dot decimal representation of numbers the calculator has 1 text field (edittext) computes values there 2 operators first part solved , appends operator some thing tried... public void dot(view v) { if(count==1) { edittext et=(edittext) findviewbyid(r.id.edittext1); string input=et.gettext().tostring(); string[] parts=input.split("[+ - * /]"); if(parts[4].matches("[.]")){ return; } else{ et.append("."); } } else{ edittext et=(edittext) findviewbyid(r.id.edittext1); string input=et.gettext().tostring(); if(input.matches("[.]")) return; else{ if(input.length()==0) et.append("0"); et.append("."); } } } count keeps track of number of operators {values(0,1)}

php - Need help retrieving forgotten password from database -

okay, forgot password login administration panel. what needing done, example echo added display password, located auto-donate-login -> password image of database here file. <?php if(!isset($_session)){ session_start(); } include_once '../connection.php'; if(isset($_post['user'], $_post['pass'])) { $statement = $connection->prepare("select * `".$sqldatabase."`.`auto-donate-login` `username`=:name"); $statement->bindparam(":name", $_post['user']); $statement->execute(); if($row = $statement->fetch()) { $hash = md5(md5($row['salt']).md5($_post['pass'])); if($hash == $row['password']) { $_session['user'] = $_post['user']; $_session['ip'] = $_server['remote_addr']; $_session['salt'] = md5(md5($row['salt

Ugly editing value on PHP nested array -

i have json object try modify. created following function. firstly deserialize json object , given array , path want change modify value. function setindict($arr, $path, $value){ switch(sizeof($path)){ case 1: $arr[$path[0]] = $value; break; case 2: $arr[$path[0]][$path[1]] = $value; break; case 3: $arr[$path[0]][$path[1]][$path[2]] = $value; break; case 4: $arr[$path[0]][$path[1]][$path[2]][$path[3]] = $value; break; case 5: $arr[$path[0]][$path[1]][$path[2]][$path[3]][$path[4]] = $value; break; } return $arr; } i tried lot of things(recursion, &arr) make work dynamically php experience limited , cant make work. is there clean way this. there alternative can try? for example have following json , want modify subsubkey value 2 { "key":{ "subkey":{ "su

c# - DataGridView Not showing Data -

i have following code display data in datagridview table. datagridview empty: namespace windowsformsapplication5 { public partial class form1 : form { public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { messagebox.show("sdgds"); sqlcommand scommand; sqldataadapter sadapter; sqlcommandbuilder sbuilder; dataset sds; datatable stable; string sql = "select * mytable"; sqlconnection myconnection = new sqlconnection("user id=test;" + "password=test;server=mobile01;" + "trusted_connection=yes;" + "database=mydatabase; " + "connection timeout=30"); mycon

ruby on rails - How to create hash out of specific words in text? -

i have file following content: class rename < activerecord::migration def change rename_table :users, :vendors rename_table :places, :venues #there loads of similar lines end end and need create hash following structure: { "users" => "vendors", "places" => "venues" } how can achieve this? i can fetch needed words using regular expression method scan /rename_table.:(\s+),\s:(\s+)/ , returns [["users", "vendors"], ["places", "venues"]] [["users", "vendors"], ["places", "venues"]].to_h => {"users"=>"vendors", "places"=>"venues"}

regex - php preg_match_all separated by an optional pattern -

i've string follows pattern "[:it]stringa in italiano[:en]string in english" . i'm trying use preg_match_all capture locales , associated strings, ie: [1] => 'it', [2] => 'en', ... [1] => 'stringa in italiano', [2] => 'string in english' the regex i'm using "/\[:(\w+)](.+?)(?=\[:\w+])/g" ( https://regex101.com/r/ez1gt7/400 ) returns first group of data. i'm doing wrong? thanks.

c# - WPF program won't load after code change -

application working fine until added code 2 arrays. have class level strings: string cfilename = "customer.txt"; string[] cname = new string[0]; string[] cphone = new string[0]; and i've added window_loaded event: private void window_loaded_1(object sender, routedeventargs e) { //read file on start //readfile(); int counter = 0; string line; streamreader custsr = new streamreader(cfilename); line = custsr.readline(); while (custsr.peek() != -1) { array.resize(ref cphone, cphone.length + 1); array.resize(ref cname, cname.length + 1); cphone[cphone.length - 1] = line; cname[cname.length - 1] = line; counter++; //phonecombobox.items.add(cphone[cphone.length - 1]); } custsr.close(); (int = 0; < counter; i++) { phonecombobox.items.add(cphone[i]); } //focus when program starts phonecombobox.focus(); } the reason have //readfile() becau

java - Spring Boot security shows Http-Basic-Auth popup after failed login -

i'm creating simple app school project, spring boot backend , angularjs frontend, have problem security can't seem solve. logging in works perfectly, when enter wrong password default login popup shows up, kind of annoying. i've tried annotation 'basicwebsecurity' , putting httpbassic on disabled, no result (meaning, login procedure doesn't work @ anymore). my security class: package be.italent.security; import org.springframework.beans.factory.annotation.autowired; import org.springframework.boot.autoconfigure.security.securityproperties; import org.springframework.context.annotation.configuration; import org.springframework.core.annotation.order; import org.springframework.security.config.annotation.authentication.builders.authenticationmanagerbuilder; import org.springframework.security.config.annotation.method.configuration.enableglobalmethodsecurity; import org.springframework.security.config.annotation.web.builders.httpsecurity; import org.sprin

memory management - Mechanism of destroying an object by CLR in c#.net -

we can declare destructor not know when run, since decided clr when destroy object no longer referenced type variable. clr decides using garbage collector build map reachable objects , deallocate unreachable objects (objects has no reference). here clear can never destroy object our own code in c#. now when use using statement (not using directive) shown below using(manageme manage = new manageme()) { manage.add(4,8); console.writeline("using statement executed"); } q1: happens object reference manage (type variable) after end of using statement? means destroyed or clr decide destroy when needs? q2: how can check whether object not reference type variable destroyed or not during execution of programme? q1: happens object reference manage (type variable) after end of using statement? means destroyed or clr decide destroy when needs? it happens whatever happens local method reference. q2: ho

How to update multiple column of a table without changing other unedited column fields of that row on codeigniter -

i have 1 table. want select row through unique id , want change fields of row. although able update table, whenever update particular column of row, rest of existing values of row becomes null. please me in this. can find code below: my controler: <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class edit extends ci_controller { function __construct(){ parent::__construct(); $this->load->helper(array('form', 'url')); $this->load->model('welcome_model'); } /** * index page controller. * * maps following url * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * since controller set default controller in * config/routes.php, it's displayed @ http://example.com/ * * other public methods not prefixed underscore * map /index.php/welcome/<method_name> * @see http://codeigniter.com/user_guide/general/url