Posts

Showing posts from August, 2012

c++ - Initialization by user-defined constructor -

consider following program: #include <iostream> struct { a(int, int){ std::cout << "a(int, int)" << std::endl; } }; a(4,4); b{4,4}; c({4,4}); int main(){ } output: a(int, int) a(int, int) a(int, int) demo i' m intereste in there difference between initialization of a , b , c ? of theme direct initialized. a a(4,4); bog standard direct-initialization . a b{4,4}; bog standard direct-list-initialization . since a has no initializer_list constructor, ends doing same thing above. no std::initializer_list object ever constructed or destroyed. a c({4,4}); this direct-initializes c a temporary, in turn copy-list-initialized braced-init-list {4, 4} . note won't work if a::a(int, int) explicit , since in case copy-list-initialization ill-formed , left no viable constructor call. construction , destruction of temporary may elided, , is.

java - Using UnboundID SDK In-Memory Directory Server in Android App Code -

i have tried implementing unbound id in memory directory server simulating ldap directory testing purpose. code works fine java application ldif file sample directory data. when use in android application code, application aborts saying "it unable find or load class inmemorydirectoryserverconfig" . below key code snippet use connect in memory ldap server. inmemorydirectoryserverconfig config = new inmemorydirectoryserverconfig("dc=example,dc=com"); directoryserver = new inmemorydirectoryserver(config); directoryserver.importfromldif(true, getclass().getresource("example6.ldif").getpath()); directoryserver.startlistening(); ldapconnection = directoryserver.getconnection(); searchrequest searchrequest=new searchrequest(techmbasedn, searchscope.sub,filter.createequalityfilter("uid", name),"givenname","uid"); kindly let me know whether possible simulate directory server in...

How to use Application Verifier on Windows 7 without Administrator rights -

i tried use application verifier, without administartor rights can't add application (menu item file->add application disabled). i've read article, doesn't help: http://msdn.microsoft.com/en-us/library/ms220948%28v=vs.90%29.aspx

angularjs - Cannot access attribute that is a directive inside another directive's template -

