Posts

Showing posts from January, 2012

php - Associated entity not merged correctly -

i have 2 associated entities this: class solicitation { <some fields> /** * @var \user * * @orm\manytoone(targetentity="user", fetch="eager", inversedby="solicitation") * @orm\joincolumns({ * @orm\joincolumn(name="id_user", referencedcolumnname="id_user", nullable=false) * }) * @orderby({"nome" = "asc"}) */ private $user; <more fields> } i don't want cascade operations. problem when try merge existing user before persisting solicitation, this: $em = $this->getdoctrine()->getmanager(); if (!(\doctrine\orm\unitofwork::state_managed === $em->getunitofwork()->getentitystate($solicitation->getuser()))) { $em->merge($solicitation->getuser()); } $em->persist($solicitation); ...it won't change user unitofwork state "managed". i`ts still "detached" , receive , error on saving. it t

math - return Int from a generic mathematics type in swift -

how require generic type usable in mathematical operations mentioned here which led me protocol protocol mathematicsprotocol : equatable { init(_ value: int) init(_ value: float) init(_ value: double) func + (lhs: self, rhs: self) -> self func - (lhs: self, rhs: self) -> self func * (lhs: self, rhs: self) -> self func / (lhs: self, rhs: self) -> self } extension int: mathematicsprotocol {} extension float: mathematicsprotocol {} extension double: mathematicsprotocol {} used in snippet struct myrange<datatype : mathematicsprotocol> { let start : datatype let end : datatype let step : datatype subscript(index: int) -> datatype { { assert(index < self.count) return start + datatype(index) * step } } var count : int { return int((end-start)/step) //not working // return 4 } } however conversion of datatype int in count function doe

c++ - Resources management - vector and pointers -

i need store sequence of elements of type thirdpartyelm , , i'm using std::vector (or std::array if need fixed size sequence). i'm wondering how should initialise sequence. first version creates new element , (if i'm right) creates copy of element when inserted in sequence: for (int = 0; < n; i++) { auto elm = thirdpartyelm(); // init elm.. my_vector.push_back(elm); // my_array[i] = elm; } the second version stores sequence of pointers (or better smart pointers c++11): for (int = 0; < n; i++) { std::unique_ptr<thirdpartyelm> elm(new thirdpartyelm()); // init elm.. my_vector.push_back(std::move(elm)); // my_array[i] = std::move(elm); } which lightweight version? please highlight errors. avoid dynamic allocation whenever can. thus, prefer saving elements instead of smart-pointers them in vector. that said, either fine, , if thirdpartyelem polymorphic, wouldn't have choice. other considerations cost , possibil

elasticsearch - How to extract specific terms from a field during indexing and copy the terms to another field? -

i indexing document elasticsearch: curl -xput 'localhost:9200/vendor_v2/items/1?pretty' -d '{ "title": "pretty hats - green hat bold head", "url": "http://hatshop.com/greenhat", "timestamp": "2014-11-28t23:40:36.630917", "regularprice": "16,34", "id": "1a99c2871df4351044f32c96b96c93d1" }' i use plugin, script or analyzer takes terms found in "title" field (whitespace based tokenizer) , runs them against 3 "term lists" (list brand names, list colors , list product types). matching terms shall copied 3 new fields in indexed document. final indexed document should this. { "title": "pretty hats - green hat bold head", "color": "green", "brand": "pretty hats", "producttype": "hat", "url": "http://hatshop.com/greenhat", "

Android BroadcastReceiver not triggered -

there lot of questions related topic. cannot run on device 4.2.1 on emulator 5.0 working fine.: here manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.bootservice" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="10" android:targetsdkversion="21" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.receive_boot_completed" /> <uses-permission android:name="android.permission.write_external_storage" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name&quo

java - CDI Interceptor not kicking in -

my interceptor not kicking in when should, though it's registered in beans , files provide no warnings. missing? edit 1: want able log each time function in genres.java invoked , left, not getting output @ configuration. edit 2: after following svetlin's advice apply breakpoints, can confirm code never reaches neither interceptor or producer. beans.xml <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" version="1.1" bean-discovery-mode="all"> <interceptors> <class>no.krystah.log.logginginterceptor</class> </interceptors> </beans> logginginterceptor.java package no.krystah.log; import javax.inject.inject; import javax.interceptor.aroundconstruct; import javax.interceptor.aroundinvok

xcode - GameCenter not refreshing -

there problem here when use gamecenter. (by way, i'm using sandbox mode.) i update score on a-device , b score on b-device. can see score on a-device b score on b-device. i can't see other people's score, can sometime can't. gamecenter problem? if problem of gamecenter itself, there suggestion way game leaderboard? thanks bob gilmore, answer quite right thinks. gamecenter did refresh after 2 or more user update score. in order refresh gamecenter, threshold 3 or 4 user.

android - getStringArrayListExtra output with Square Brackets -

i'm learning android intent. need show list of items when showlist button clicked, without using listview or spinner.here parts of code: firstactivity class (main) // add item function public void additem (view v){ if((textutils.isempty(item_in.gettext().tostring()))||(item_in.gettext().tostring().contains(" "))){ input_error_alert.setmessage("data not correct").setpositivebutton("edit data",null).show(); } else{ confirm_alert.setmessage("data correct").setpositivebutton("ok",null).show(); itemlist.add(item_in.gettext().tostring()); item_in.settext(""); } } public void showlist (view v){ //create intent secondactivity intent show = new intent(this,secondactivity.class); bundle b = new bundle(); b.putstringarraylist("itemlist",itemlist); show.putextras(b); startactivity(show); } secondactivity

c - How to determine if a byte is null in a word -

i reading "strlen" source code glibc, , trick developers found speed read n bytes n size of long word, instead of reading 1 byte @ each iteration. i assume long word has 4 bytes. the tricky part every "chunk" of 4 bytes function reads can contain null byte, @ each iteration, function has check if there null byte in chunk. like if (((longword - lomagic) & ~longword & himagic) != 0) { /* null byte found */ } where longword chunk of data , himagic , lowmagic magical values defined as: himagic = 0x80808080l; lomagic = 0x01010101l; here comment thoses values /* bits 31, 24, 16, , 8 of number zero. call these bits "holes." note there hole left of each byte, @ end: bits: 01111110 11111110 11111110 11111111 bytes: aaaaaaaa bbbbbbbb cccccccc dddddddd 1-bits make sure carries propagate next 0-bit. 0-bits provide holes carries fall into. */ how trick of finding null byte work? from famous "bit twiddling hacks&

angularjs - How to load different html depending on screen width? -

i want change sitetype value depending on screen width without editing in view part. app.js 'use strict'; var app = angular.module('location', []). config(['$routeprovider', function ($routeprovider) { $routeprovider. when('/', { templateurl: 'pages/' + **params.sitetype** + '/locationlist.html', controller: location }). when('/locationdetail/:projectid', { templateurl: function (params) { return 'pages/' + **params.sitetype** + '/locationdetail.html'; }, controller: location }). otherwise({ redirectto: '/' }); }]) app.config(['$locationprovider', function($location) { $location.hashprefix('!'); }]); controller.js 'use strict'; function location($scope, $http, $routeparams) { $scope.projectid = $routeparams.projectid; $scope.selectedproject = null; $scope.locationlist = null; $scope.si

python - How to get mouse position using PySDL2? -

do not understand @ how achieve getting mouse's position except listening events, in circumstance event queue empty, how achieved? the documentation pysdl pygamers suggests using sdl2.mouse.sdl_getmousestate() ( doc here ) function actially requires x, y coordinates of cursor want ask about. meanwhile, calling sdl2.mouse.sdl_getcursor() returns cursor object, can find no way coordinates (ie. it's wrapping c object, has empty .__dict__ attribute). i have been trying can think of i've never programmed in c before. simple wrapper function i'm trying produce just: def mouse_pos(self): # ideally, return <some.path.to.mouse_x_y> event_queue = sdl2.sdl_pumpevents() state = sdl2.mouse.sdl_getmousestate(none, none) # returns 0, tried next few lines print state event in event_queue: if event.type == sdl2.sdl_mousemotion: # works, except if mouse hasn't moved yet,

asp.net - Google search engine displaying site title as "Web" -

Image
the title displays in other search engines, google's search: the site (www.clearspaninc.com) has been awhile, , has had more enough time crawled. using asp.net. <!doctype html> <html lang="en"> <head id="head1" runat="server"> <meta charset="utf-8" /> <title>******* - <%: page.title %></title> <asp:placeholder id="placeholder1" runat="server"> <%: scripts.render("~/bundles/modernizr") %> </asp:placeholder> <head> <title>my title</title> </head>

How do I show text and a button? (android) -

i'm working on app generates random quote (from switch) when press button. goes next screen, displays textview. part works. want button under this, send user main screen (i plan on having 2 other buttons come later). however, app displaying either text or button, not both. protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_comp_out); intent intent = getintent(); string message = intent.getstringextra(mainactivity.extra_message); // create text view textview textview = new textview(this); textview.settextsize(40); textview.settext(message); button button = new button(this); button.settext("main menu"); button.settextcolor(color.parsecolor("#ff0000")); button.setheight(75); // set text view activity layout setcontentview(textview); setcontentview(button); } this code i'm using create text output , button. string mes

show - Why does Haskell want this function's argument to have the type classes (RealFrac x, Integral x) when it only needs to be Integral x? -

i'm trying write code complete factorization of integer trial division. code seems ought work: findafact :: integral x => x -> x findafact x = searchints [2, 3..] x searchints (int:ints) div | div `mod` int == 0 = int | otherwise = searchints ints div completefacts :: integral x => x -> [x] completefacts x = tryforfact [] x tryforfact fs x = if x == 1 fs else let fact = findafact x in tryforfact (fact:fs) (floor ((fromintegral x) / fact)) but if try compile following error: could not deduce (realfrac x) arising use of 'tryforfact' context (integral x) bound type signature completefacts :: integral x => x -> [x] @ 5.hs:26:18-39 possible fix: add (realfrac x) context of type signature completefacts :: integral x => x -> [x] in expression: tryforfact [] x in equation 'completefacts': completefacts x

java - Print Character Multiple times -

how can print character multiple times in single line? means cannot use loop. i'm trying print " _" multiple times. i tried method it's not working: system.out.println (" _" , s); s variable. you can print in same line system.out.print(" _"); can use loop. print instead of println not append new line character. for (int i=0; i<5; i++){ system.out.print(" _"); } will print: _ _ _ _ _ .

javascript - Flatter calls using promises: avoiding callbackception -

this question has answer here: how access previous promise results in .then() chain? 15 answers i have found following use case while working promises. writing coffeescript concision reading javascript developers should straight forwards getusername().then (username) -> getrelatedcompany(username).then (relatedcompany) -> registerconnexion(username, relatedcompany) in above request depend of above results of previous ones. what's proper way solve this: getusername().then (username) -> getrelatedcompany(username) .then (relatedcompany) -> # in example, username undefined here there's less callbackception registerconnexion(username, relatedcompany) edit : using bluebird promise library. you can use promises proxies represent values: username = getusername() company = username.then(getrelatedcompany) // assuming promis

algorithm - Partition of a set into K disjoint subsets with equal sum -

given n ( n <= 20) non-negative numbers. there / can there algorithm acceptable time complexity determines whether n numbers can divided k ( k <= 10) disjoint subsets, such each subset has equal sum? one way improve on brute force method: s = sum of numbers = 2 10 k = s / if k integer partitions of input array minimum subset size of 2 elements , maximum of n-1 elements. check each partition it's generated see if subsets have same sum. end if next the hard (and slow) part generating partitions. can recursive function. shouldn't unreasonably slow partitioning 20 numbers. can optimize partition generation throwing out partitions unequal subset sums early.

vba - How To Determine Required dll-ActiveX componentcant cant create object -

the following error pops @ various point in application editing: activex component cant cant create object module: frmchqreg procedure: form_load i referencing microsoft activex data objects 2.5 library how determine ocx or dll files missing, problem? if have other insights, please let me know. appreciated.

javascript - Sigma.js border on all nodes -

i'm implementing visualization sigma.js (using neighborhood plugin , if that's of relevance). out of box, sigma.js displays rectangular label , blurred border on hovered nodes. greater visual clarity, i'm interested in implementing border (preferably not blurred) strictly around circular node on all nodes default, rather hovered or clicked ones. understand prepackaged settings allow alterations hovered node borders. guidance regarding modifying node borders appreciated. anticipate involve tinkering original sigma.js source, unclear where. all! i found resource answers question, , explains why sigma.js relies on custom renderers modify node attributes such border. on topic of sigma custom renderers hope helps others out there similar questions!

html - How can I prevent my ul list from breaking line? [duplicate3 - still cannot find the solution] -

i trying build dynamic user interface puts model attributes category. one of problems need put other runtime attributes on screen. want happens everytime add attribute, or new category, keeps appending on display list horizontally , shows horizontal scroll bar. every time add attribute, layout not want, , gets "fuzzy". i did research on stackoverflow , got topic , wanted. so, decided apply it, no success. ideas doing wrong? first, html. <fieldset class="gpp21kjdhk" style=""> <legend>victim</legend> <div class="gpp21kjdlk" style="overflow: auto; position: relative; zoom: 1;"> <div style="position: relative; zoom: 1;"> <div class="gpp21kjdmk" style="position: relative; overflow: hidden; height: 100%; width: 100%;"> <div class="horizontal"> <ul> <l

Spring Junit Test cases exceution failed in Jenkins Environment : java.lang.IllegalStateException: Failed to load ApplicationContext -

my junit test cases failed in jenkins environment. please find below exception log in console. working in eclipse environment. common_rbac_test_applicationcontext.xml part of application ear file in 1 jar file 09:06:30 tests run: 2, failures: 0, errors: 2, skipped: 0, time elapsed: 7.951 sec <<< failure! 09:06:30 t1_create_pending_account(com.cisco.services.entacc.service.testenterpriseaccountservice) time elapsed: 4.677 sec <<< error! 09:06:30 java.lang.illegalstateexception: failed load applicationcontext 09:06:30 @ org.springframework.test.context.cacheawarecontextloaderdelegate.loadcontext(cacheawarecontextloaderdelegate.java:99) 09:06:30 @ org.springframework.test.context.testcontext.getapplicationcontext(testcontext.java:122) 09:06:30 @ org.springframework.test.context.web.servlettestexecutionlistener.setuprequestcontextifnecessary(servlettestexecutionlistener.java:105) 09:06:30 @ org.springframework.test.context.web.servlettestexecutionliste

remote branch - Git - Change tracking configuration of branches -

i have following branches (local , remote): origin/master origin/alter origin/alter_old master alter alter_old if git branch -vv get: master 6aec3b5 [origin/master] blam alter 8c32a03 blaa1 alter_old 1669af7 [origin/alter: ahead n, behind m] blaa2 i want alter track origin/alter , alter_old track origin/alter_old . how can it? tried following: git checkout alter_old git branch -u origin/alter_old but get: error: unknown switch `u' and same --set-upstream-to . edit: strangely, think when push, alter pushes origin/master , alter_old pushed origin/alter_old . why this? for git 1.8.0 onwards git branch alter_old -u origin/alter_old or git branch alter_old --set-upstream-to origin/alter_old for git 1.7.0 : use --set-upstream instead of --set-upstream-to git branch --set-upstream alter_old origin/alter_old

