Posts

Showing posts from August, 2011

python 2.7 - how to show UART received data (on PIN 10, RX) of Raspberry pi on Tkinter Window -

i have slave pic transmit data raspberry pi depending on switch pressed(connected pic) using uart. want show message coming on rx pin of raspberry pi tkinter window. procedure so?? import serial, time, struct ser = serial.serial("/dev/ttyama0", 9600) while true: count = 0 avalue = [] ch in ser.read(): if ch == "\n": avalue = [] time.sleep(0.1) while count < 4: ch in ser.read(): avalue.append(ch) count += 1 im using code recive 4 bytes of code (float) pic. can go there

javascript - Dotnet highchart visible attribute -

i using dotnet highchart in project, want use visible attribute of point following: series: [{ type: 'pie', name: 'browser share', data: [ ['firefox', 45.0], ['ie', 26.8], { name: 'chrome', y: 12.8, visible: false }, ['safari', 8.5], ['opera', 6.2], ['others', 0.7] ] }] but did not find attribute in dotnet highchart, how can it? please refer link below. think extent. this hides unwanted series values. jsfiddle $(function () { $('#container').highcharts({ series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], visible:false }, { data: [129.2, 144.0, 176.0

ruby on rails - Error after bundle install on production -

every time install gem on production using bundle install got error could not find rake-10.4.2 in of sources (bundler::gemnotfound) also following warning when bundle install don't run bundler root. bundler can ask sudo if needed, , installing bundle root break application non-root users on machine. i tried removing gemfile.lock , re-installed gems still not working thanks in advance.

java - Servlet error HTTP Status 405 - HTTP method GET is not supported by this URL -

i've written following servlet (search1.java): package ergasia; import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.arraylist; public class search1 extends httpservlet { @override public void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html"); connection connection= null; string url = "jdbc:mysql://localhost:3306/"; string dbname = "ergasia"; string user = "root"; string password = "password"; preparedstatement selectproteins = null; resultset resultset = null; arraylist al = null; try { connection = drivermanager.getconnection(url + dbname, user, password); string keyword = request.getparameter("keyword"); selectproteins = connecti

php - why my page wont get my facebook name? -

<?php require_once('facebook.php'); // require 'facebook.php'; $facebook = new facebook(array( 'appid' => 'my_appid', 'secret' => 'my_secret' )); if($facebook->getuser() == 0){ $login_url = $facebook->getloginurl(array( 'scope' => 'email' )); echo "<a href = '$login_url'>login facebook</a>"; } else{ $api = $facebook->api('/me','get'); echo "hi " . $api[name]; echo "<br><a href ='logout.php'>logout</a>"; }; ?> i think have facebook sdk 3.2.3 working somehow keep return logging page , when click log in facebook , facebook ask me wanted pass data on , when redirect url cant echo name , wrong ? getuser keep return = 0 ? can me take ? wanted use 4.0 sdk friend sever 5.2 below need facebook loging working. doing wrong here? try : echo "hi "

Is there any hope of parsing csv-like file with augeas? -

i trying build lens parse file format #header1 header2 header3 vala1 vala2 vala3 valb1 valb2 valb3 i'd result resemble following tree: root +--[1] | +----header1 -> vala1 | +----header2 -> vala2 | +----header3 -> vala3 +--[2] +----header1 -> valb1 +----header2 -> valb2 +----header3 -> valb3 the problem first need parse header line learn field names and remember them , , use them multiple times source of key names on following rows. have idea how start writing such lens? i've checked 181 lenses come bundled augeas , found no lens suspect parse tables. no, it's not possible in augeas store values in header , reuse them labels every line. you can build tree one: { "#comment" = "header1 header2 header3" } { "1" { "1" = "vala1" } { "2" = "vala2" } { "3" = "vala3" } { "2" { "1" = "

windows - Chmod issue to change file permission using python -

i looking change file permission files read write , execute users in directory using python script. however, after running script when check file permission doing right click, shows permissions me , group has read permission. there wrong doing in following script: import os import pdb dirpath, dirnames, filenames in os.walk('m:\intra\eu'): filename in filenames: path = os.path.join(dirpath, filename) os.chmod(path, 0o777) # example i found solution here :) setting folder permissions in windows using python import win32security import ntsecuritycon con import os import pdb userx, domain, type = win32security.lookupaccountname ("", "everyone") directory='m:\intra\eu' dirpath, dirnames, filenames in os.walk('m:\intra\eu'): filename in filenames: sd = win32security.getfilesecurity(directory+'\\'+filename, win32security.dacl_security_information) dacl = sd.getsecuritydescriptordac

javascript - php Uploading multiple files with ajax -

i've managed upload multiple files using current php , html form , wanted fancy bit ajax , automatically submitting form. i've hidden 'file' input , submit button form handeled js (mentioning incase may affect form submission, form submission , i've checked via http headers). ajax section of js use ajax , standard forms, when submit form $_files empty guess i'm not using ajax correctly here? need change in ajax handle file uploads? $("#add_button").click(function(e) { e.preventdefault(); $("#folder_open_id").trigger("click"); $("#folder_open_id").change(function() { $("#folder_upload").submit(); }); }); $("#folder_upload").submit(function(event) { var formdata = $(this).serialize(); event.preventdefault(); $.ajax ({ url: "index.php", type: "post",

mysql - Laravel Schema Builder alter storage engine -

i trying alter table , change it's storage engine innodb . when run php artisan migrate completes without error. when check storage engine in sequel pro, nothing changed. public function up() { schema::table('tests', function(blueprint $t) { $t->engine = 'innodb'; $t->foreign('group_id')->references('id')->on('test_groups')->ondelete('restrict'); }); } since @alexrussell confirmed believe, i'm can define storage engine when create table schema::create() . can use raw sql last resort: db::statement('alter table tests engine = innodb');

angularjs - Combining button functionality in anchor tag -

i need combine functionality of button in anchor tag i'm using angularjs <div class="text-center" > <button scroll-to-bookmark="bookmark1">bookmark 1</button> <a href="#!/details/{{previtem}}" class="btn btn-left-primary">&lt;&nbsp;&nbsp; </a> bookmark 1 if click button bookmark1 go bookmark 1 no issue objective way of combining functionality in anchor tag

spring - Hibernate - No value specified for parameter -

i have entity class mapped this: @entity @table(name = "configuration") @xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class jsonconfiguration implements jsonserializable, serializable { private static final long serialversionuid = 1l; @id @notnull @jsonproperty("_id") private integer id; @jsonproperty("config") @notnull @type(type = "jsontype") private string config; public jsonconfiguration(integer id, string config) { this.id = id; this.config = config; } public jsonconfiguration(){ super(); } public integer getid() { return id; } public void setid(integer id) { this.id = id; } public string getconfig() { return config; } public void setconfig(string config) { this.config = config; } } each time i'm trying update or insert same error: caused by: org.springframework.dao.dataintegrityviolationexception: not execute statement; sql [n/a]; nested exception org.hibernate.exception.data

command line interface - AWS CLI: Error when trying to retrieve console output of an Amazon EC2 instance -

when retrieving console output instance command: aws ec2 --region us-east-1b get-console-output --instance-id my_instance_id i got following error: httpsconnectionpool(host='ec2.us-east-1b.amazonaws.com', port=443): max retries exceeded url: / (caused <class 'socket.gaierror'>: [errno 11004] getaddr info failed). when configure 'aws', ensure region name given correctly. c:\>aws configure aws access key id [****************offq]: aws secret access key [****************axen]: default region name [none]: us-east-1b default output format [none]:

Compile program in linux using c code -

i'm trying write program compiles program in given directory, , i'm having couple of questions. i'm using command execv (and tried other of exec family). when use command path run code directory+path or path <> example : program in desktop : exe.c . when use command execv "./users" path go "desktop/users" ? the second question how compile program through c code? thank you! you can use exec function compiling that. execl("/usr/bin/gcc or cc","cc","path name or filename",null); using 1 can compile program easily. if file name given taken current directory. or else taken given path.

ruby - Not able to send flags when using RVM wrapper -

i'm trying use crontab rvm setup (creating backup using backup gem ). my crontab entry runs following command several times day: /home/user/.rvm/gems/ruby-2.1.1/wrappers/backup -t app however, misterious reason, -t flag beeing changed _t (dash turns underscore --trigger changes __trigger ). in cause of that, i'm not able use bin correctly. error message says: could not find command "_t" please note using backup -t app works fine, using wrapper fails. is there reason behing such behavior? can run wrapper non-underscored flags? in advance.

log4j - Logstash-Kafka integration not working -

we want logs using logstash , pass them kafka. we have written following conf file logstash 1.5.0 beta 1 , kafka 2.9.2_0.8.1.1 ** input { file { type => "apache" path => ["/var/log/apache2/access.log", "/var/log/apache2/error.log"] } } output { kafka { codec => plain { format => "%{message}" } topic_id => "example1" } } ** after running following command : bin/logstash agent -f test.conf --log ex.log test.conf our conf file. ex.log blank file have created logs stored. we getting following output sending logstash logs ex.log. using milestone 2 input plugin 'file'. plugin should stable, if see strange behavior, please let know! more information on plugin milestones, see http://logstash.net/docs/1.5.0.beta1/plugin-milestones {:level=>:warn} using milestone 1 output plugin 'k

sql server - SSIS: How to append SQL Data into an Excel file AT A SPECIFIC ROW -

Image
i designing ssis package export data sql query excel file, column names in excel file on row 5. i have created workflow task, , added ole db source , excel destination, plus connection manager both. the excel connection manager has checkbox of 'first row has column names' (see below) - couldn't find way set 5 (i.e., fifth row). i have done research , solutions suggested adding formula openrowset parameter @ customerproperties of excel destination. the above works when column names on first row of excel-sheet, need have column names set on fifth row; first 4 rows used headings:

c - Void pointer type conversion -

i want print addresses of void pointer u32 j; (j = 0; j < sizeof(struct queue_header); j += 4) { printf("0x%x ",(u32 *)((u32 *)q->q_hdr + j)); //q_hdr void pointer } but type conversion giving error: warning: cast pointer integer of different size [-wpointer-to-int-cast] can please tell me how can print address. that's %p for: printing pointers. printf("%p ", (void *)((u32 *)q->q_hdr + j)); should want.

javascript - Node module.exports pattern - Is this correct? -

i'm new js , working on irc bot. have produced following module want use creating bot commands. /*** * module contains available bot commands including * access levels view/utilise command , text. * * usage example: commands.tg.play(payload); * ***/ module.exports = commands = { tg: { reg: '^[. - !]tg', help: 'some text tg', play: function(payload){tg(payload);} }, help: { reg: '^[. - !]help', description: 'some text intel', play: function(payload){help(payload);} } }; function tg(payload){ //example: msg_route: pm msg_from: munkee msg_data: .tg munkee testing message via tg command msg_match: .tg msg_method: . console.log("msg_route:" + payload.msg_route + ' msg_from: ' + payload.msg_from + ' msg_data: ' + payload.msg_data + ' msg_match: ' + payload.msg_match + ' msg_method: ' + payload.msg_method); return; } function help(payload){ var output=&

android - OnePlus One device not shown in Eclipse (Ubuntu) -

i have turned usb debugging mode , tried every setting development purpose. eclipse does recognize other devices it's not working oneplus one . steps required? eclipse: 64bit thanks! this worked me in ubuntu. settings->developer options-->turn on android debugging. settings-->storage-->menu on upper right corner-->usb computer connection-->check box mtp/ptp http://forum.xda-developers.com/oneplus-one/help/phone-recognized-storage-connected-to-t2825728

siteminder - authenticate to Alfresco repository using siteminderToken -

i have authenticated using siteminder & have obtained accesstoken. now there application comes under scope of same application. i want use alfresco there without need of further sign-up. want implement single sign on. i don't know siteminder, sso possible in alfresco. you'll have @ how authentication subsystem work. you'll find configuration under alfresco.war\web-inf\classes\alfresco\subsystems\authentication\ can redefine them under /shared/classes/alfresco/extension/subsystems/authentication/ things exist for: alfrescontlm (alfresco's own mechanism) kerberos ldap ldap-ad passtrhu external <- on candidate you with external can tell aflresco trust comes url. you'll find information here http://docs.alfresco.com/5.0/concepts/auth-external-intro.html or there http://smasue.github.io/alfresco-external-sso i hope helps

python - unable to deploy portia spider with scrapyd-deploy -

could please me figure out i'm doing wrong ? here steps: followed portia install manual found here https://github.com/scrapinghub/portia - ok created new project, entered url, tagged item - ok clicked "continue browsing", browsed through site, items being extracted expected - ok next wanted deploy spider: 1st try : tried run, docs specified, scrapyd-deploy your_scrapyd_target -p project_name - got error - scrapyd wasn't installed fix: pip install scrapyd 2nd try : launched scrapyd server, accessed http://localhost:6800/ -all ok after brief reading of scrapyd docs found out had edit file scrapy.cfg project : slyd/data/projects/new_project/scrapy.cfg added following : [deploy:local] url = http://localhost:6800/ went console, checked ok : $:> scrapyd-deploy -l local http://localhost:6800/ $:> scrapyd-deploy -l local default seemed ok gave try : $scrapyd-deploy local -p default packing version 1418722113 deploying project "defau

eclipse - Add label to JSP and change label text from java code? -

im new jsp. tried searching kind of function no luck. tried doing this doesn't work. can 1 me on how declare label on jsp , change it's value java code. im getting value oracle database have no idea on how pass value front end? need pass string label :( appreciated. in jsp page: <% example c = new example(); %> <label><%=c.getname()%></label> your class example.java: private string name="igarren"; public string getname() { return name; } public void setname(string name) { this.name = name; } but should read ajax @gaurav said

c# - How do I show a form only when data is loaded? -

i need on thing can't resolve. i've windows form datagridview populated large amount of data. data stored in sql server database , retrieved simple piece of ado.net code. i'm using backgroundworker class perform kind of operation form still freezes 1-2 second. is there way delay showing of form? show form when data in loaded? i've tried make not visible or use hide() , show() method still not have results. remove initializecomponent(); constructor of form , call method when data has loaded

Deviceready is not working in cordova -

deviceready not working in cordova when remove plugins working fine. plugin list "org.apache.cordova.device": "0.2.12-dev", "org.apache.cordova.network-information": "0.2.12-dev", "org.apache.cordova.battery-status": "0.2.11-dev", "org.apache.cordova.device-motion": "0.2.10-dev", "org.apache.cordova.device-orientation": "0.3.9-dev", "org.apache.cordova.geolocation": "0.3.10-dev", "org.apache.cordova.media": "0.2.13-dev", "org.apache.cordova.file-transfer": "0.4.6-dev", "org.apache.cordova.contacts": "0.2.13-dev", "org.apache.cordova.globalization": "0.3.1-dev", "org.apache.cordova.splashscreen": "0.3.3-dev", "org.apache.cordova.inappbrowser": "0.5.2-dev", "org.apache.cordova.console": "0.2.11-dev", "org.apache.cordova.

java - Weka connection to MySQL in Eclipse -

i'm trying use weka library write own software throws jdbc driver exception. my code (mostly copy-pasted tutorial): package test; import weka.core.instances; import weka.experiment.instancequery; public class test { public static void main(string[] args) throws exception{ instancequery query = new instancequery(); query.setusername("root"); query.setpassword(""); query.setquery("select id_activite activites limit 1"); instances data = query.retrieveinstances(); system.out.println(data.tostring()); } } i exception: trying add database driver (jdbc): rmijdbc.rjdriver - error, not in classpath? trying add database driver (jdbc): jdbc.idbdriver - error, not in classpath? trying add database driver (jdbc): com.mckoi.jdbcdriver - error, not in classpath? trying add database driver (jdbc): org.hsqldb.jdbcdriver - error, not in classpath? exception in thread "main" java.sql.s

icc - How to compile a CUDA project with my own Makefile from inside Nsight? -

i have cuda project contains .c , .cu files. project uses mkl. compile project without problems using own makefile terminal. makefile uses both intel c compiler (icc 15.0.0) , cuda 6.0 compiler (nvcc). i build project inside nsight cannot find right way. have tried configure build provided nsight use onwn makefile without success. i have achieved generate project default build (make all) inside nsight. not know how customize default build own makefile. can me this? thanks in advance nsight based on cdt this tutorial should work. if have cuda c sources, use "cuda c" project wizard , select cuda toolkit toolchain.

javascript - How to see what nodes are selected with d.selected ? D3/JS -

how can make array of selected nodes ? ie d.selected ? i have force layout graph , want sort out selected nodes , hide unselected. is there way loop through selected nodes, add them array , can sort them accordingly. for example. every node has name applied , names beginning a,b , c. have function sorts out nodes customised layout (names starting on 1 line, b next , c next) works every node, not selected. what wish happen sort selected nodes out , hide unselected peoplearray = []; peopleindex = []; for(i = 0; < people.data.nodes.length;i++) { if(!peoplearray[people.data.nodes[i].name]) { peoplearray[people.data.nodes[i].name]=1; peopleindex.push(people.data.nodes[i].name); } else{ ++peoplearray[people.data.nodes[i].name]; } } you can data bound selection calling .data() without arguments, i.e. var selected = d3.selectall(".selectednode").data();

Lucene Index with file system -

i have created lucene indexer periodically file system folder read content of latest files update lucene catalog. problem arise, if delete file above folder above indexer doesn't understand file gets deleted same remove catalog. can 1 please tell me how resolve issue. not sure how implemented polling on file system, here's how delete events (among others) can captured.

javascript - Can I modify the points on an existing path using Snap? -

i have svg path element: <path d="m54.7,0.8 l111.8,73.4 l79.9,126.1 l27.9,128.7 l0.5,74.2 l54.7,0.8 z" id="shape"></path> i understand svg path's meaning : m moves point the ls draw lines z closes path, producing polygon and know can snapsvg manipulable object with: var graph = snap(".graph"); var item = graph.select('#after #shape'); but can't find how modify path in the snap docs . i've looked @ item's paper.path can't see examples of changing paths, new ones. how can modify existing path in snapsvg? ideally, i'd animate change in paths, ie, going old polygon new one. you can animate d ( path descriptions ) other snapsvg items: var graph = snap(".graph"); var item = graph.select('#after #shape'); get existing points: item.attr('d') then animate them: item.animate({ d: "m81.8,0.1 l146.8,85.1 l124.1,164.4 l39.7,164.4 l0.6,79.7 l81.8,0.1

python - Angularjs with Django using AJAX request -

i sent information post method until 1 views in django , returned site. however, i'm not getting submit information on site. file post3.html <!doctype html> <html ng-app> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js"></script> <script> function listdropdown($scope, $http){ $scope.ccvms={lista01:['1','3','5','7','9'],lista02:['2','4','6','8','10']} $scope.send=function(x,y){ $http({ method:'post', url:'/escalar', data:x+y, headers:{'content-type': 'application/x-www-form-urlencoded'}, }).success(function(c){ console.log(c) }) } } <

Excel - Insert "day" on a cell and format it to date with current month and year -

i working on home accounting template (and not find 1 :-/), creating 1 each month. both in expenses , incomes, have date column have insert "day" (e.g.: 22) , automatically fills rest current month , year (or set them in cell). for example: 22 + enter return: 22/12/2014 if this, automatically default date: 22/01/1900 i not know if possible change defaul date depending on current 1 or other value. i have tried different strategy: if amount column not empty, fill in today's date: =if(a3="";"";today()) the problem not register today's expenses, need change manually. wondering if possible , there better way (maybe macro?). you need excel modify cell contents after press enter . option seems macro using worksheet_change event. please check out this other question . think help.

How to update listview when loading next new items android? -

hi have popup button. when click pop button, displays radio button.for every radio button selection, fetching datas , updating in ui. problem first radio button updating ui. second radio button , on, ui not updating. how solve this? code follows: public class datalist extends activity { private button popupclick; private dialog sortfilterdialog; private radiogroup radiogroup; private radiobutton asctodesradiobutton, destoascradiobutton, hightolowradiobutton, lowtohighradiobutton, popularityradiobutton; private int popupselectionitem; private imageview closebutton; private string sessionid; private string sortname,sortorder; arraylist<sortfilterproducts> personslist; private listview list; private datalistadapter gridadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); setconten

java - Editing the output screen -

i taking screenshots output in netbeans, , make user enters coloured. have tried using screw driver @ left of output screen color , fonts edits body of code .. possible, suggestions. in netbeans goto: window -> options -> miscellaneous -> output here, can change color user input changing value of input color option.

Reading from URL - Java, C#, Android, Visual Studio -

is possible read url directed text file. e.g. https://dl.dropboxusercontent.com/u/53441658/read.txt instead of giving file path located on computer, want give path text file, via url. this; streamwriter sw = new streamwriter("https://dl.dropboxusercontent.com/u/53441658/read.txt", true); in java (android) url url = new url("ftp://mirror.csclub.uwaterloo.ca/index.html"); urlconnection urlconnection = url.openconnection(); inputstream in = new bufferedinputstream(urlconnection.getinputstream()); try { readstream(in); { in.close(); } } p.s. must in separate thread async task. read more on android official documentation. in dot.net c# using(webclient client = new webclient()) { string s = client.downloadstring(url); }

flask - NameError: global name 'User' is not defined -

i follow miguelgrinberg tutorial , want make profile page without login page when have http:.../user/peg said got error,i think because couldn't connect database. put data in user python command >>> u = models.user(nickname='peg', email='peg@email.com') >>> db.session.add(u) >>> db.session.commit() i have question database store user , post? , why didn't define table?( because in app.db have table 3 column 1.reponsity_id 2. reponsity_path 3. id) , please tell me how can solve error. thanx views.py from app import app flask import render_template, flash, redirect @app.route('/') @app.route('/index') def index(): user = {'nickname': 'miguel'} posts = [ { 'author': {'nickname': 'john'}, 'body': 'beautiful day in portland!' }, { 'author': {'nickname': 'susan'}, &#

ios - Swift Typhoon error in tests target - not subclass of Typhoon Assembly -

i trying set typhoon framework example project , works fine when run simulator giving me error when try run tests. error following: nsinvalidargumentexception', reason: 'class 'di_example.myassembly' not sub-class of typhoonassembly' now, read here , here caused typhoon package being linked twice because of cocoapods. podfile , doesn't seem should linked twice platform :ios, '8.0' target 'di_example', :exclusive => true pod 'typhoon', '~> 2.3' end target 'di_exampletests', :exclusive => true end inhibit_all_warnings! also when change tests target applicaiton-style logic-style seems work fine (i assuming because package not imported twice). can spot problem doing? it seems error thrown before hitting test guessing has linking 2 targets here test (which passing if set host application none var controller: homeviewcontroller! override func setup() { super.setup() let ctrlasse

mysql - Last Auto increment ID before insert query in Wordpress -

i want last auto increment id in wordpress.so have tried last_insert_id(); $last_id = $wpdb->query('select last_insert_id();'); $new_id = $last_id + 1; but not working , per official mysql site : give id of executed insert statement any other way id? pl help. $wpdb->query function returns integer value indicating number of rows affected/selected. create, alter, truncate , drop sql statements, function returns true on success. use $wpdb->get_var function instead. $last_id = $wpdb->get_var('select last_insert_id();'); $new_id = $last_id + 1;

Python 3.3.4: python-daemon-3K ; How to use runner -

struggling try , python daemon work using python 3.3.4. im using latest version of python-daemon-3k pypi i.e. 1.5.8 starting point following code found how create daemon in python? code believe 2.x python. import time daemon import runner class app(): def __init__(self): self.stdin_path = '/dev/null' self.stdout_path = '/dev/tty' self.stderr_path = '/dev/tty' self.pidfile_path = '/tmp/foo.pid' self.pidfile_timeout = 5 def run(self): while true: print("howdy! gig'em! whoop!") time.sleep(10) app = app() daemon_runner = runner.daemonrunner(app) daemon_runner.do_action() attempting run following error. python mydaemon.py start traceback (most recent call last): file "mydaemon.py", line 60, in daemon_runner = runner.daemonrunner(app) file "/depot/python-3.3.4/lib/python3.3/site-packages/python_daem

c++ - How read a boost mapped_region object like a binary file? -

i mapped binary file memory following tutorial using boost library cannot figure out how iterate on binary object same way i'm using ifstream when open directly: this code #include <boost/interprocess/file_mapping.hpp> #include <boost/interprocess/mapped_region.hpp> ... file_mapping m_file(shmfile.c_str(), read_write); mapped_region region(m_file, read_write); i want that: ifstream myfile (region.get_address(), std::ios::in); struct stat filestatus; sstemp = filename.str(); const char * c = sstemp.c_str(); stat(c, &filestatus); size = filestatus.st_size; int cant = 0; while (cant < size) { myfile.read((char *) user_id, 4); cant += 4; } is there way it? i cannot figure out how iterate on binary object same way i'm using ifstream when open directly well, if want use when readin binary file, why using else? maybe want this: file_mapping m_file(shmfile.c_str(), read_write); mapped_region region(m_file, read_write);

IOS UIActivityViewController redraw layout -

i've added on ios app share button, works fine, there problem after send/close dialog. problem layout moved up. the code is: nsstring *texttoshare = @"my app"; nsurl *linkurl = [nsurl urlwithstring:article.fonte]; nsarray *activityitems = @[texttoshare, linkurl]; uiactivityviewcontroller *activityvc = [[uiactivityviewcontroller alloc] initwithactivityitems:activityitems applicationactivities:nil]; activityvc.excludedactivitytypes = @[uiactivitytypeposttoweibo, uiactivitytypeassigntocontact]; [activityvc setcompletionhandler:^(nsstring *activitytype, bool completed) { }]; [self presentviewcontroller:activityvc animated:true completion:nil]; is possible open/close di dialog without redraw layout?

java - Draw on transparent SurfaceView -

i have following problem: made class extends surfaceview, implements surfaceholder.callback when try draw red square, it's black. below code: first call following method in constructor: private void inittransparentbackgroundcolor(){ this.setbackgroundcolor(color.transparent); this.setzorderontop(true); getholder().setformat(pixelformat.transparent); } then, start drawing: protected void ondraw(canvas canvas){ paint p = new paint(); p.setcolor(color.red); p.setstyle(paint.style.fill_and_stroke); canvas.drawrect(10,10,20,20,p); } what doing wrong? replace getholder().setformat(pixelformat.transparent); to this getholder().setformat(pixelformat.translucent); good luck. :)

php - Correct method of checking with an array has elements -

i trying check returned array exists before accessing elements. @ first had $img = wp_get_attachment_image_src($img_id, 'type')[0]; but since array didn't exist, changed $check = wp_get_attachment_image_src($img_id, 'type'); if ($check) { $img = wp_get_attachment_image_src($img_id, 'type')[0]; } despite check (which same wordpress recommendation below) still error within if statement parse error: syntax error, unexpected '[' here wordpress example usage below. cannot see why mine different. have tried !empty($check) , number of other things. silly mistake making? <?php $attachment_id = 8; // attachment id $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns array if( $image_attributes ) { ?> <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>"> <?php }

apache - Htaccess recursive file rewrite -

i know if there better way achieve sort or redirection : # apache configuration options -indexes options +followsymlinks # rewrite engine configuration rewriteengine on rewritebase / # force domain www (302 redirect) rewritecond %{http_host} ^([^\.]+\.[^\.0-9]+)$ rewriterule ^/?(.*)$ http://www.%1/$1 [l,r=302] # request redirection (/module/tld/module/domain/module/sub/data/public/...) rewritecond %{request_uri} !^/index.php rewritecond %{http_host} ^(.+)\.([^\.]+)\.([^\.0-9]+)$ rewritecond %{document_root}/module/%3/module/%2/module/%1/data/public/%{request_uri} -f rewriterule ^/?(.+)$ /module/%3/module/%2/module/%1/data/public/$1 [l] rewritecond %{request_uri} !^/index.php rewritecond %{http_host} ^(.+)\.([^\.]+)\.([^\.0-9]+)$ rewritecond %{document_root}/module/%3/module/%2/module/%1/data/public/%{request_uri}/index.php -f rewriterule ^/?(.+)/?$ /module/%3/module/%2/module/%1/data/public/$1/index.php [l] rewritecond %{request_uri} !^/index.php rewrite

deployment - Promote the application to test environment after successful build using Jenkins -

i able promote application test environment running particular shell script. want automate task using jenkins. specify shell script in jenkins script executed build successful. jenkins has plug-ins allow run shell scripts. wiki pages plug-in typically shows how utilize them within jenkins. here 2 plug-ins run shell script. post build task managed script plugin

linux - Can we set the port number for listening in some automatic way rather than hardcoding it? -

in typical example client server programs found on net, can see following hardcoded way of specifying port number process id of process used handle incomming messages. can set port number listening in automatic way rather hardcoding it? i mean how supposed know port number beforehand? serveraddr.sin_family = af_inet; /* set port number, using htons function use proper byte order port number process id of process used handle incomming messages. */ serveraddr.sin_port = htons (7891); /* set ip address localhost */ serveraddr.sin_addr.s_addr = inet_addr ("127.0.0.1"); /* set bits of padding field 0 */ memset(serveraddr.sin_zero, '\0', sizeof serveraddr.sin_zero); /*---- bind address struct socket ----*/ bind(welcomesocket, (struct sockaddr *) &serveraddr, sizeof(serveraddr)); if port number dynamically identified during execution process of client, transfer server via interprocess communication.

java - How to enforce usage of gradlew over gradle? -

if have gradle installed on system , project foo uses gradle wrapper have found can invoke the build using gradle command or gradlew wrapper. suppose gradle installed on system version 2.2.1 , gradle wrapper setup use gradle version 1.9 happens if invoke system gradle build run using gradle 2.2.1 or 1.9 specified wrapper? how gradle handle conflicts between version installed on system , 1 specified wrapper? there way build fail if invoked using gradle rather gradlew ? there no built-in way enforce gradlew on gradle . common solution tell/document should use gradlew , , nobody should install gradle manually. experience works (why install if don't need to). power users need/want local gradle installation typically figure out if got wrong.

javascript - window.location.hash problems in firefox -

i have problem concerning site i'm creating <div id="footer"></div> <script> function preloadfunc() { window.location.hash = 'footer' } window.onpaint = preloadfunc(); </script> above piece of code (placed in head, div positioned 15300px top) redirecting page bottom before else gets loaded (i wanna start bottom up). works here chrome/safari, seems redirect in ff after refresh. there workaround this? (+ #div in end of url not possible redirecting domain url#div seems not work server side/cpanel. presumably because #div not directory) i'm pretty sure should window.onpaint = preloadfunc; apparently chrome/safari have no problem understanding location.hash = 'footer' before footer element available (or preprender layout somehow), firefox has no idea there element id footer soon. nothing.

bzip2 - unpack bz2 url without temporary file in python -

i want unpack data bz2 url directly target file. here code: filename = 'temp.file' req = urllib2.urlopen('http://example.com/file.bz2') chunk = 16 * 1024 open(filename, 'wb') fp: while true: chunk = req.read(chunk) if not chunk: break fp.write(bz2.decompress(chunk)) fp.close() error on bz2.decompress(chunk) - valueerror: couldn't find end of stream use bz2.bz2decompressor sequential decompression: filename = 'temp.file' req = urllib2.urlopen('http://example.com/file.bz2') chunk = 16 * 1024 decompressor = bz2.bz2decompressor() open(filename, 'wb') fp: while true: chunk = req.read(chunk) if not chunk: break fp.write(decompressor.decompress(chunk)) req.close() btw, don't need call fp.close() long use with statement.

java - Jasper report error when exporting report to docx -

i'm trying export jasper report .docx file; i'm getting error java.lang.classcastexception: java.lang.string cannot cast net.sf.jasperreports.engine.jasperprint i'm using java develop this. here code used public void generatereport2() throws printerexception { try { string sourcefilename = "src/pos_bill/esfourreport.jasper"; string printfilename = null; databeanfactory2 databean = new databeanfactory2(); jrbeancollectiondatasource beancoldatasource = new jrbeancollectiondatasource(databean.generatecollection()); map parameters = new hashmap(); printfilename = jasperfillmanager.fillreporttofile( sourcefilename, parameters, beancoldatasource); jrdocxexporter exp=new jrdocxexporter(); exp.setparameter(jrexporterparameter.jasper_print,printfilename); exp.setparameter(jrexporterparameter.output_file_name,"src/pos_bill/sample_report2.docx"); exp.exportreport(); } catch (exception e) { system.out.println(e); } }

C# / Sql Server 2008 INSERT int value grows automatically to 1000000 -

i had strange problem occured 1 time in sql server 2008. i work in .net web application (c#) , use sqlcommand access database , execute queries. process following: i have view me maximum number existing in specific table: select max(number) maxnumber mytable i maxnumber in variable and, variable, execute insert in mytable maxnumber + 1. that, have maximum number logged in mytable it worked since 1 time, week ago, when, suddenly, saw maxnumber passed 134200 1000000 ! i investigate code , there no way reason of behavior. inspected logs of web server, no logs of bad insert throwned. i looked logs of sql server i've found no logs of error... what suspicious number passed "common" number (134200) "specific" number (1000000). why 1000000 ? why not 984216 or 1000256 ? is there experienced same problem ? thanks help. edit - 2014-12-23: i analyzed further problem , seems occurred when restored backup in preprod environment. i explain: have

Dynamically configure a Job in spring-batch -

is possible dynamically configure job in spring-batch ? here want do. have created several different itemreader , itemwriter below: flatfileitemreader dbitemreader flatfileitemwriter dbitemwriter ..... xmlitemwriter i want able mix , match them dynamically while creating batch job. example, suppose need job 2 steps. first step contains tasklet pre-processing . second step have tasklet chunk based data processing using reader/writer.... this: // define job parameters jobparametersbuilder parameters = new jobparametersbuilder(); // create 2 steps taskletstep step1 = new taskletstep(); taskletstep step2 = new taskletstep(); step1.setname("preprocessingstep"); step2.setname("chunkreadwritestep"); // create 2 tasklets tasklet tasklet1 = new preprocessingtasklet(); tasklet tasklet2; <------ how attach reader/writer in tasklet?? // attach tasklet step step1.settasklet(tasklet1); step2.settasklet(tasklet2); // attach steps job simplejob job =

osx - macos 10 setuid failing for no reason -

i'm running code change real uid if process: #include <cstdlib> #include <cstdio> #include <errno.h> #include <sys/types.h> #include <unistd.h> void printstat() { printf("uid: %d, euid: %d\n",getuid(),geteuid()); } int main(int argc, char** argv) { if (argc < 2) { return -1; } int m_targetuid = atoi(argv[1]); printstat(); uid_t realuid = getuid(); printf("setting effective uid %d\n",m_targetuid); seteuid(m_targetuid); printstat(); if (m_targetuid != realuid) { printf("setting real uid %d\n",m_targetuid); int res = setuid(m_targetuid); printf("setuid(%d) returned: %d\n",m_targetuid,res); if (0 > setuid(m_targetuid)) { printf("setuid(%d) failed: %d, getuid() returned %d, geteuid returned %d\n",m_targetuid,errno,realuid,geteuid()); exi