my custom directive "testapp". access value of "file-model" in template, contain file object uploaded. whatever not able value, displaying "undefined". please suggest ways solve problem. app.directive('testapp', function ($compile) { return { restrict: 'e', scope: { text: '@', filem: '=filemodel' }, require:'filemodel', replace:true, template: '<div class="col-xs-4" style="padding-left:0px"><div class ="jumbotron" id="section1"><input type="text" name="id" id="section{{incr}}" placeholder="section heading" class="form-control"><form id="addliform1"><div ng-repeat="i in range(fileincr) track $index"><input type="text" name="file{{incr}}{{$index+1}}" id="f...

How to use Google Apps Script to create issues in Redmine? -

i'm trying create issue in redmine using google apps script, code following: function create_issue() { var payload = { 'project_id': 'helpdesk', 'subject': 'this test ticket', 'description': 'this genius test ticket', 'category_id': 1 }; var headers = { 'x-redmine-api-key': '<myapikey>', 'content-type': 'application/json' }; var url = 'http://myredmine.com/issues.json'; var options = { 'method': 'post', 'headers': headers, 'payload': payload, //utehttpexceptions': true }; var response = urlfetchapp.fetch(url, options); logger.log(response); } every time ran script, threw following exception: execution failed: request failed http://myredmine.com/issues.json returned code 422. truncated server response: {"errors":["subject can't blank"]} (use mutehtt...

javascript - push if not exist in array object -

i have below model in js . using angular js $scope.data = { focuson: " ", filters: [], range: { from: "", to: "" } } i have below function : $scope. addfield = function ($type, $value) { $scope.data1 = { filtername: $type, filtervalue: $value }; if ($scope.data.filters[$type] === undefined) { $scope.data.filters.push($scope.data1); } $scope.data1 = ""; $scope.json = angular.tojson($scope.data); }; i want push filters if not available already. how can this. i have tried above dint work. went wrong. can please me, thanks, so assuming $scope.data.filters array of objects filtername , filtervalue property. in case, need search array see if matching object exists before inserting it, comparing values of pro...

java - How to do Polygon Spatial Search in Spring-data-solr -

i have query below :- fq=latlng:iswithin(polygon(('23.60 71.60','28.65 71.68','28.60 72.61','28.63 72.65'))) now got stuck here in how query using spring-data-solr have function like public list<hotel> gethotelsinsidepolygon(point... points); it helpful if tells how proceed got 1 :- thing change in solr polygon search work are add jts jars in deployed solr war web-inf/lib change field type of latlng "location" "location_rpt" modify location_rpt field type below <fieldtype name="location_rpt" class="solr.spatialrecursiveprefixtreefieldtype" spatialcontextfactory="com.spatial4j.core.context.jts.jtsspatialcontextfactory" disterrpct="0.025" maxdisterr="0.000009" units="degrees" /> add location data index , polygon query work.

jquery - Comboboxes onsubmit changes giving results but refreshes javascript setting -

i have html page has 3 buttons on click event displays respective hidden div form .the html buttons : <button id="edituser" type="submit" onclick="toggle_visibility('c');" style="border:0;width:100px;margin-left: 74px;"> <img src="images/edituser.png" alt=""> </button><br><br> <button id="companyprofile" type="submit" onclick="toggle_visibility('d');" style="border:0;width:100px;margin-left: 74px;"> <img src="images/companyprofile.png" alt=""> </button><br><br> <button id="checkticket" type="submit" onclick="toggle_visibility('e');" style="border:0;width:100px;margin-left: 74px;"> <img src="images/checkticket.png" alt=""> </button>...

ios - JavaScript popup window on ipad -

i have not been able open popup windows on ipad using javascript window.open function, why have been trying make alternative solution ipad's, inspired this thread. function newpopup(url) { // user agent string var deviceagent = navigator.useragent; // set var ios device name or null var ios = deviceagent.tolowercase().match(/(iphone|ipod|ipad)/); if (ios) { // line matters $(this).attr('href', url); }else{ popupwindow = window.open( url,'popupwindow','height=250,width=350,left=50,top=50,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no') } } still can't open new window on ipad. there way target ipad? yes can find here if( navigator.platform === 'ipad' ){ alert('hurray'); } more details read here: https://developer.mozilla.org/en-us/docs/web/api/navigatorid.platform also detects iphone if needed , other ...

javascript - Get textbox and checkbox value for each row in table -

i've code <tr class="checkboxrow"> <td class="checkboxcol"> <input name="" type="checkbox" value="7" class="checkbox" /> </td> <td class="checkboxcol"> <input name="" type="checkbox" value="1" class="checkbox" /> </td> <td class="checkboxcol"> <input name="" type="checkbox" value="2" class="checkbox" /> </td> <td class="checkboxcol"> <input name="" type="checkbox" value="3" class="checkbox" /> </td> <td class="checkboxcol"> <input name="" type="checkbox" value="4" class="checkbox" /> </td> <td class="checkboxcol"> <input name="" type="checkbox...

java - AtomicInteger Class Inconsistency -

i using atomicinteger class increment value of customerid , productid. dont have database using serialization store state of application , command based application. everytime add customer or product costructor calls idgenerateor class has atomicinteger create id. there inconsistency, somtimes increment id , not, tell me whats wrong. public final class idgenerator implements serializable { private static atomicinteger nextid = new atomicinteger(); public static int newid() { return nextid.incrementandget(); } } public customer (string name, string email, string phone, address address) { this.name = name; this.email = email; this.phone = phone.replaceall("[\\s\\-()]", ""); // drop non-digit characters this.address = address; this.id = idgenerator.newid(); this.facebook=""; this.twitter=""; this.deliveryinstructions=""; }

ios - CoreData Fault, when i am trying to get data from NSSet for current user, I am getting following error." -

solution plz"! coredata fault, when trying data nsset current user, <_currentuser.useraddresses.allobjects[indexpath.row]);> getting following error....solution plz"! "<address: 0x7fd66a54a4c0> (entity: address; id: 0x7fd66a5a6f10 <x-coredata://0ef4f398-8357-4a52-9bc3-2c6e6b9a5014/address/p1> ; data: <fault>)" ) 2014-11-27 11:45:27.829 icare[2657:39674] row value 0 2014-11-27 11:46:43.381 icare [2657:39674] array value <address: 0x7fd66a54a4c0> (entity: address; id: 0x7fd66a5a6f10 <x-coredata://0ef4f398-8357-4a52-9bc3-2c6e6b9a5014/address/p1> ; data: <fault>) that's not error. fault data associated object has not yet been retrieved database. see apple documentation fuller explanation. if access of attributes of object, coredata automatically "fire" fault, retrieving relevant data database.

android - Databases from assets folder -

how data assets folder db? have .db file in assets folder. here doing. dbhelper2.class package com.example.testapp; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import android.content.context; import android.database.cursor; import android.database.sqlexception; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteexception; import android.database.sqlite.sqliteopenhelper; import android.util.log; public class databasehelper2 extends sqliteopenhelper{ private static string db_path = "/data/data/com.example.testapp/databases/"; private static string db_name = "birthdate_details.db"; private sqlitedatabase mydatabase; private final context mycontext; public databasehelper2(context context) { super(context, db_name, null, 1); this.mycontext = context; } public void createdataba...

How to terminte mysql sql file execution without run left statements -

suppose have table named test create table test ( id int not null, primary key (id) ) engine = innodb; and sql file 1.sql start transaction; insert test(id) values(1); select sleep(100); select * test; commit; we run 1.sql mysql client tool mysql -uroot < 1.sql it block @ "select sleep(100)" statement. if press "ctrl-c", mysql client kill current statement , continue execute left statements. result, insert commit. there method kill sql file execution without execute left statements? ps: tried "ctrl + \" abort mysql client, make query still executed in server side because of do not send kill query you can open second connection, check session want kill show processlist , , use sql kill command terminate it. see http://dev.mysql.com/doc/refman/5.6/en/kill.html and http://dev.mysql.com/doc/refman/5.6/en/show-processlist.html

class - Use of unlimited polymorphic type for array operation in Fortran 03/08 (gfortran compiler) -

i'd realize useful array operations (add element, remove element, different realizations allocatable/pointer/binary tree structures) class(*) feature (unlimited polymorphism). use gfortran 5.0 should handle such feature. need not repeating identical code each type use. this should like function add_element(array,element) class(*),intent(in)::array(:) class(*),intent(in)::element class(*)::add_element(size(array)+1) add_element=[array,element] end function the problem when try use function definite type, have error returning result. can not assign class(*) definite type variable without select type , , surely don't want have select type structures every time use it. , inside subroutine should not know of types want use, because create many of them. i tried variants move_alloc , source, tried use subroutine intent(out) argument etc. didn't work. think should defined in argument attributes, same size (with source keyword?) didn't find example or...

javascript - Rendering HTML using Gulp.js template compilers -

what easiest way use 1 of gulp template compilers render html files? gulp.task('html', function () { gulp.src('templates/**/*') .pipe(handlebars()) .pipe(whatcangoheretorenderhtml()) .pipe(gulp.dest('www')); }); the simplest way found render templates directly html using gulp-consolidate plugin per following example: var gulp = require('gulp'); var consolidate = require('gulp-consolidate'); gulp.task('html', function() { gulp.src('templates/**/*.html') .pipe(consolidate('handlebars', {msg:'this message!'})) .pipe(gulp.dest('www')); }); keep in mind handlebars library need installed example work.

function - Python weave lists -

i want "weave" 2 numberrows together. example: x = [1,2,3] y = [4,5,6] result = [1,4,2,5,3,6] this function, can't find out why doesn't work: def weave(list1,list2): lijst = [] = 0 <= len(list1): lijst += [list1[i]] lijst += [list2[i]] + 1 python's for-loops aren't other languages can have conditional. need use while loop instead or alter for-loop: def weave(list1,list2): lijst = [] = 0 while < len(list1): lijst.append(list1[i]) lijst.append(list2[i]) += 1 return lijst i've altered code in variety of ways: use while loop if have condition want loop through you want conditional less length, not less or equal to. because indexing starts @ 0, , if <= , try list1[3] won't exist. use list.append add items list you forgot = in i += 1 finally, don't forget return list! you use zip() : >>> [a b in zip(x, y) in b] [1, 4...

Windows Phone 8 choose text file C# -

i have question. if there possibility @ windows phone 8 @ visual studio create button event read text file? know streamreader , if declare wchich exacly file want read, if want choose list of files wchich want display. did research on internet didint find answer. know can use isolatedstorage read music, video, image not text files, on app created few files text in , want users have posibility display 1 file, whichever want see. so, can tell me how this? you can use isolatedstorage read file type wish. must of been using launcher filters out file type based on chooser. you can open file this: private async task<string> readtextfile(string file_name) { // return buffer string file_content = ""; // local folder storagefolder local = windows.storage.applicationdata.current.localfolder; if (local != null) { // file storagefile file; try { file = await local.getfileasync(file_name); ...

groovy - org.apache.commons.logging.impl.Jdk14Logger does not implement Log -

i have application deployed on websphere 8.5, class loading configured "parent last". in application, use groovyscriptengine run groovy script file. here groovy script: @grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.2' ) import groovyx.net.http.* import static groovyx.net.http.contenttype.* import static groovyx.net.http.method.* new file('grab.log').delete() file file = new file('grab.log') try{ file << '11111\n\n' def http = new httpbuilder('http://www.google.com') def html = http.get( path : '/search', query : [q:'groovy'] ) file << html file << '\n\n22222' }catch(e){ file << org.apache.commons.lang.exception.exceptionutils.getstacktrace(e) } jars downloaded folder .groovy/grapes, code line def http = new httpbuilder('http://www.google.com') results in error: org.apache.common...

Windows Phone 8 lunch application at start up -

does knows if there way execute application @ phone start up? i not think allowed in windows phone. there no parameters can set within app(in resulting xap say) allow run phone booted. obviously alignment fact windows phone user centric os, i.e. not allowing user isn't aware about.

ios - UILongPressGestureRecognizer bound only applicable on UIImageView -

this question has answer here: uitapgesturerecognizer on uiimageview within uitablevlewcell not getting called 3 answers i'm developing ios app based on augmented reality. suppose user set distance wall through uislider . he'll select picture gallery , see how on wall. app should scale uiimage accordingly distance of user wall , user can drag see how on wall. i want apply uilongpressgesturerecognizer on added uiimage can deleted i.e. tap hold , delete. this code i've applied import image in library i'll import gallery later: self.myimage = [uiimage imagenamed:@"myimage.png"]; self.myimageview = [[uiimageview alloc] initwithimage:self.myimage]; self.myimageview.userinteractionenabled = yes; cgrect cellrectangle; self.myimageview.contentmode = uiviewcontentmodescaleaspectfit; cellrectangle = cgrectmake(0, 0, self.myimage.size.width/5, s...

excel - Sum cells if date is correct (SUMIF) -

Image
i having little problem google spreadsheets. spreadsheet looks this: a b c 24.11.2014 07:30:12 fruit 500 24.11.2014 17:34:32 meat 450 25.11.2014 07:30:09 blah 1000 25.11.2014 18:30:47 blah 802 now want add numbers in c:c if date equals 24.11.2014. first guess using: =sumif(a:a,">="&e2,c:c) where e2 = 24.11.2014 after messing around it, still gives me parsing error. sumif works google spreadsheets. thanks help! here simplest solution: =sumif(a:a;"*"&e2&"*";c:c) you sum values in c:c if find e2 in a:a . , result 950 in example. hope works fine.

Description of parameters of GDAL SetGeoTransform -

can me parameters setgeotransform? i'm creating raster layers gdal, can't find description of 3rd , 5th parameter setgeotransform. should definition of x , y axis cells. try find here , here , nothing. i need find description of these 2 parameters... it's value in degrees, radians, meters? or else? the geotransform used convert map pixel coordinates , using affine transformation. 3rd , 5th parameter used (together 2nd , 4th) define rotation if image doesn't have 'north up'. but images north up, , both 3rd , 5th parameter zero. the affine transform consists of 6 coefficients returned gdaldataset::getgeotransform() map pixel/line coordinates georeferenced space using following relationship: xgeo = gt(0) + xpixel*gt(1) + yline*gt(2) ygeo = gt(3) + xpixel*gt(4) + yline*gt(5) see section on affine geotransform at: http://www.gdal.org/gdal_datamodel.html

knockout.js - Bootstrap Glyph icon Calendar not working -

i have used bootstrap glyph calendar icon date picker textbox in c#. when calendar icon clicked, calendar shown, without next/ previous month/year arrow buttons. there blank space instead of either side arrow buttons, still arrow control works. does know how make arrow visible ? have used knockout js also. depending on version you're implementing may need include glyphicons separately, either use bootstrap icons or font awesome.

c# - How to increase the padding of a MSChart Datapoint label -

Image
i created chart control displaying datapoints values labels. how can increase distance between text , label border (padding) label (actually labels). first considered using smartlabelstyle property of series class, think property deals relation between each label instead of appearance. the datapoints not provide options handle padding. maybe can work font property somehow? best regards if can without border have, can datapoint point: point.labelborderwidth = 7; point.labelbordercolor = point.labelbackcolor;

c# - Marshal.Copy, copying an array of IntPtr into an IntPtr -

i can't figure out how copy(intptr[], int32, intptr, int32) method works. though copy data contained in multiple intptrs single intptr (as msdn states) apparently doesn't work expected: intptr[] ptrarray = new intptr[] { marshal.allochglobal(1), marshal.allochglobal(2) }; marshal.writebyte(ptrarray[0], 0, 0xc1); // allocate total size. intptr ptr = marshal.allochglobal(3); marshal.copy(ptrarray, 0, ptr, ptrarray.length); // expect read 0xc1 value random!! byte value = marshal.readbyte(ptr, 0); does know if i'm using method not purpose? static void main(string[] args) { intptr[] ptrarray = new intptr[] { marshal.allochglobal(1), marshal.allochglobal(2) }; marshal.writebyte(ptrarray[0], 0, 100); int size = marshal.sizeof(typeof(intptr)) * ptrarray.length; intptr ptr = marshal.allochglobal(size); marshal.copy(ptrarray, 0, ptr, ptrarray.length); ...

openstack - Devstack Juno: ImportError: No module named persistence.backends.sql -

deploying openstack using devstack ran across error when use keystone commands. [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] traceback (most recent call last): [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] file "/var/www/keystone/main", line 51, in [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] drivers = service.load_backends() [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] file "/opt/stack/keystone/keystone/service.py", line 58, in load_backends [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] token_api=token.manager(), [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] file "/opt/stack/keystone/keystone/common/dependency.py", line 166, in wrapper [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] self. wrapped_init (*args, **kwargs) [thu nov 27 09:20:59 2014] [error] [client 172.20.14.15] file "/opt/stack/keystone/keystone/common/dependency.py", line...

.net - Create custom list view in windows form with c# -

i facing issues in creating custom list view in windows forms c#. in listview want 1 cell text box , 3 cell drop down box or combo box , 1 cell image button. tried make gridview , taking cell combobox not able bind data specific combobox database. tried creating cell coding making false auto generate column still not able bind data combobox in grid view. my code: private void form1_load(object sender, eventargs e) { sqlconnection db = new sqlconnection(configurationmanager.connectionstrings["ram"].connectionstring); db.open(); // string query = @"select itemcode item"; sqlcommand command = new sqlcommand("select itemcode item", db); sqldataadapter adapter = new sqldataadapter(command); datatable dt = new datatable(); adapter.fill(dt); datagridviewcomboboxcolumn cmb = new datagridviewcomboboxcolumn(); //cmb.headertext = ""; cmb.name = "itemcode"; //cmb.maxdropdownitems = 4;...

android - libgdx couldn't load pixmap outofmem -

i had made game , can run without error, sometime throw error don't known why, need help~~~~~~~~ here's error message: exception in thread "lwjgl application" com.badlogic.gdx.utils.gdxruntimeexception: couldn't load file: data/font/fzkt.png @ com.badlogic.gdx.graphics.pixmap.<init>(pixmap.java:140) @ com.badlogic.gdx.graphics.glutils.filetexturedata.prepare(filetexturedata.java:64) @ com.badlogic.gdx.graphics.texture.load(texture.java:142) @ com.badlogic.gdx.graphics.texture.<init>(texture.java:133) @ com.badlogic.gdx.graphics.texture.<init>(texture.java:112) @ com.badlogic.gdx.graphics.texture.<init>(texture.java:108) @ com.badlogic.gdx.graphics.g2d.bitmapfont.<init>(bitmapfont.java:135) @ com.badlogic.gdx.graphics.g2d.bitmapfont.<init>(bitmapfont.java:127) @ com.thtb.game.zy.utils.getfont(utils.java:167) @ com.thtb.game.zy.actor.ygz.takedinfo.<init>(takedinfo.java:53) ...

c# - Attempted to read or write protected memory when using reflection to call dll functions -

i have made plugin system uses reflection call functions in plugin. plugin has implement iplugin interface used. in application uses plugins plugin instance created following code: assembly currentassembly = assembly.loadfrom(startinfo.pluginassemblypath); type[] types = currentassembly.gettypes(); iplugin plugininstance = null; foreach (type type in types) { if (type.fullname == startinfo.plugintypename) { plugininstance = (iplugin)activator.createinstance(type); } } if (plugininstance == null) { throw new exception("plugin loader error: not instantiate plugin: " + startinfo.tostring()); } return plugininstance; i have made plugin uses unmannaged dll's. when call iplugin interface functions in test project in plugin solution works fine. when call plugin via plugin instance made in code shown above system.accessviolationexception: attempted read or write protected memory err...

Invalid memory access when using JNA in JAVA -

i trying use jna call function in mysms.dll read sms device. sms details read smessage, sfrom , stime. however, below error. no idea on causing error. please help. many thanks. c:\users\chi\desktop\sms_pool\install\sms.dll\mysms.dll>set classpath=.;c:\program files (x86)\java\jre7\lib\* c:\users\chi\desktop\sms_pool\install\sms.dll\mysms.dll>"c:\program files (x86)\java\jre7\bin\java" smstest exception in thread "main" java.lang.error: invalid memory access @ com.sun.jna.native.invokeint(native method) @ com.sun.jna.function.invoke(function.java:371) @ com.sun.jna.function.invoke(function.java:315) @ com.sun.jna.library$handler.invoke(library.java:212) @ com.sun.proxy.$proxy0.readsms(unknown source) @ smstest.main(smstest.java:35) api file dll: _declspec(dllexport) bool _stdcall readsms(int comport, int baud, int nindex, char* smessage, char* sfrom, char* stime, bool bdel); java code: import com.sun.jna.library; import...

php - posting data to another url in XML format -

this first controller xmlpost.php <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class xmlpost extends ci_controller { public function index() { $this->load->view('my_view'); $data["id"] = $this->input->post("id"); $this->load->library('session'); $this->session->set_flashdata('$my_var' , $data["id"]); redirect('/xmlreceive/r_data/'); } } ?> this second controller xmlreceive.php <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class xmlreceive extends ci_controller { public function r_data() { $this->load->library('session'); $my_var = $this->session->flashdata('$my_var'); echo $my_var; } } ?> this view taking input in test box <html> <form method="post" action="<?php echo base_url();?...

How to use Python Decorator to change only one part of function? -

i practically repeating same code 1 minor change in each function, essential change. i have 4 functions similar this: def list_expenses(self): explist = [(key,item.amount) key, item in self.expensedict.iteritems()] #create list dictionary, making tuple of dictkey , object values sortedlist = reversed(sorted(explist, key = lambda (k,a): (a))) #sort list based on value of amount in tuples of sorted list. reverse high low ka in sortedlist: k, = ka print k , def list_income(self): inclist = [(key,item.amount) key, item in self.incomedict.iteritems()] #create list dictionary, making tuple of dictkey , object values sortedlist = reversed(sorted(inclist, key = lambda (k,a): (a))) #sort list based on value of amount in tuples of sorted list. reverse high low ka in sortedlist: k, = ka print k , i believe refer violating "dry", don't have idea how can change more drylike, have 2 seperate dictionaries(expensed...

javascript - Remove whitespace from text while preserving newlines -

i want sanitize poetry text, below sample: (used code tag better see hidden characters): მეორდება ისტორია, დღევანდელს ჰგავს გარდასული, რახან ბევრი გვიცხოვრია, ნუთუ დგება დასსარული?! არა! არ თქვა დავბერდითო, ნუ მაჯერებ, რაც არ მჯერა, არ მწამს სიტყვა ავბედითი, რომ ჩამძახონ ათასჯერაც! i tried with: function sanitize(txt) { txt = txt.replace(/\s+\n/g, "\n"); return txt; } it works removes new lines between paragraphs. want remove white space end , start each line , leave new lines as presented i know it'd easy solve i'm stuck thanks \s matches spaces including line breaks. txt.replace(/^ +| +$/gm, ""); this removes 1 or more horizontal spaces (except tabs) present @ start or @ end of line.

javascript - How to escape double quotes in Node.js -

i have tried / escape double quotes in string not able desired string. the code snippets follows in node.js var querystring = "select * courier couriername '%"+filtername+"%'"; console.log(querystring); the output getting double quotes included on console: select * courier couriername '%"a"%' but want output this select * courier couriername '%a%'; how .. have tried many things ... seems me filtername equal "a" , not a can log value ?

javascript - Prevent Bootstrap modal window from opening in new tab / window -

i using bootstrap 3 , looking way prevent modal dialog windows open open in new tab / window. modal window has opened (on top of current window) direct click , not displayed when user right clicks on "open in new tab / window". appreciated, thanks on element can use oncontextmenu <ul class="nav nav-tabs" oncontextmenu="return false;"> <li><a href="#tab1" data-toggle="tab">tab1</a></li> <li><a href="#ab2" data-toggle="tab">tab2</a></li> </ul>

javascript - How to update bound data in d3.js? -

i want update network graph dynamically in d3.js. code is: var color = d3.scale.category20(); var my_nodes = [{"cluster": 0, "x": 50, "y": 50}, {"cluster": 0, "x": 100, "y": 50}, {"cluster": 1, "x": 100, "y":100}]; var vis = d3.select("body").append("svg").attr("width", 500).attr("height", 500); var nodes = vis.selectall("circle.node").data(my_nodes).enter().append("g") .attr("class", "node"); var circles = nodes.append("svg:circle") .attr("cx", function(d) { return d.x; }) .attr("cy", function(d) { return d.y; }) .attr("r", 5) .style("fill", function(d) {return color(d.cluster)}); this code works. when update data like: var new_nodes = [...

c# XML serialisation of child class - remove xmlns:p1 and p1:type attributes from root node -

using bog-standard system.xml.serialization.xmlserializer, serializing object who's class inherits another. inspecting resulting xml, root node being given attributes "p1:type" , "xmlns:p1": <apisubmission apiversion="1" custid="100104" p1:type="orderconfirmationapisubmission" xmlns:p1="http://www.w3.org/2001/xmlschema-instance"> ... </apisubmission> is there nice way remove these attributes?

asp.net - when i access my MVC site it works great but when i access same with domain name it ask for authentication -

Image
i working on site working great @ space when put on hosting server , access with domain name . ask me authentication @ pages. at same when access ip address works fine.. screenshot thank in advance

php - Retrive recent videos of multiple YouTube users and order by most recent -

so title suggests looking use php retrive recent videos , json data multiple youtube channels. have looked around stackoverflow , cannot find reply user looking (even tweaking.) i able use code grab uploaded youtube videos single user. <?php $xml = simplexml_load_file("https://gdata.youtube.com/feeds/api/users/1jboa_hgxttggs8oirfykg/upload s"); $json = json_encode($xml); $videos = json_decode($json, true); var_dump($videos); note: code have shown work looking code display videos multiple users in order. thanks in advance :) if know name of users, guesing do, put them in array , iterate on array using code have working above inside each iteration. // array of users (dummy values....) $users = array("1jboa_hgxttggs8oirfykg", "4dfg_hgxttggs8oirfykg", "6dzgdf_hgxttggs8oirfykg"); $allvideolists = array(); // iterate on each user in 'users' array 1 one foreach ($users $thisuser) { //get video list use...

github - How can i find issue cause in git? -

i have git issues (not again huuummmmpf): cannot push specific branch i've re-pull re-push pull -rebase , re-push . nothing new happened. (i've figured out way send work) have field of search suggest? i want able of resolving issue myself in future. actually, not having answers student understandable. bit lost , ressourceless case (and makes me quite uncomfortable). can found clues figure out happening damn repo. ps: had many projects saved efforts, of you. $ git pull origin stef github.com:pierrend/approfusion * branch stef -> fetch_head up-to-date. $ git pull --rebase origin stef github.com:pierrend/approfusion * branch stef -> fetch_head current branch 25_push date. $ git push origin stef git@github.com:pierrend/approfusion.git ! [rejected] stef -> stef (non-fast-forward) error: failed push refs 'git@github.com:pierrend/approfusion.git' hint: updates rejected because pushed branch tip beh...

html - How ot achive table cells combined of fixed width and shrinked to content? -

assume have table, of cells should have equal content, fixed , others fill rest. used 100% method lost fixed size. every thing do, can not achieve both: .thetable{ display:table; width:80%; /* or whatever width table*/ height: 200px; } .thecell{ display:table-cell; padding:0px 2px; white-space: pre; /* avoid line breaks*/ border:1px solid black; vertical-align: middle; } .bigcell{ width:100%; /* shrink other cells */ } .fixedcell { height: 40px; width: 70px; } any helps? fiddle: http://jsfiddle.net/80nmuxs8/4/ here fix http://jsfiddle.net/80nmuxs8/5/ if set width of cell want filled according contents 1%, grow according content. the .bigcell doesn't need width take remaining space. .contentcell {width: 1%}

database - Using OleDb.OleDb??? vb code ExecuteReader: Connection property has not been initialized -

i trying load datagridview call dgvinfo information database. quite new vb , don't understand problem lies in code @ moment. private sub frmproductinformation_load(byval sender system.object, byval e system.eventargs) handles mybase.load dim conn new oledb.oledbconnection dim dt new datatable dim cmd new oledb.oledbcommand() dim readit oledb.oledbdatareader conn.connectionstring = "provider=microsoft.ace.oledb.12.0;data source=n:\data\gamehq.accdb" conn.open() readit = cmd.executereader() readit.read() dt.load(readit) dgvinfo.datasource = dt dgvinfo.refresh() conn.close() end sub this code , hope able point out if i've missed something. you have initialize cmd. assuming don't use transactions, put query , connection cmd. btw - didn't specify sql query yet: dim conn new oledb.oledbconnection dim dt new datatable dim readit oledb.oledbdatareader conn.connectionstring = "provider=microsoft.ac...

plot - How to change the range of my x-axis in matplotlib -

Image
i trying plot list of 30.000 values. name of list "velocity_x". plot them following command: plot(velocity_x,'r') the result shown in image below (do not pay attention dashed line) since using command line, creates automatically x-axis of length 30.000. changing range of x-axis in such way show time(s) instead of iterations t = 0.0002 * iteration. you use linspace : a=np.linspace(0,6,len(velocity_x)) plot(a, velocity_x, 'r' )

json - Spring @ReponseBody @RequestBody with abstract class -

suppose have 3 classes. public abstract class animal {} public class cat extends animal {} public class dog extends animal {} can this? input: json dog or cat output: dog/cat depends on input object type i dont understand why following code doesnt work. or should use 2 separate methods handle new dog , cat? @requestmapping(value = "/animal", method = requestmethod.post, produces = "application/json; charset=utf-8") private @responsebody <t extends animal>t insertanimal(@requestbody t animal) { return animal; } update: sry forget include error message http status 500 - request processing failed; nested exception java.lang.illegalargumentexception: type variable 't' can not resolved ref link i found answer myself , here reference link. what have done added code above abstract class import com.fasterxml.jackson.annotation.jsonsubtypes; import com.fasterxml.jackson.annotation.jsontypeinfo; import com.fasterxml.jacks...

After changing mysql table engine, the old table will be deleted? -

for example, if execute: mysql-> alter table mytable engine = innodb it change mysql table engine, old table copy new table row row. question is: when copy completed, old table reserved or auto deleted or execute drop old_talbe myself?

java - How to add associated text for input text in Struts html? -

<tr> <td valign="top" width="150"> <label for="mfyr">maximum factory year</label> <!-- <label for="mfyr"><span style="color: rgb(255, 51, 0);" class="fnt">*</span></label></td> skl--> <span id="mfyr" style="color: rgb(255, 51, 0);" class="fnt">*</span> <td width="7"><br /> </td> <td valign="top" width="140"> <%-- <html:text styleid="mfyr" property="maximumfactotyyear" size="15" styleclass="iform" /></td> --%> <html:text id="mfyr" property="maximumfactotyyear" size="15" styleclass="iform" /> this code there. using rational policy tester(rpt), getting policy violation of "each form control must have associated text."... please me in sorting out issu...

javascript - Check if number is in an array an generate new number if it is -

i'm making simple script create random number. intent of script cache each random number in array , loop through array when generating new numbers see if previous 1 had been used. if has been used script continue looping until number created not in array, , return that number. wrote code below , logic simple enough don't know why works when launched sometimes , blows stack @ other times without returning number. var oldnumbs = [1,2,3,4,6,7] // dummy data var randomnumb = math.floor((math.random() * 10) +1); function checkifinarray(value, array) { if(array.indexof(value) > -1){ randomnumb = math.floor((math.random() * 10) +1); checkifinarray(value, array) } else{ return randomnumb } } console.log(checkifinarray(randomnumb,oldnumbs)); /* returns number not in array , blows stack. blows stack. */ simple mistake is. need pass randomnumb instead of value since randomnumb new random number generated. checkifinarray(randomnumb , ar...