Posts

Showing posts from September, 2012

java - kotlin: some problems with arrays in annotations -

java - kotlin: some problems with arrays in annotations - i have problem in annotations: entity table(uniqueconstraints = array(uniqueconstraint(columnnames = array("key", "userid")))) public class ... in case next error: type inference failed. expected type mismatch: found: kotlin.array required: kotlin.string there no problems uniqueconstraints = array(...) thought shows me error in columnnames = array(...) i using hibernate-jpa-2.1-api-1.0.0.final.jar workaround: instead uniqueconstraints using composite key (@javax.persistence.idclass) use spread operator: uniqueconstraint(columnnames = *array("key", "userid")) java arrays hibernate jpa-2.0 kotlin

C++ OpenCV get Bounding Box From Vector Of Points -

C++ OpenCV get Bounding Box From Vector Of Points - i have vector of points drawed self : std::vector<cvpoint> shape1 = paintshape(0); now need bounding box object (points) around shape , i have searched web answeres every topic talking recognizing border of object within whol image file , making bounding box. in case different , thanks ! get boundingrect points: #include "opencv2/imgproc/imgproc.hpp" // please utilize stuff cv:: namespace, not outdated cv* std::vector<cv::point> shape1 = paintshape(0); cv::rect r = cv::boundingrect(shape1); c++ opencv

c++ - Structure aggregate initialization with less clauses, why does it initialize everything? -

c++ - Structure aggregate initialization with less clauses, why does it initialize everything? - if have mutual linux struct like: struct sockaddr_in { sa_family_t sin_family; in_port_t sin_port; struct in_addr sin_addr; unsigned char __pad[__sock_size__ - sizeof(short int) - sizeof(unsigned short int) - sizeof(struct in_addr)]; }; #define sin_zero __pad and perform aggregate initialization: struct sockaddr_in my_addr = { 0 }; how come initializes every fellow member 0? i mean: documentation says: if number of initializer clauses less number of members or initializer clauses empty, remaining members initialized brace-or-equal initializers, if provided in class definition, , otherwise (since c++14) empty lists, performs value-initialization. to create easy: why code print 0? struct sockaddr_in my_addr = {2, 2}; // initialize sin_family , sin_port 2, else value-initialized my_addr = {0

java - How to connect to Firebird using LibreOffice -

java - How to connect to Firebird using LibreOffice - i have create reports using libreoffice. need connecto firebird database using jdbc. installed driver (adding classpath) , configured connection use class="lang-none prettyprint-override"> firebirdsql://server:alias org.firebirdsql.jdbc.fbdriver when test class error: class="lang-none prettyprint-override"> "could not load driver class org.firebirdsql.jdbc.fbdriver" javax/resource/resourceexception i tried in machine , got same message. there should added classpath? i´m missing here? have both jre , jdk installed , i´m using first located in c:\program files(x86)\java\jre7. there no classpath environment variable defined nor global or user jaybird has required dependency on jca (java connector architecture), jca 1.5 (although newer should work well), documented in jaybird 2.2.5 releasenotes, this means need include either connector-api-1.5.jar (from lib folder) on cla

java - When select is faster than a for? -