javascript - JQuery dynamic fields (ruby page) -

i have page redmine (an open source management program) in have show options in drop down list 2, depending on selected on drop down list 1. here code made far, using jquery if($("#categoryid1").val()=== "#categoryvalue1"){ $("#dynamiccategory option[value='categoryoptions1']").hide(); $("#dynamiccategory option[value='categoryoptions2']").hide(); $("#dynamiccategory option[value='categoryoptions3']").hide(); $("#dynamiccategory option[value='categoryoptions4']").show(); $("#dynamiccategory option[value='categoryoptions5']").show(); }else if($("categoryid1").val()=== "categoryvalue2"){ $("#dynamiccategory option[value='categoryoptions1']").show(); $("#dynamiccategory option[value='categoryoptions2']").show(); $("#dynamiccategory option[value='categoryoptions3']").hi

sql - How do I use a stored procedure in a function or query? -

sorry title. not think of way sum problem in short sentence. in select statement, table has column of active directory id's. need use subquery full names adid's. came following code query adsi , need: select givenname + ' ' + sn fullname openrowset( 'adsdsoobject', 'adsdatasource'; 'mydomain\jsmith'; 'mypassword', 'select givenname, sn ''ldap://my.company.com'' objectclass = ''user'' , samaccountname = ''stennell''') that's cool, need parameterize id, password, , samaccountname value. since openrecordset requires literal strings, can't concatenate strings & parameters. must use dynamic sql. here's new code: set @sql = 'select givenname + '' '' + sn fullname ' + 'from openrowset(''adsdsoobject'', ''adsdatasource''; ''us\' + @authadid + '''; ''' + @authpwd + &#

In Excel, how can I use the LEFT function inside of an INDEX/MATCH? -

so problem this: sheet 1 has pivot table, sheet 2 has comparable data , formula, feed getpivotdata formula. sheet 1 entities (row names) looks this: 123456_abc on sheet 2 this: 123456 i'm trying use index/match function full entity names sheet 1 without having insert new column: =index('sheet 1'!a:a, match('sheet 2'!a12, left('sheet 1'!a:a, find("_", 'sheet 1'!a:a&"_")-1),0) i'm following guideline : =index (column return value from, (match (lookup value, column lookup against, 0)) its not working. have suggestions? edit: reason, not showing _ in between " " after find as requested @pnuts as doing string operations on whole column, work when entering formula in array type - once formula typed in, instead of pressing enter , press ctrl+shift+enter

Google reCAPTCHA: show only digits in recaptcha image? -

i hoping use google's free recaptcha service on web form. https://developers.google.com/recaptcha/docs/display however, don't want distorted letters or words show in recaptcha images. feel these distorted letters give visitors frustration, , did read negative comments using distorted words challenge. hope digits show in recaptcha images. is developers can configure , control? googled , did not find want. thanks , regards. to knowledge, there no way configure this. google decide how wants verify user. sometimes, no input required, user checks box. other times, digits or letter required typed.

loops - C++ Can't input with keyboard -

if "password" not inputted, code asks name of user. if name found, assigns first name user. the code blow simplified version of larger 1 problem same. in else if statement, std::cout << "hello " << firstname << std::endl; repeats infinitely. if remove std::cout << "hello " << firstname << std::endl; incapable of inputting anything. it's if keyboard unplugged. tried using goto, cases, , making function out of it, yet problem persists. ideas? #include <fstream> #include <iostream> #include <string> int main() { std::string user; std::string text; std::string password; std::cin >> password; if(password == "password") { user = "ryan"; } else if (password != "password") { std::string line; std::string lastname; std::string firstname; std::string attemptuser; std::ifstream namefile;

matrix - Compute p-values across all columns of (possibly large) matrices in R -

is there more efficient/faster way compare 2 matrices (column columns) , compute p-values using t-test no difference in means (eventually switching chisq.test when necessary)? here solution: ## generate fake data (e.g., treatment , control data) z0 <- matrix(rnorm(100),10,10) z1 <- matrix(rnorm(100, mean=1.1, sd=2),10,10) ## function compare columns (bloody loop) compare.matrix <- function(z0, z1){ pval <- numeric(ncol(z0)) ## initialize for(i in 1:ncol(z0)){ ## compare columns pval[i] <- t.test(z1[, i], z0[, i])$p.value ## if var categorical, switch test type if ( length(unique(z1[,i]))==2){ index <- c(rep(0, nrow(z0)), rep(1, nrow(z1))) xx <- c(z0[,i], z1[,i]) pval[i] <- chisq.test(table(xx, index), simulate.p.value=true)$p.value } } return(pval) } compare.matrix(z0, z1) here's 1 way using dplyr. better combine first 3 lines single step if you've got large matrices, separated them c

php - How to count image of gallery in wordpress gallery shortcode -

i want display total of item in wordpress gallery each post. code this, not work. post display wrong number of item in gallery. $args = array( 'order' => 'asc', 'post_mime_type' => 'image', 'post_parent' => $post->id, 'post_status' => null, 'post_type' => 'attachment', ); $pattern = get_shortcode_regex(); preg_match('/'.$pattern.'/s', $post->post_content, $matches); if (is_array($matches) && $matches[2] == 'gallery') { // preg_match('/\[ gallery ids=\"(.*?)\"]/',$matches[0],$ids); if (is_array($ids) && $ids[1] ) { $photos = explode(',',$ids[1]); } else { $photos = get_children( $args ); } $total_images = count($photos); }

c# - Dropzone.js already attached -

i've implemented dropzone in project working great. except browser decides throw error whenever page request clarity have trimmed view down quite long, below html lives inside form (not sure if cause issue anyway) have 1 reference dropzone shown here, dropzone.js included inside bundle config again 1 occurrence. error : if(this.element.dropzone)throw new error("dropzone attached.") this view <div class="form-group"> <div class="col-xs-12 dropzone" id="uploadimage"> <input type="file" id="id-input-file-2" /> </div> </div> this how create dropzone $(document).ready(function () { $("div#uploadimage").dropzone({ url: '@url.action("saveuploadedfile", "person")' }); }); and controller follows public actionresult saveuploadedfile() { bool success = true; string fname = string.empty; tr

ruby on rails - Use VirtualBox to access site on host from guest? the host and guest is linux -

i'm running virtualbox on ubuntu (host), vm i'm using fedora (guest). virtualbox setup use nat network adapter, , i'm able internet. use port forwarding access ssh , rails web server port forwarding rules <nat> <dns pass-domain="true" use-proxy="false" use-host-resolver="false"/> <alias logging="false" proxy-only="false" use-same-ports="false"/> <forwarding name="rule 1" proto="1" hostport="5679" guestport="22"/> <forwarding name="rule 2" proto="1" hostport="3080" guestport="3000"/> </nat> now can access internet on guest machine , , can logging through ssh cannot access rails web server on port 3080 i tried : localhost:3080 10.0.2.15:3080 #the guest ip what can need ssh , internet connection , open web site host on gust machine browser in host machine thanks

jquery - jqgrid onSortCol return 'stop' not able to stop client side sorting -

i having issues onsortcol event of jqgrid. i trying disable client side sorting , handle on server side. due contraints have use datatype local , not json. i can see server side call being made , results fetched , getting displayed in ui screen. not able stop client side sorting happening . return 'stop' not able stop jqgrid performing sorting on newly returned data. can let me know how stop client side sorting happening here? here code inside onsortcol function: // populate data using async call onsortcol: function (index, columnindex, sortorder) { that.store.find("oldcontact",{page:page,pagesize:pagesize,columnname:index,sortorder:sortorder}).then(function(data){ grid.jqgrid('cleargriddata'); grid.jqgrid('setgridparam', {data: data}); grid.trigger('reloadgrid'); return 'stop&

ruby on rails - Pass a symbol to a method and call the corresponding method -

in rails controller can pass symbol layout method corresponds method in controller return layout name this: layout :my_method def my_method 'layout_1' end i want have similar functionality likewise pass symbol classes method , class should call corresponding function , use return value, this myclass.foo :my_method def my_method 'layout_1' end i've read posts[1] tell me need pass myclass.foo(method(:my_method)) which find ugly , inconvenient. how rails here different allowing pass symbol without wrapper? can achieved rails it? [1] how implement "callback" in ruby? if want pass :symbol method, have make assumptions method named :symbol 1 want called you. it's either defined in class of caller, or outer scope. using binding_of_caller gem, can snag information , evaluate code in context. this surely has security implications, issues you! :) require 'binding_of_caller' class test def foo(sym) bi

java - counting unique occurences of string in document -

i reading logfile java. each line in logfile, checking see if line contains ip address. if line contains ip address, want +1 count of number of times ip address showed in log file. how can accomplish in java? the code below extracts ip address each line contains ip address, process counting occurrences of ip addresses not work. void read(string filename) throws ioexception { bufferedreader br = new bufferedreader(new inputstreamreader(new fileinputstream(filename))); int counter = 0; arraylist<ipholder> ips = new arraylist<ipholder>(); try { string line; while ((line = br.readline()) != null) { if(!getip(line).equals("0.0.0.0")){ if(ips.size()==0){ ipholder newip = new ipholder(); newip.setip(getip(line)); newip.setcount(0); ips.add(newip); } for(int j=0;j<ips.size();j++){

c - Is this valid code? extern marked with @ and address, from PIC microcontroller libraries -

this question has answer here: @ sign in c variable declaration 4 answers i used clang perform analysis on code pic18 microcontroller. gets lots of errors , seem caused lines in headers this. extern volatile unsigned char ansela @ 0xf38; i understand doing, mapping symbol register on chip, standard c or microchip extension compilers? however standard c or microchip extension compilers? it not standard c common extension used c embedded compilers. see answer here on specific topic: @ sign in c variable declaration

java - how to get file names exisiting in a folder and put it in Jtable -

when run programme, first file name repeated many times files exist in chosen folder (as rows). example, if have 3 files in folder, file1, file2 , file 3, after running programme jtable return: file1 file1 file1 here code: file files = new file(directory); file[] listoffiles = files.listfiles(); defaulttablemodel dtm = new defaulttablemodel(); dtm.getdatavector().removeallelements(); dtm.firetabledatachanged(); vector datarows = new vector(); dtm.addcolumn("nom"); (file fichier : listoffiles) { if (fichier.isfile()) { filenames = fichier.getname(); if (filenames.endswith(".txt") || filenames.endswith(".txt")) { datarows.add(filenames); dtm.addrow(datarows); } } } tblfile.setmodel(dtm); create new instance of vector datarows each file, otherwise you're adding names columns

cypher - Create duplicate node and relationship to handle versioning in Neo4j -

i've seen previous topic duplicates, here use case bit different. i'm managing part assemblies bill of material. each node should verionnable. want handle versioning duplicating node , every relationship node. create lot of nodes, , relationships that's way manage think. easiest way run cypher? i've seen how create node, need duplicate relationships. you want kind of programming language. here little cypher example can start experiment. did similar. 1 thing aware of since creating new versions of same of objects same data have limitations uniqueness constraints. in case bom have many uniques keys choose though. data little fuzzier. ended creating new label each new version , added uniqueness constraint on name every label version. indexed name across database. that suggestion courtesy of michael hunger // match 2 specific nodes of particular version , relationship match (a:node)-[r1:assembled_with]-(b:node) a.name = 'node 1' , a.versio

duplicates - mysql modify duplicated fields -

i have table (products) duplicate products_model field . need change them new value. can select them: select * products group products_model having count(*) >=2 i need change products_model = products_model + random number thank you given both fields varchars job, concatenating products_model , products_id underscore update products p1, products p2 set p1.products_model = concat(p1.products_model, '_', p1.products_id), p2.products_model = concat(p2.products_model, '_', p2.products_id) p1.products_model = p2.products_model , p1.products_id > p2.products_id before: id products_model products_id 1 2 b 3 b 4 c 5 c b after: id products_model products_id 1 a_a 2 a_b b 3 b 4 c_a 5 c_b b