java - When select is faster than a for? - imagine situation, have id of entity , have liked list entities of same class. find the entity, when faster in linked list or select @ database? i mean, when have 5 entities in linked list, example, imagine faster, , when have millions of entities select faster. but when select starts faster for? it faster after 1e5 elements on machine*. baseline selecting table 1 record trough jpa 1ms. confidence interval (99.9%): [0,747, 1,087] select 1e5 records take same time(1ms) lower bound increment 0.1ms. sequential search in list of 1e5 elements desired element placed lastly takes 2ms. confidence interval (99.9%): [2073669,347, 2514442,020] ammortize dividing 2 random postition of desired element. fyi getting entity map of 1e5 elements take less 30ns here benchmark peer review: entitymanagerfactory emf; list<individual> list; map<integer, individual> map; @setup public void setup() { emf = pe

objective c - How can i convert NSDate to NSString ios? -

objective c - How can i convert NSDate to NSString ios? - i'm receiving date server next format "/date(1413374176217)/" . tried this nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"dd-mm-yyyy"] nsdate *datefromstring = [[nsdate alloc] init]; datefromstring = [dateformatter datefromstring:date]; nslog(@"datefromstring = %@",datefromstring); but doesn't work. how can convert string? try this. nsstring *actdate = @"/date(1326067200000)/"; nsstring *ndate = [[[[actdate componentsseparatedbystring:@"("] objectatindex:1] componentsseparatedbystring:@")"] objectatindex:0]; nsdate *date = [nsdate datewithtimeintervalsince1970:([ndate doublevalue] / 1000)]; ios objective-c nsstring nsdate nsdateformatter

android - Loading ListViewItems Bitmaps causes crash -

android - Loading ListViewItems Bitmaps causes crash - as title says, loading bitmaps tlistviewitems causes android apps crash. works ios, not android. image paths correct. simplicity sakes, can drop timage onto form, , manually set 1 image it, seek instead of going through loop did, set litem.bitmap := timage1.bitmap . doing wrong? or can confirm , perchance help me out work around now. delphi xe7 android if menulist.items.count=0 // load menu options + icons begin := 0 length(picturepaths)-1 begin litem:=menulist.items.add; litem.text := picturenames[i]; litem.bitmap.loadfromfile(tpath.gethomepath+pathdelim+picturepaths[i]); end; end; update this happens if tlistview.itemappearance.item.appearance not set 1 of options starting imagelistitem . in situation bitmap property not assigned. since xe7 possible have different settings controls different devices. possible have set imagelistitem , other device listitem , exception

python - Phylogenetic Tree Coloring -

python - Phylogenetic Tree Coloring - i have created phylogenetic tree of bunch on enzyme sequences have. have in simple format scores displayed , no coloring. sequences have restriction enzymes , each of them have motif . want color enzyme branches having similar motifs . spent improve part of yesterday looking @ different softwares help me ended confused. i wanted know tool takes trees either in newick format or takes in alignment information. , allow me impart color based on similar motifs. i came across tool : http://etetoolkit.org/ , requires big number of dependent libraries in turn have dependencies little or no documentation of installation errors. i used phylo class biopython library develop trees. used next command generate tree scores: phylo.draw(tree,branch_labels=lambda c: c.branch_length) figtree (http://tree.bio.ed.ac.uk/software/figtree/) phylogenetic tree viewer allows customizable coloring. it's not clear me how know enzyme has motif. i

java - How to style DockPanel.NORTH element independently of DockPanel.CENTER in GWT -

java - How to style DockPanel.NORTH element independently of DockPanel.CENTER in GWT - in gwt app i'm using dock panel in dockpanel.north menubar component, implementing navigation bar while component in dockpanel.center position displays different panels according alternative selected in navigation bar (is deckpanel ). my problem navigation bar on dockpanel.north aligned left. when deckpanel switches wider component navigation bar moves too. each panel in deckpanel navigation bar in different position, annoying user. great me component in dockpanel.north centered, seems can center dockpanel itself, not component in dockpanel.north . all components in dockpanel styled with .navigationpanel{ margin-left: auto; margin-right: auto; text-align:justify; } the gwt ui binder menubar item is: <g:dockpanel> <g:dock direction='north' > <g:menubar ui:field="mainmenu"/> </g:dock> </g:dockpanel&g

php - Codeigniter image resize library not working properly -

php - Codeigniter image resize library not working properly - for($i=0; $i< count($data['upload_data']); $i++){ //resize uploade image $config['image_library'] = 'gd2'; $config['source_image'] = $data['upload_data'][$i]['full_path']; $config['new_image'] = $data['upload_data'][$i]['full_path']; $config['maintain_ratio'] = true; $config['width'] = 700; $config['height'] = 700; $this->load->library('image_lib', $config); $this->image_lib->resize(); $this->image_lib->clear(); } i want resize images in loop, images in database, after running script, first image resized. all path correct, else encountering problem? after loading image_lib might need initialize it. $this->load-&

c# - Extension methods equivalents for CAR and CDR in .Net's Linq/IEnumerable -

c# - Extension methods equivalents for CAR and CDR in .Net's Linq/IEnumerable - i know can someenumerable.first() . there's no .rest . i know write one, wondering if missing something. related question: are there ruby equivalents car, cdr, , cons? for cdr can utilize enumerable.skip(1) like: var cdrresultquery = someienumerable.skip(1); consider next example: ienumerable<int> someienumerable = new list<int> {1, 2, 3, 4, 5}; var cdrresultquery = someienumerable.skip(1); foreach (var in cdrresultquery) { console.writeline(i); } and get: 2 3 4 5 c# linq ienumerable

html - finding if a file exists in a directory in php -

html - finding if a file exists in a directory in php - i have exhausted brain , cant seem way construction code, solution have works need simplify it. ok have $id = $_get["id"]; , $id = 352 ... now, scenario: the code below user selects image upload: $query = mysql_query("select * properties id = '$_get[id]'"); <input type="file" name="image1" id="image1" /> <?php if(isset($query) && file_exists("../uploads/properties/".mysql_result($query, 0, "id").".jpg")) { ?> <img height="100" src="../uploads/properties/<?php echo mysql_result($query, 0, "id"); ?>.jpg" /> <a target="_blank" href="delete_script/deletepic.php?id=<?php echo mysql_result($query, 0, "id"); ?>">delete image</a> <?php } ?> <input type="file" name="image2" id="image2" /&

php - Cant json_encode form data -

php - Cant json_encode form data - i got ajax request method, send info to. my ajax phone call follows: $.ajax({ url: btn.data('url'), type: 'post', data: {_method: 'delete', _token: token, items: json.stringify(_items)}, success: function () { // } }) where token read meta tag , _items array id's. when inspect ajax call, form info contains: _method:delete _token:15kebpmbt7wvgm8kncwg4idqcw3fpgykzrepn8fu items: ["4","11","15"] but when dd(json_decode(input::get('items') returns: 0: 3 1: 0 2: 4 3: 1 4: 1 5: 11 6: 2 7: 2 8: 15 9: 2 edit: when remove json.stringify formdata contains: items[]:1 items[]:2 and returns array of: 0: 2 1: 0 2: 1 3: 1 4: 1 5: 2 6: 1 here route catch: route::delete('user/destroy/multiple', function() { dd(input::get('items')); }); i don't know going wrong... php

Convert from Byte Array to String and compare against another String (java) -

Convert from Byte Array to String and compare against another String (java) - i have udp server/client sends , receive information. client send illustration "test" server, server receive "test" in byte[] array representation , convert string using string(byte[]) constructor. need compare new string received against string using equalsignorecase method. it's not working... here's sample of code : datagrampacket receivepacket = new datagrampacket(receivedata, receivedata.length); serversocket.receive(receivepacket); //client sent "test" string sentence = new string(receivepacket.getdata(), "utf-8"); system.out.println("received: " + sentence); system.out.println(sentence.equalsignorecase("test")); //this gives me false any ideas? the explanation string in sentence not "test" looks like "test" when display it. strings are: " test" or "test " &q

winforms - Telerik RadGridView change cell color depending of another cell value using C# -

winforms - Telerik RadGridView change cell color depending of another cell value using C# - i'm using telerik radgridview . i'm trying alter color of 1 cell depending on value of cell. i'm trying accomplish using code: if (e.column.name == "coldate" && !string.isnullorempty(e.cellelement.value.tostring())) { if (datetime.now > datetime.parse(e.cellelement.value.tostring())) { e.row.cells["colcolor"].style.drawfill = true; e.row.cells["colcolor"].style.backcolor = color.red; e.row.cells["colcolor"].style.numberofcolors = 1; } } but reason doesn't alter color. noticed when replace e.row.cells["colcolor"].style with e.cellelement it changes color. changes color of wrong cell (what totally logical because it's on current cell). don't want alter current cell. any suggestions? you can utilize rule based formatting objects documented in tele

javascript - QUnit multiple scripts in one page but no interaction between them -

javascript - QUnit multiple scripts in one page but no interaction between them - i'm new unit testing (this first day working qunit , i've never worked other testng scheme before), , i'm bit unclear on how test stuff multiple script files in 1 qunit page without letting scripts interact each other. mean is, say, if have script1.js , , calls hello() , , hello() defined in script2.js , how can run unit test on script1.js create sure calls hello() , mock output of hello() it's true unit test, , run script2.js 's hello() . basically, how supposed hide 1 script's global variables , functions script in single qunit page? this depends exclusively on how various script files organized scheme whole. if using angular, example, able inject dependencies when include module in script file. there tools mocking out things , "spying" on function calls such sinon, still depends heavily on how code organized. for sake of argument, let's 2 fil

arrays - Time limit exceeded in bubble sort -

arrays - Time limit exceeded in bubble sort - problem-to sort array in ascending order algorithm used-bubble sort error-time limit exceeded compiler-ideone online editor /codeblocks possible alternative this? int a[5]; int i,t,j; for(i=0;i<=4;i++) //for initialising elements { printf("enter 5 numbers"); scanf("%d",&a[i]); } for(j=0;j<5;i++) //for sorting { for(i=0;i<5;i++) { if(a[i]>a[i+1]) { t=a[i+1]; a[i+1]=a[i]; a[i]=t; } } } for(i=0;i<=4;i++) //for printing sorted array { printf("%d\n",a[i]); } your loop: for(j=0;j<5;i++) //for sorting should j++, should be for(j=0;j<5;j++) your sec loop: for(i=0;i<5;i++) should for(i=0;i<4;i++) arrays sorting bubble-sort

html - Responsive CSS grid won't allow for proper spacing -

html - Responsive CSS grid won't allow for proper spacing - i trying create page html , css3, unfortunately lastly time coded css3 wasn't thing yet. trying set images in reactive grid, grid keeps coming out looking this: as can see other items aren't showing because assume not think there plenty room, here responsive css code using: http://pastebin.com/qazmcrby here css using on div: .portfolio-section { } .portfolio-box { position:relative; overflow:hidden; margin-bottom:5px; } .js .portfolio-box { opacity:0; } .portfolio-box:hover .portfolio-caption { opacity:1; -ms-filter: "progid:dximagetransform.microsoft.alpha(opacity=95)"; filter: alpha(opacity=95); } .portfolio-image { margin:0; } .portfolio-image img { display: block; width: 100%; box-shadow:0 0 0 0 #000000; } .portfolio-caption:before, .portfolio-title { display: inline-block; vertical-align: middle; } .portfolio-caption:before {

python - SQLAlchemy insert select query from case statement to FROM clause -

python - SQLAlchemy insert select query from case statement to FROM clause - i have case statement saved in variable like: article_video_exists = exists( select([1], correlate=false, from_obj=article_video_t).where( article_video_t.c.article_id == article_t.c.id)) has_videos_case = case([(article_video_exists, 1), ], else_=0).label( 'has_videos') and utilize case select([has_videos_case], from_obj=article_t) after executing, saw in query statement from article_t, (select 1 article_video_t article_video_t.article_id=article_t.id) and error should utilize alias. tried utilize alias select in case, it's not fixed problem. tried pass correlate=false select clauses, it's not help, if pass case in final select clause without using variable, it's work , not generate invalid clause. but after have many duplicating code, how utilize variable case in situation? thanks. fixed using select(...).correlat

python - Pygame Keyup/Keydown -

python - Pygame Keyup/Keydown - i'm making little mario school's computer club. (well, part of team.) anyway, i'm having problem "keyup/keydown" commands. here's code: # 1 - import library import pygame pygame.locals import * # 2 - initialize game pygame.init() width, height = 1280, 1000 screen=pygame.display.set_mode((width, height)) keys = [false, false, false, false] playerpos=[100,100] # 3 - load images player = pygame.image.load("images/totallynotgodzilla.png") # 3.1 - load sound music = pygame.mixer.sound("audio/skyrim.wav") # 4 - maintain looping through while 1: # 5 - clear screen before drawing 1 time again screen.fill(0) # 6 - draw screen elements screen.blit(player, playerpos) # 7 - update screen pygame.display.flip() # 8 - loop through events event in pygame.event.get(): if event.type == pygame.keydown: if event.key==k_w: keys[0]=true

How to include es5-shim in browserify bundle -

How to include es5-shim in browserify bundle - should next in entry point: var es5shim = require('es5-shim'); that gets included in bundle seems there has improve way , i'm missing it. use -r require additional dependencies: $ browserify -r "es5-shim" ... browserify es5-shim

max - Maximum Value of subarray -

max - Maximum Value of subarray - is there function returns maximum number subarray of longint array? for example: i have array: [2,3,6,2,9,4,2,4] i want maximum value of first 5 elements [2,3,6,2,9] of array (9) which best solution? you don't need create array. 1st solution come loop within array, taking first value 'tempmaxvalue', , fetching array comparing each value 'tempmaxvalue'. if value greater 'tempmaxvalue', update 'tempmaxvalue' particular value , jump next value in array, otherwise jump next value. with solution, can manage number of items want search (here wanted greatest number within 5 first elements, loop go 0 4) edit : (as @tlama said) max pascal freepascal arrays

java - Why my compare() method can not refer to a model class field or method? -

java - Why my compare() method can not refer to a model class field or method? - i did defined employee class name , getsalary() method, when define mycomparator, recognize emp1 , emp2 employee class not recognize name , getsalary() method (dundefined). import java.util.comparator; public class mycomparator<employee> implements comparator<employee> { @override public int compare(employee emp1, employee emp2) { string s = emp1.name; if (emp1.getsalary() < emp2.getsalary()) { homecoming -1; } else if (emp1.getsalary() == emp2.getsalary()) { homecoming 0; } else homecoming 1; } // compare method } // mycomparator class public class employee { private int salary; public string name; employee(string n, int s) { salary = s; name = n; } public int getsalary() { homecoming salary; } } the right syntax : public class myc

java - Color Conversion RGB to HSV using formula -

java - Color Conversion RGB to HSV using formula - i asked write programme based on java convert colors rgb hsv , not allowed utilize java.awt.color, far efforts got me level, don't know how create console read other methods reads main method.. public class colorconversion { public static void main(string[] args) { system.out.println("nope"); } void rgbtohsv( float r, float g, float b, float h, float s, float v ) { r=input.readfloat(); float min, max, delta; min = min( r, g, b ); max = max( r, g, b ); v = max; // v delta = max - min; if( max != 0 ) s = delta / max; // s else { // r = g = b = 0 // s = 0, v undefined s = 0; h = -1; return; } if( r == max ) h = ( g - b ) / delta; // between yellowish & magenta else if( g == max ) h = 2 + ( b - r ) / delta; // between cyan & yellowish else h = 4 + ( r - g ) / delta; // between magenta & cyan h = 60; // degrees if(

asp.net - Table into Tree Structure c# -

asp.net - Table into Tree Structure c# - i have next info construction , wanting turn tree. have working recursion wondering if there more efficient/better way? public class construction { public int id {get;set;} public int level1 {get;set;} public int level2 {get;set;} public int level3 {get;set;} public int level4 {get;set;} } var info = new list<structure> { new structure{id=1,level1=1,level2=11,level3=35,level4=105}, new structure{id=2,level1=1,level2=11,level3=35,level4=106}, new structure{id=3,level1=1,level2=11,level3=36,level4=107}, new structure{id=4,level1=1,level2=11,level3=36,level4=108}, new structure{id=5,level1=1,level2=11,level3=36,level4=109}, new structure{id=6,level1=1,level2=11,level3=36,level4=110}, new structure{id=7,level1=1,level2=11,level3=36,level4=111}, new structure{id=8,level1=2,level2=12,level3=37,level4=112}, new structure{id=9,level1=2,level2=12,level3=37,level4=113}, new

laravel - Processing a php POST request prior sending to API -

laravel - Processing a php POST request prior sending to API - i have faced problem on , on again. scenario: communicate info api using post request (this time it's payment form, user enters details , gets redirected payment gateway create actual transaction via credit card or whatever..), far good. one of fields commonly required apis in scenario hash field or such, (basically field md5 hashes of fields entered + secret merchant key). now.. the way hash these fields + secret key securely via server-side language (i utilize php). i got around problem taking user's original input, processing , hashing it, prompting user sec page, api required fields hidden it included hash too , asked user click "confirm" button triggering post request api's required fields. here's issue: don't prompting user sec "confirm" page/button. i'm using laravel, there way take user's input, process , hash needs hashed , automatically redir

Angularfire Seed Routes -

Angularfire Seed Routes - is there detailed illustration of how modify routes in angularfire seed? although seems should straightforward edit of routes.js , partial html pages have not been able way. missing? routes angularfire ngroute

Disable core PHP extension on Travis CI -

Disable core PHP extension on Travis CI - i'm looking add together travis-ci job tests library works without php intl extension beingness installed (see https://github.com/giggsey/libphonenumber-for-php/pull/46). the intl extension in php build, , there doesn't appear way turn off. there one? there's no way on travis because many php extensions compiled straight php (intl included). issue track/comment on if need functionality here: https://github.com/travis-ci/travis-ci/issues/4701 note of august 19, 2015, can run docker containers on travis. in order test , without mcrypt extension, i've been using official php docker container, , conditionally installing mcrypt. can see how implemented here: https://github.com/cweagans/mcrypt-polyfill php php-extension travis-ci intl

Ruby on Rails performance on lots of requests and DB updates per second -

Ruby on Rails performance on lots of requests and DB updates per second - i'm developing polling application deal average of 1000-2000 votes per sec coming different users. in other words, it'll receive 1k 2k requests per sec each request making db insert table stores voting data. i'm using ror 4 mysql , planning force heroku or aws. what performance issues related database , application should aware of? how can address amount of inserts per sec database? edit i thinking in not inserting db each request, instead writing memory stream insert data. have scheduled job running every sec read memory stream , generate mass insert, avoiding each insert made atomically. cannot think in nice way implement this. while can need in aws, high level of i/o cost you. rds can back upwards 30,000 iops; can utilize multiple ebs volumes in different configurations back upwards high io if want run database yourself. depending on planned usage patterns, @ pus

enterprise guide - SAS: Conditional choice of library -

enterprise guide - SAS: Conditional choice of library - i have same table name in 2 different libraries, , want utilize status in origin take library utilize (sas enterprise guide). possible utilize variable library accomplish below? if(txt = 'tst") select * tst.tablename else select * form dev.tablename the best way varies based on defines txt . if choosing based on user input (in example, user chooses test or dev (or prod) database point to), best way in enterprise guide create prompt create macro variable, or secondarily straight create macro variable. ben cochran's paper be prompt now: creating , using prompts in sas enterprise guide introduction topic, other sources online. can set prompt asks user environment point to, , define macro variable value of choosing. add together prompt programme need related to, , presto, works. so in case, have set variable &env. contains value of table name ( tst or dev ). have command libna

Force new drive request even if not modified -

Force new drive request even if not modified - getting grips google drive api - working ok. i have nested requests can save/update file. each nested request gets me id of parent folder - top parent, sec parent. lastly request resolves jquery promise id 'parents' alternative of file save metadata object: 'parents' : [{'id' : invoicefolderid}] when load web page , carry out file save first time - works ok. subsequent attempts fail because sec nested request folderid not run - firebug shows get request 'not modified'. hence jquery promise not resolved , chain of promises fails. don't want store folderid in variable on first time because code used apply multiple objects on same page share top parent id - sec not going work of them - 'not modified'. any thought how forcefulness get request if not modified? google-drive-sdk

javascript - HTML5 Page Loading Issues (using jQuery + JS + HTML5) -

javascript - HTML5 Page Loading Issues (using jQuery + JS + HTML5) - my service pages have loading/displaying issues. i using jquery ui - tabs outer , inner tabs , "footable" component display table records. jquery tabs & footable component prepared in jquery ready method. $(document).ready(function(){ $( "#tabs" ).tabs(); $( "#tests" ).tabs(); $('.footable').footable(); .... } from reason page displayed before ui positioned , page has poor layout effects looks unprofessional. is there problem jquery tabs requires initialize them in other way? appreciate idea... example: here how page looks before positioned here how page looks after positioned ran problem before using jquery tabs other table plugins. jquery ui's tabs have activate event fires when click tab. need phone call footable's redraw() method within that. $('#tests').tabs({

php - Changing the content of jquery mobile -

php - Changing the content of jquery mobile - i developing mobile app using jquery mobile framework , alter page content using javascript , ajax don't expected result.could help me please. here code : connection.php class="lang-php prettyprint-override"> <?php $dbhost="localhost"; $dbuser="root"; $dbpass=""; $db="mobileapp"; $conn=mysql_connect($dbhost,$dbuser,$dbpass) or die("could not connect"); mysql_select_db($db); ?> index1.php class="lang-php prettyprint-override"> <?php include 'connection.php'; $fetch="select * users"; /** $result=mysql_query($query) or die(mysql_error()); //while($person=mysql_fetch_array($result)){ $person=mysql_fetch_array($result) echo json_encode($person);**/ while ($row = mysql_fetch_array($fetch, mysql_assoc)) { $row_array['id'] = $row['id']; $

javascript - Combobox will not display loaded store data -

javascript - Combobox will not display loaded store data - i using extjs 4.2 , when print store in loadcombobox() , items present, not appear in drop-down. drop-down empty. here jsfiddle demo. class="lang-js prettyprint-override"> ext.define('reportfieldmodel', { extend: 'ext.data.model', fields: [{ 'name': 'name', 'type': 'string' }] }); ext.define('reportfieldcombostore', { extend: 'ext.data.jsonstore', model: 'reportfieldmodel' }); var config = { 'type': "summary", 'columns': [ "red", "yellow", "orange", "green", "blue", "indigo", "violet"] }; function processitem(item) { homecoming ext.create('reportfieldmodel', { name: item }); } function processitems(data) { v

Array index out of bound exception for palindrome java program -

Array index out of bound exception for palindrome java program - why getting array bound of exception? im beginner in programming. please help me understand. have tried convert string char array , reverse characters , convert end result string , compare original string /* check if entered string palinrome or not*/ class palin { public static void main(string[] args) { string name="anna"; int l=name.length(); int d=l/2; char tmp; char tmp1; char[] arr = name.tochararray(); for(int j=0;j<d;j++) /*to swap characters*/ { tmp=arr[j]; tmp1=arr[l]; arr[j]=tmp1; arr[l]=tmp; l=l-1; } string str=string.valueof(arr); /* convert swapped char array string*/ if (str==name) system.out.println("true"); else system.out.println("false"); } } an array of n entries can accessed index between 0 , n-1 . change this: tmp1 = arr[l]; to this: tmp1 = arr[l-j-1]; and rid of this: l = l-1; by way, swapping can done in 3 assignment operat

Duration format in google speadsheet -

Duration format in google speadsheet - i'm trying apply duration format cells in google speadsheet. convert integer number in format: x days x hours x minutes. i've tried formats like: d:h:mm found problem when apply format. set 1 day less. when write 1 in cell convert 31:0:00. when write 2 cells changes 1:00:00. does know how solve this? that because duration format date / time format (for comparing dates). if come in number (1) google interpret midnight (as times stored fractions of whole days) of reference day number 1 . reference day in google sheets 31/12/1899 - ie 31st day of month. why result returns days=31. to accomplish want want add together 1 values. 1 (+1) becomes "2 days since 31/12/1899 - ie 01/01/1900 - ie 1 day, , utilize custom format display, wont work when have >31 days. i think best way concatenate info have relavent parts (where a1 cell containg info - 1,2,1.5 etc): =int(a1)&" days "&int(mod(a1,

c# - Design patterns in a reporting solution -

c# - Design patterns in a reporting solution - i'm creating web reporting solution , trying adapt graphics telerik. realized there alternative of mvvm design pattern in list of examples have. there list of preferred design patterns [web] reporting solution? more detail: i'm looking programming design patterns utilize before dive coding. , reporting solution mean sole purpose of solution show interactive graphs online. used in mobile apps later too. i'm planning utilize .net c# write this. suggestion appreciated. there lot of available resources start: msdn the 23 gof to avoid duplicate other answers - head first design patterns - code samples codeplex and if want piece of advice - @ developed tools about and reporting solution mean sole purpose of solution show interactive graphs online. like: open source charting & reporting tools winward davechart c# design-patterns mvvm reporting telerik-reporting

C# Append byte array to beginning of a file (without loading entire file in memory) -

C# Append byte array to beginning of a file (without loading entire file in memory) - question: possible (and how?) append byte array existing file without loading entire file in memory. to more specific: goal transform this: 00000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00000010 00 00 10 00 00 00 08 00 08 02 00 00 00 29 f0 61 00000020 e9 00 00 00 09 70 48 59 73 00 00 17 12 00 00 17 00000030 12 01 67 9f d2 52 00 00 20 00 49 44 41 54 78 da 00000040 dc bd db 76 24 39 ae 2c 08 f0 e2 1e aa ea f9 ff 00000050 ff 9c 5e a7 53 ee bc 60 1e 8c 80 c3 af 0a 29 b3 00000060 76 ef 33 7a a8 a5 52 46 f8 85 04 41 10 30 33 30 00000070 33 d3 37 7f 44 e4 07 df fa 5f f5 c3 cc 22 f2 f0 00000080 af 97 6f 8a af e0 bb 0f 57 b0 7f 12 22 3e fd fd into this: --added bytes 00000000 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 --added bytes 00000010 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00000020 00 00 10 00 00 00 08 00 08 02 00 00 00 29 f0 61 00000030 e9 00 00 00 09 70 48 59 73

c# - How best to represent 'variant' enums? -

c# - How best to represent 'variant' enums? - unfortunately i'm having interface firmware seemingly in constant state of flux (the usb communications protocol keeps changing, register/address map keeps changing, various state machines maintain changing, etc.). i've managed implement reasonable interface, communicating firmware isn't difficult. my main problem representing differing state machines, of there dozen. before changed had enumeration, such as: public enum component1statetype { reset = 0, initialising = 1, ready = 2, waiting = 3 } which used freely in main code modify software's behaviour depending on scheme state. now have problem whereby newer firmware's component1statetype has changed this: public enum component1statetype { reset = 0, initialising = 1, initialised = 2, ready = 3, error = 4, standby = 5, waiting = 6 } which b

python - Why does mysql connector break ("Lost connection to MySQL server during query" error) -

python - Why does mysql connector break ("Lost connection to MySQL server during query" error) - when run big queries (queries returning many rows), lost connection mysql server during query error, , cannot see wrong. utilize "new" mysql driver mysql.com (not "old" mysqldb), , mysql version bundled mamp. python 2.7. table not corrupted, analyze table nrk2013b_tbl; returns status ok. here's illustration breaks: #!/usr/bin/python2.7 # coding: utf-8 import sys import mysql.connector # version 2.0.1 connection = mysql.connector.connect( unix_socket="/applications/mamp/tmp/mysql/mysql.sock", user="dbusernam", passwd="dbuserpassword", db="nrk", charset = "utf8", use_unicode = true) cur = connection.cursor() cur.execute("use nrk;") sql = """

json - Cloudant support of XML -

json - Cloudant support of XML - have xml interfaces , info need support. trying decide if in cloudant take advantage of dbaas operational advantages. take in xml, convert json , store in cloudant, convert xml respond request. i've heard overhead of doing these sorts of conversions between xml , json in range of 20%. using cloudant backend datastore xml interfaces practical versus using native xml databases? you utilize list or show function convert cloudant responses xml but, unless have requirement clients communicate straight cloudant, you'd improve off doing conversion in application tier. besides this, approach seems practical. xml json cloudant

html - Unwanted left-padding added in wordpress -

html - Unwanted left-padding added in wordpress - my webpage menu placement changed bit in tablet/mobile view when created wp theme of html/css. wp added left-padding menu , don't know how rid of it. html/css: http://tigu.hk.tlu.ee/~jaan.koppe/veebiprogrammeerimine/portfolio/ wp: http://jaankoppe.planet.ee/wp4 thanks help! it's default padding added ul in <ul id="menu-menu-1" class="menu"> overwrite or alter css padding: 0; . of menu items set float: left , it's not needed (at to the lowest degree in mobile/tablet view). remove floats html css wordpress

jsp - XSS with dynamic HTML input -

jsp - XSS with dynamic HTML input - my team fixing vulnerability threats old jsp application. problem allows (permissioned) users create simple home page putting html textarea , having render on page. problem xss issues. have been doing research , found withing jsp pages can use: fn:escapexml() jstl library escape html/xml inputted. fine simple form inputs, home page creator, want able maintain simple html rid of harmful scripts or xss vulnerabilities. my teammate , new fixing xss issues , have been relying on resources find.. i have come across these resources , not sure if work way after reading through them. -which html sanitization library use? -https://www.owasp.org/index.php/xss_%28cross_site_scripting%29_prevention_cheat_sheet if utilize owasp, sanitize html basic rendering , prevent scripting beingness implemented? here have in jsp: <td class='caption'> <c:set var="x"><%=system.getname()%></c:set> options ${

Excel vba: How to programatically find what has called a macro -

Excel vba: How to programatically find what has called a macro - i trying write macro has portion reacts differently depending on whether called straight button in worksheet, or called indirectly macro. want able have react differently depending on other macro has called it in case, if macro activated manually button or if has been run particular other macro, pops msgbox allow user know has been completed successfully, if same macro run macro, want skip step. is there way this? you passing arguments subroutines. here's basic example: sub test(number, displaymessage) msgbox ("the number " & number) if displaymessage msgbox ("you ran b sub") end sub sub asub() phone call test(4, false) end sub sub bsub() phone call test(7, true) end sub try running both asub , bsub. hope helped. excel excel-vba

java - Compress string longer than 2 - loops -

java - Compress string longer than 2 - loops - method compress string using java , loops. example, if dc = "aabbbccaaaaba, c = "aab3cca4ba" here have far. please help/guide. thanks. int cnt = 1; string ans = ""; (int = 0; < dc.length(); i++) { if ((i < dc.length()) && (dc.charat(i) == dc.charat(i++)) && (dc.charat(i) == dc.charat(i+=2))){ cnt++; ans = ans + dc.charat(i) + cnt; } else ans = ans + dc.charat(i); setc(ans); unless you're restricted using loops, believe trick: string sb = ""; (int = 0; < dc.length(); i++) { char c = dc.charat(i); int count = 1; while (i + 1 < dc.length() && (dc.charat(i + 1)) == c) { count++; i++; } if (count > 1) { sb += count; } sb += c; } system.out.println(sb); edit: changed illustration utilize regular str

Layout changes animations Android -

Layout changes animations Android - i have relativelayout has nested empty framelayout , listview below framelayout . adding view framelayout animation (setting android:animatelayoutchanges="true" in xml) , doing because want appear @ top of window. appears default fade in animation. listview on other hand moves down, not animated. can listview slide downwards position, because not looking. if have alter way define views in layout, that's ok also. consider every suggestion. thx here code: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <framelayout android:id="@+id/frame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:animatelayoutchanges="true"></framelayout> &l

php - Laravel custom Admin-Filter with redirect-loop -

php - Laravel custom Admin-Filter with redirect-loop - i got dumb question here. i've endless redirect in app. understand why, don't know solve issue. in routes.php i've next code: route::filter('admin', function(){ if(auth::user()->admin){ homecoming redirect::to(route::current()->getpath()); }else{ homecoming redirect::to('/'); } }); route::when('admin/*', 'admin'); when phone call url /admin/createnews browser loading while , tell me there redirect. me logical don't know here. if filter passes, execution flow go on requested route, without need return redirect . solution reverse logic: route::filter('admin', function() { if( !(auth::user()->admin) ) { homecoming redirect::to('/'); } }); php laravel admin

routes - How can I write Rails 4 routing namespaces without duplicating the controller name? -

routes - How can I write Rails 4 routing namespaces without duplicating the controller name? - what i'd able write like: namespace :cats '/:breed/' => '#search_by_breed' '/:breed/count' => '#count_by_breed' end but leads these routes: /cats/:breed(.:format) cats/#search_by_breed /cats/:breed/count(.:format) cats/#count_by_breed which, given slash in cats/#show , won't work. i know can following: '/:breed/' => 'cats#search_by_breed' '/:breed/count' => 'cats#count_by_breed' which results in these routes: /:breed(.:format) cats#search_by_breed /:breed/count(.:format) cats#count_by_breed however, duplicates naming cats controller each time, i'd rather not (in actual code have more routes 2 listed above. unfortunately i'm not working on cat search site...). thought there'd away around this. am missing something? on doing

python - Chaining Filters together -

python - Chaining Filters together - given following: instances = catalog.objects.filter( q(imdb_url=imdb_url) |q(isan=isan) |q(amg_video_id=amg_video_id) ) how same in next format, chaining each together: instances = catalog.objects.all() if imdb_url: instances = instances.filter(imdb_url = imdb_url) # or if isan: instances = instances.filter(isan = isan) # or if amg: instances = instances.filter(amg = amg) # or the above gives me equivalent of: instances = catalog.objects.filter(imdb_url=imdb_url).filter(isan=isan).filter(amg=amg) how eqivalent of q in first query? you can create empty q object , or others accordingly using |= : q = q() if imdb_url: q |= q(imdb_url=imdb_url) if isan: q |= q(isan=isan) if amg: q |= q(amg=amg) instances = catalog.objects.filter(q) python django django-models django-queryset

Initiating "Clear data" for an app from settings in app code (Android) -

Initiating "Clear data" for an app from settings in app code (Android) - i know may seem silly question, possible? in cause wondering why asking this... made update app of mine that, if installed on previous versions, create crash in vital point, , work if go settings , "clear data". wondering if utilize code snippet create automatically version. a improve prepare problem figure out why crashing @ point , address that. can create utilize of sqlitehelper#onupgrade method accomplish this. that beingness said. assume prepare problem: file dir = context.getfilesdir(); fileutils.cleandirectory(dir); that gets private file directory application , clears it, clear info function do. android

entity framework - Many to Many Relationship EF Code First -

entity framework - Many to Many Relationship EF Code First - i'm starting larn mvc , i'm trying create database using entity framework code first approach. have table students , table of subjects, each pupil can have number of subjects , a subject can have number of students. linker table has column grade, because each pupil have different grade every subject. i'm getting error when trying create dtabase, telling me 1 or more validation errors detected during model generation. here models. public class course of study { [key] public int courseid { get; set; } public string coursename { get; set; } public list<student> students { get; set; } } public class pupil { [key] public int studentid { get; set; } public string name { get; set; } public list<course> courses { get; set; } } public class studentcourses { [key] public course of study course { get; set; } [key] public pupil student { get; se

java - Sorting Arraylist with multiple data types by date (numeric) -

java - Sorting Arraylist with multiple data types by date (numeric) - this have. im scanning txt , passing array string (per line). need sort date bundle stocktest; import java.io.filenotfoundexception; import java.util.arraylist; import java.util.scanner; /** */ public class stocktest { /** * @param args command line arguments */ public static void main(string[] args) { arraylist alist = new arraylist(); java.io.file file = new java.io.file("transactions.txt"); seek { scanner input = new scanner(file); while (input.hasnext()) { string info = input.nextline(); alist.add(data); system.out.println(alist); } } grab (filenotfoundexception e) { system.err.format("file not exist/n"); } } } each line in transaction.txt looks this buy,1/2/2002,ibm,30,135.00 i need sort list date. think s

ruby on rails - Errno::ENOSPC keeps happening even after space increases -

ruby on rails - Errno::ENOSPC keeps happening even after space increases - i using linux ubuntu server nginx , passenger ruby on rails app. i run out of space on disk , got "an errno::enospc occurred". tried prepare increasing disk size error persists. if run df -l in server get: if run df -i get: any thought happening , how solve it? thanks! solution: unmount tmp directory (umount /tmp) ruby-on-rails nginx

python - How come file.readline() works, yet open('name of file', 'r').readline() does not? -

python - How come file.readline() works, yet open('name of file', 'r').readline() does not? - i have solved dilemma has cost me @ to the lowest degree 3 hours of life: >>> open('foo.py','r') >>> open('foo.py','r').readline() >>> '' i tried various combinations, , no avail, , of course of study asked uncle google this know howewer, work >>> bar=open('foo.py','r') >>> bar.readline() >>> 'crap' >>> bar.readline() >>> 'more crap' >>> bar.readline() >>> 'even more crap' >>> bar.readline() >>> 'end of crap' so, thought value assigned variable that. simple seems can't be, otherwise code work either way. instead of asking direct answer, have materials go over, not wiki page, that's bit advanced, article of sorts. calling readline() on file o

c# - System.Data.SqlClient.SqlException when I insert generates conflict with foreign key -

c# - System.Data.SqlClient.SqlException when I insert generates conflict with foreign key - i have table when seek insert new cargo appear exception saying insert statement conflicted foreign key constraint "fk_cargo_rol". conflict has appeared in database "banco" table "dbo.rol", column 'idrol'. statement has been terminated. this code aspx.cs public partial class public_cargo_crearcargo : system.web.ui.page { protected void page_load(object sender, eventargs e) { if(!ispostback){ string query1 = @"select * formula"; string query2 = @"select * rol"; using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["banco"].tostring())) { sqlcommand comand = new sqlcommand(query1, con); sqlcommand comand2 = new sqlcommand(query2, con); dataset ds = new dataset(); dataset ds2 = new dataset();

jquery - Add a resizable handle to the top of a div with position fixed bottom -

jquery - Add a resizable handle to the top of a div with position fixed bottom - how can create div fixed position bottom expand handle on top? if @ stackoverflow question form, has expandable handle on bottom, how can place such handle on top of div ? jquery-ui's resizable not appear back upwards this: http://jsfiddle.net/ka7p2/725/. a none jquery solution fine. how this: http://jsfiddle.net/ka7p2/729/ html: <div id="container" class="resizable"> <div id="handle" class="ui-resizable-handle ui-resizable-n"></div> </div> jquery: $(document).ready(function () { $(".resizable").resizable({ handles: { 'n': '#handle' } }); }); edit: fixed bottom requested css: body { height: 1000px; } #container { width: 100%; background: lightgray; height: 100px; position: fixed !important; top: auto !important;