Posts

Showing posts from March, 2010

android - Is it possible to get the version of a shared object? -

i'm trying track down bug in software line. have 2 release build version 2.0.962 , 2.0.966. difference between these versions lib.so file. in order figure out start looking in source tree lib.so, need know version number in each of release builds. is there command line tool printing version of shared object? i never did native android programming android uses linux kernel, executable format used "elf". far elf concerned, there no version information of shared object stored in file. unless file name saying "libxxx.version.so" , there no other way find out version number of shared object. technique used in linux. my suggestions solving issue are: use date modified if possible differentiate shared objects use dlopen() or similar open shared object , try see functions being exported. source: http://man7.org/linux/man-pages/man5/elf.5.html note: e_version in executable version of elf format, not of executable.

c++ - Fail to pass command line arguments in CreateProcess -

i'm having trouble using createprocess command line arguments. i've read posts i've found none of solutions did work. here's have: std::string path = "c:\\my\\path\\myfile.exe"; std::wstring stemp = std::wstring(path.begin(), path.end()); lpcwstr path_lpcwstr = stemp.c_str(); std::string params = " param1 param2 param3"; startupinfo info = { sizeof(info) }; process_information processinfo; createprocess(path_lpcwstr, lptstr(params.c_str()), null, null, true, create_new_process_group, null, null, &info, &processinfo); the code works , myfile.exe (a qt application) opened, argc 1. i've tried specifying first parameter "c:\my\path\myfile.exe param1 param2 param3" didn't work either. any appreciated. solution: using createprocessa , change parameters accordingly fixed problem pointed out 1 of answers. startupinfoa info = { sizeof(info) }; process_information processinfo; std::string path = "c:\\my\\path\\

java - Android library module with extendable service -

i need develop android library has service component. service requirements are: works started service (always started) started , restarted alarm service when required (another service within library) started system boot (boot_completed) provide way subscribe service events (which should executed in context of service, mean in background well) the purpose of service provide client (android application) use ability subscribe events should executed in background. dure limitation extended client should receive notification in background (even when client not started) can see extension service (derived service reconfigured @ manifest @ client app). what proper approach achieve goal? how should base service communicate client extension? so first client have add service androidmanifest.xml . client call methods library start service or alarm service, depending on needs. communication depends on data want send service client's app. if it's notification best wa

How to use Google Content Experiment with Google Tag Manager -

i couldn't find answers on how use/implement google content experiments gtm. i have set-up gtm container ga code , in original page experiment have google experiment code @ beginning of html tag. problem i'm having not users counted in google analytics experiments report. is still impossible use google content experiments in gtm? ( how run google experiment within google tag manager - seems bit old discussion) what best way of implementing experiment code in tag manager? it's still impossible implement google experiments gtm. however far understand - implemented experiment code in normal way. did checked if experiment set 100% of visitors? if it's less - it's normal visits outside of experiment , sounds case you. other - gtm shouldn't affect experiment in way, don't use gtm it.

javascript - html5mode doesn't remove hashbangs -

i have gulp connect server running , want remove hashbangs routeprovider using in angularjs project. i have in app.js: //setting html5 location mode companiesapp.config(['$locationprovider', function ($locationprovider) { $locationprovider.hashprefix('!'); $locationprovider.html5mode(true); } ]); i know if remove hashprefix work still http://www.example.com/#example-uri how rid of entirely. isn't html5mode(true) supposed that? yes, $locationprovider.html5mode(true); should that. but able access pages directly browser, should configure server redirect request index page, call partial internally. check document on angular-ui documentation how configure document so.

Print assembly output of compiled d program like asm.dlang.org -

how replicate functionality of http://asm.dlang.org/ locally? how can print assembly output of compiled code-snippet written in d language? the easiest way disassemble compiled object file or final binary. on linux, can use objdump , on windows, digital mars sells obj2asm utility.

c++ - qreal equality fails in release, but works in debug (and cast to float also works) -

in code, have large number of checks equality... for example: int main(int argc, char *argv[]) { qapplication a(argc, argv); qgraphicslineitem* x = new qgraphicslineitem(50, 50, -50, -50); qgraphicsview view(new qgraphicsscene(-200, -150, 400, 300) ); view.scene()->additem(x); view.show(); bool sameline = true; qlinef line1 = x->line(); qreal _length = line1.length(); foreach(qgraphicsitem* item, view.scene()->selecteditems()) { qgraphicslineitem *item2 = dynamic_cast<qgraphicslineitem*>(item); if(item2->line().length() != _length ) sameline = false; } qdebug("same line: %d", sameline); } it seems work... in debug. when tested in release, fails ? assume single selected item, item1 , item2 same, regardless of precision, above lengths should equal.... in debug, have not been able see fail... yet in release, fails ! the functions above ( length() ) return qreal

html - Vertical align h2 in div -

ok, i've got following html structure <div class="category"> <div class="container bottom"> <h2>name1</h2> </div> <div class="container top"> <h2>name2</h2> </div> <div class="container "> <h2>name3</h2> </div> <div class="container"> <h2>name4</h2> </div> <div class="container"> <h2>name5</h2> </div> <div class="container"> <h2>name6</h2> </div> <div class="container"> <h2>name7</h2> </div> </div> the css this: * { margin: 0; padding: 0; } .category { text-align: center; width: 95%; margin: 0 auto; } .container { display: inline-block; width: 33%; height: 4em; } h2 {

yii2 - How to customize vendor view files? -

in yii2 how customize vendor view files without modifying original view files? i'm using dektrium yii2-user , make few changes login page. you can assign view path dektrium yii2-user in way (assume @app app alias) : 'components' => [ ....... 'view' => [ 'theme' => [ 'pathmap' => [ '@dektrium/user/views' => '@app/views/your_dir_views' // mapping override views dektrium views ], ], ..... ],

powershell script reading parameters from txt -

i have script takes 2 parameters (name , location). put name , location txt file per post here powershell parameters file . got prompted put in value 2nd parameter: import-csv 'c:\temp\paramtest.txt' | % { c:\temp\script\paramtest.ps1 @_ } cmdlet paramtest.ps1 @ command pipeline position 1 supply values following parameters: param2:** this .txt like: "param","param2" "foo","c:\temp" "bar","c:\temp" "foobar","c:\temp" and powershell script plain: param ( [parameter(mandatory=$true,position=1)] [string]$param, [parameter(mandatory=$true,position=2)] [string]$param2 ) $greeting='hello ' + $param + ' , ' + $param2 write-output $greeting any appreciated. when import file import-csv cmdlet, objects of type pscustomobject back. the splatting operator ( @ ) expects hashtable, not pscustomobject . powershell 3.0+ to import

android - ViewPager Andorid:NullPointerException: Attempt to invoke virtual method -

i've got fragment have added 2 sliders in xml file: public class filterslider extends fragment implements fragmentlifecycle { private static final string tag = filterslider.class.getsimplename(); relativelayout relativelayout; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.filter_slider, container, false); return view; } and xml file looks: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <seekbar android:id="@+id/seekbarmin" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout

php - Rewriting Magento Core Product Model using Module -

not sure doing wrong here.. trying rewrite magento core catalog product model (app/code/mage/catalog/model/product) using custom module. see code below: app/code/local/james/catalog/etc/config.xml : <?xml version="1.0"?> <config> <modules> <james_catalog> <version>1.0.1</version> </james_catalog> </modules> <global> <models> <catalog> <rewrite> <product>james_catalog_model_product</product> </rewrite> </catalog> </models> </global> </config> app/code/local/james/catalog/model/product.php : <?php require_once('mage/catalog/model/product.php'); class james_catalog_model_product extends mage_catalog_model_product { public function test() { return "function called"; } } app/etc/modules/james_catalog.xml : <?xml version="1.0"?> <config> <modules> <

unicode - Error While Renaming An Extracted Zip File To Other Languages In PHP -

Image
i use php ziparchive class extract .zip file, works fine english, cause problems in local language (thai). i use icov('utf-8','windows-874',$zip->getnameindex($i)) convert utf-8 thai. works folder's/file's name, doesn't work extracted .zip file , cause error : iconv(): detected illegal character in input string can please tell me problem here? my php code $file = iconv('utf-8', 'windows-874', $_get['file']); $path = iconv('utf-8', 'windows-874', $_get['path']); $zip = new ziparchive; if ($zip->open($file) === true) { // convert thai language for($i = 0; $i < $zip->numfiles; $i++) { $name = $zip->getnameindex($i); //echo iconv("charset zip file", "windows-874", $name); //$zip->extractto($path,$name); -> problem } $zip->close(); echo json_encode('unzip!!!'); } else { echo json_encode('failed

r - write.csv writes an empty file -

i created data.frame cust_data_360 2 data sets cust_data , cust_demo using following sql query : used sqldf package cust_data_360 <- sqldf('select * cust_data id not in(select id cust_demo)') when try write output using write.csv : write.csv('cust_data_360', file = 'cust_data_360.csv') the file written @ working directory blank. not sure problem? cust_data_360 has 44 observations 10 variables. to clarify @akrun - don't quote name of object writing. use write.csv(cust_data_360, file="cust_data_360.csv") the csv created shouldn't empty: > write.csv('cust_data_360', file = 'cust_data_360.csv') > now view (linux command line, in windows, open in notepad) $ cat cust_data_360.csv "","x" "1","cust_data_360" it contains 2 lines me.

android - this keyword as parameter to a new Intent -

from android documentation: public intent (context packagecontext, class<?> cls) parameters packagecontext context of application package implementing class. cls component class used intent. correct me if wrong: a context of application package implementing class. means package contains class want start. this shouldn't work(but works, why?), because this refers current activity, not application package says in documentation. a context of application package implementing class. means package contains class want start. here, "application package", cases, is referring app. this shouldn't work yes, should. this refers current activity, not application package says in documentation. assuming current activity , activity started both in same app, this works fine, "a context of application package implementing class". this not work if trying start activity other app, in case use implicit intent pattern, u

Canvas Paint text size android -

i have mutable bitmap , i'm drawing on canvas. after want draw pre-defined text on bitmap. problem have different bitmap sizes, though i'm setting text size 20sp, depending on bitmap size text bigger of smaller, want text size same images. should do? thought of maybe scaling text size depending on image width , weight i'm not sure how that. final bitmap mutablebitmap = bitmap.copy(bitmap.config.argb_8888, true); final canvas canvas = new canvas(mutablebitmap); final paint paint = new paint(); paint.settextsize(getresources().getdimensionpixelsize(r.dimen.myfontsize); canvas.drawtext(text, x, y, paint); first of if ondraw method doing wrong work here. shouldn't allocate inside ondraw method. on other hand , shouldn't change text size bitmaps. resize bitmaps on same values(width , height) , setting text same value.

html - Maintaining a videos aspect ratio in a responsive layout -

i'm trying maintain videos aspect ratio in responsive layout prevent black edges when layout changes size. far, i've set media queries, while re-sizing there still points video has black edges. you can see layout , video here http://smedia.lv/ (the showreel video). the video embedded vimeo iframe , has width , height of 100%. video container width depends on screen size , defined in %, height fixed value. how can keep aspect ratio of video, doesn't have black edges? what want fluid width video . adding few styles container ( .video ) , iframe accomplish this. .video { height: 410px; width: 964.71px; margin: 0 auto; } iframe { width: 100%; height: 100%; } /* adjust max-width depending on other styles on site. */ @media(max-width: 1046px) { .video { position: relative; /* 40:17 aspect ratio */ padding-bottom: 42.5%; height: 0; width: auto; } iframe { position: absolute; top: 0; left: 0; } } checkout

ios - fatal error: unexpectedly found nil while unwrapping an Optional value (cellForRowAtIndexPath) (Xib Custom Cell Swift) -

i error stated in topic unknown reason cell reference(in downloadprofilepicture) visible. basically, trying replicate/adapt done in lazytableviewimages override func viewdidload() { super.viewdidload() self.tableview.registerclass(topcell.self, forcellreuseidentifier: "topcell") self.tableview.registerclass(contentcell.self, forcellreuseidentifier: "contentcell") tableview.registernib(uinib(nibname: "topcell", bundle: nil), forcellreuseidentifier: "topcell") tableview.registernib(uinib(nibname: "contentcell", bundle: nil), forcellreuseidentifier: "contentcell") self.tableview.delegate = self self.tableview.datasource = self } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let nodecount = arrayofposts.count; let cell = uitableviewcell() tableview.dequeuereusablecellwithidentifier(&quo

Run a JavaScript function based off of PHP validation and form submit -

i have php validation , form setup php. if forgets username, validation add errors array , display on page when submitted. now, instead of displaying text error (username can't blank) want input box highlighted in red, know needs javascript. having trouble running javascript function properly. below code. javascript: <script type="text/javascript"> function myfunction() { document.getelementbyid("usernameformitem").classname = "formerror"; } </script> php: if (isset($_post['submit'])) { $required_fields = array("username"); function validate_presences($required_fields) { global $errors; foreach($required_fields $field) { //the $value un/pw without whitespaces $value = trim($_post[$field]); //if value not exist/is blank if (!has_presence($value)) { //remember field un or pw $errors[$field] = fieldname_as_text($field) . " can't blank"; echo "<scrip

php - ReflectionException in laravel: it cannot find a request that i just created -

i have request file named usersrequest (in app\http\requests) , @ top use app\http\requests\usersrequest i error: "reflectionexception in routedependencyresolvertrait.php line 57: class app\http\requests\usersrequest not exist" ..although manually created file php artisan make:request usersrequest yesterday renamed userrequest usersrequest. use phpstorm , editor finds userrequest, not usersrequest (this last 1 in yellow) is there way of refreshing project or tell laravel usersrequest exists ? i went userrequest , works fine. maybe related pluralism or request name has match somehow class name

node.js - child_process.exec producing "♀" character -

Image
i have simple child_process.exec statement , output (stdout) has "♀" character @ beginning reason var exec = require('child_process').exec; exec('echo hi', function (err, stdout) { console.log(stdout); }); [ my node v0.12 , have iojs installed v2.3. i've tested both separately same result. i've tested in different consoles - cmd.exe, powershell, , git's sh.exe, same result. is character supposed present? if not, might producing it? according child_process 's documentation , object passed stdout buffer object. need decode before printing out string. i modified code demonstrate how that. symbol no longer appears in console. var exec = require('child_process').exec; var stringdecoder = require('string_decoder').stringdecoder; var decoder = new stringdecoder('utf8'); exec('echo hi', function (err, stdout) { var message = decoder.write(stdout); console.log(message.trim()); });

mobile - J2ME (Java ME): StringItem Alignment -

in simple words, possible center stringitem or fit width of screen? know may need provide no example code, instance: stringitem addbutton = new stringitem("", "add new", item.button); how apply on button example? addbutton.setlayout(stringitem.layout_center); btw name "addbutton" should rather lowercase

javascript - addClass() not working -

i have bootstrap button <button onclick="leaveopen()">test</button> it calls custom function function leaveopen(){ $("#rangedropdown").addclass('open'); $("#dropdownmenu2").trigger('focus').attr('aria-expanded', 'true'); }(jquery); which should affect these elements <div class="dropup mobilewidth mobilebottom" id="rangedropdown"> <button class="btn btn-default dropdown-toggle mobilewidth" type="button" id="dropdownmenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> ... </button> ... </div> this part works $("#dropdownmenu2").trigger('focus').attr('aria-expanded', 'true'); but part doesn't $("#rangedropdown").addclass('open'); when click the test button, "dropup mobilewidth mobilebottom" l

python - How to access to a key of a result of .value() queryset -

i have queryset: p = respuestapreguntaseleccionmultiple.objects.all().values('respuesta').annotate(count('respuesta')) the result this: [{'respuesta__count': 2, 'respuesta': u'una vez'}] i need access respuesta__count or respuesta key, mean, 2 or "una vez" pass template, how can achieve this? you need iterate on result list: p = respuestapreguntaseleccionmultiple.objects.all().values('respuesta').annotate(count('respuesta')) item in p: item['respuesta__count'] # return 2 item['respuesta'] # return 'una vez'

javascript - JS Timer with setTimeout get a "Uncaught SyntaxError: Unexpected token (" -

i've been trying make javascript timer using settimeout() command. when @ in browser console returns "uncaught syntaxerror: unexpected token (". also can see code here: http://mathiakiaer.site88.net/timer/ this html code: <!doctype html> <html> <head> <title>timer</title> <link rel="stylesheet" type="text/css" href="style.css"> <script src="script.js" type="text/javascript"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <article> <p id="timertime"><span id="timertimeminutes">00</span>:<span id="timertimeseconds">00</span></p> <button id="timerstart" onclick='repeattimer()&

php - PhpStorm unable to unlock files (Ionic) -

Image
i'm making webapp using laravel 5 backend , ionic frontend. the ide i'm using phpstorm 8 i've been running problem. whenever try make new ionic project (ionic start myapp tabs/sidemenu...) folder gets locked in phpstorm, cannot edit single file, pop 'clear read status' clicking ok not change anything. i've tried several things: placing folder everywhere on hd, creating ionic folder sudo , adding chmod 777 . @ first i've added ionic folder backend project, made them stand-alone too, nothing seems work: cannot edit file in ionic project. every kind of helpful since i'm stuck right now... it might little bit late since question on year old, user owner of file? instance if user your-username-here:staff folder/file owned _www:_www phpstorm won't able open file since runs your-username . to remedy add user group owns file (or folder). on macos can following: sudo dseditgroup -o edit -a whoami -t user _www if owner of group _ww

get - Security : primary key parameter in an url -

i have question security. have website using url that: www.mysite.com/product?id=4 on server side, check of course if product id=4 exists , if connected user has right permission see page product. if not user gets error "not authorized". my problem id=4 primary key of table. , wonder if idea primary key appears in clear in url. perhaps www.mysite.com/product?id=45t6yhyu431azefgthu78n is better? better transform these parameters in address bar? or not necessary if security managed correctly on server side ? it depends on identifier refers to. have wonder attacker can information. leaking opaque identifier in url give attacker valuable information? can he/she use information retrieve more information in unsecured way? if example identifier medical record number (mrn) used in other systems , on numerous paper forms, hipaa violation use identifier in url. if on other hand identifier points product in inventory table fine use in url fragment or query p

jquery - Replace text with img based off of text -

i want replace text img using part of itself: <li class='custom'> <legend>images:</legend> {[img.png][1desc][2desc]} {[img2.png][1desc2][2desc2]} </li> i want appear this: <li class='custom'> <legend>images:</legend> <img src="img.png" title="1desc - 2desc"/> <img src="img2.png" title="1desc2 - 2desc2"/> </li> current code using(doesn't work): <script> function texttoimg(theimg) { return theimg.replace( /\{\s*[\s*(.*?)\s*]\s*[\s*(.*?)\s*]\s*[\s*(.*?)\s*]\s*\}/gi, '<img src="$1" title="$2 - $3"/>' ); } jquery('li.custom').each(function() { current = jquery(this); img = texttoimg(current.html()); current.html(img); }); </script> it looks [ , ] in regular expression not being escaped. try ( demo ): function texttoimg(theimg) { return th

gpgpu - Blending in opengl compute shaders -

since imageatomicadd (which seems real atomic "read-modify-store" function operates on images) available 32bit integers, don't see sensible way accumulate multiple color values different shader invocations in 1 pixel. the reasonable way can see use 32bit per color (128bit per rgba pixel), add 8bit color values up, hope doesn't overflow , clamp 8bit afterwards. seems wasteful , restrictive (only pure additive blending?) accumulating in other data structures doesn't solve issue, since shared variables , ssbos seem support atomicadd , on integers. there 2 reasons make me think missing something: 1. every pathtracer allows concurrent intersection testing (for example shadow rays) has solve issue seems there must solution. 2. kinds of fancy blending can done in fragment shaders, hardware capable of doing this. is writing pathtracers have 1:1 shader invocation:pixel mapping?

html - Unable to images in collapsed columns on a mobile device - bootstrap -

Image
question background: i have webpage features column 4 images. each column set @ col-lg-3 , col-sm-12 respectively. implementing media queries resize images when site used on mobile devices. the issue: the images evenly space when viewed on pc or on mobile device when held horizontally when viewed on device in portrait style images no centering in divs. this page when viewed on pc or on device horizontally: this when viewed on device held in portrait fashion: code: this html markup images: <div class="productlogo"> <div class="container"> <div class="row"> <div class="col-lg-3 col-sm-12 text-center" style="padding-top:5px; padding-bottom:5px; width:25%;"><img class="img-responsive" src="~/images/camaroweb.png" /></div> <div class="col-lg-3 col-sm-12 text-center" style="padding-top:15px; padding-bottom:15

python 2.7 - How to get something stuck to something else? -

i try apple picture on top on white triangle when apple on triangle , press h. i'm stuck , don't know do. when hit h, nothing or bad happens. can move rectangle around, not pick picture. , not know how rectangle leave apple either. here's code: import pygame import random pygame.locals import * screensize = (640,480) surface = pygame.display.set_mode(screensize) running = true clock = pygame.time.clock() x = 1 y = 1 = random.randint(0,640) b = random.randint(0,480) while running: clock.tick(15) surface.fill((20,150,100)) event in pygame.event.get(): if event.type == pygame.quit: running = false if event.type == pygame.keydown: if event.key == pygame.k_left: x -= 10 elif event.key == pygame.k_right: x += 10 elif event.key == pygame.k_up: y -= 10 elif event.key == pygame.k_down: y += 10 elif event

c++ - How do I solve the following scenario : adding images when pushing button? -

Image
i have following problem solve. working on programm bachelorthesis , have create qt program, adds picture if push add, right next old picture. explain showing pictures. so if click on add button should happen: and on. @ moment, hide labels , make them visible if push add. guess it's not best way solve it. thinking array of labels or that. does have idea on how achieve this?

How to load VM_global_library.vm for Velocity in Spring Boot? -

we're using velocitylayoutservlet view resolver in spring boot. @bean(name = "velocityviewresolver") public velocitylayoutviewresolver velocityviewresolver() { velocitylayoutviewresolver resolver = new velocitylayoutviewresolver(); this.properties.applytoviewresolver(resolver); resolver.setlayouturl("layout/default.vm"); return resolver;} we want load global macros vm_global_library.vm file, described in velocity user guide . expected velocity load default file /templates directory, not happening. adding theexplicit setting mentioned in velocity user guide did not work either: spring.velocity.velocimacro.library=vm_global_library.vm velocimacro.library - comma-separated list of velocimacro template libraries. default, velocity looks single library: vm_global_library.vm . configured template path used find velocimacro libraries. are missing magic, or missing integration? velocity properties can set "

Laravel 5 - DropzoneJS: Request object is empty -

Image
i've decided upgrade website laravel 4.3 laravel 5.1 , i'm facing strange problem. i'm trying upload pictures using dropzonejs library. i'm telling library: "before sending pictures /pictures/store (with ajax post method), adds album_id parameter request". this part working in picturecontroller , store action taking request object remains empty instead of containing inputs , many other things. view: {!! form::open(['url' => '/pictures/store', 'class' => 'dropzone', 'id' => 'myawesomedropzone']) !!} {!! form::hidden('album_id', $album->id) !!} // gives correct value here {!! form::close() !!} js: var token = $('meta[name="csrf-token"]').attr('content'); dropzone.options.myawesomedropzone = { paramname : 'file', maxfilesize : 8, // mo acceptedfiles : 'image/*', headers : { 'x-csrf-token' : token

c# - Only last member of a list gives a Rectangle Intersect xna -

this similar problem posted here: only last made member of list updating again have list of players (for multiplayer purposes) , list of blocks(basically texture assigned position , rectangle). i have function named collision engine supposed detect collisions between each block in list , player. here function using attempt detect if player intersecting any block (in case 500 randomly generated trees). foreach (blocks b in main.initializer.blocklist) { foreach (player p in main.initializer.playerlist) { if (p.hitbox.intersects(b.box)) { p.intersection = true; } else { p.intersection = false; } } } at first thought wasn't detecting collision @ all, noticed is detecting collision, detects on last placed block in list (figured out after limiting amount of trees 1, 2). if explain me fix appreciated. i have secondary o

c++ - confusion of char* str="ab", str and &str -

i learning pointer , code. defined pointer char (string actually) *str , pointer int *a , defined in same way. thought both str , a should address, when tried output str , &str , a , &a , found str not address, string. difference between char *str , int *a in terms of type of str , a ? thank you. #include<iostream> #include<string> using namespace std; int main() { char *str = "fa"; cout << "str: " << str << endl; cout << "&str: " << &str << endl; int b = 5; int *a = &b; cout << "a: " << << endl; cout << "&a: " << &a << endl; } this output: str: fa &str: 0x7fff5a627280 a: 0x7fff5a62727c &a: 0x7fff5a627288 the << operator streams has overload char * outputs c-style string. want, if it's not want, can use reinterpret_cast<

javascript - HTML id tag conflict with array member -

my page has bunch of id's on <div> elements - xx1, xx2, xx3, xx4 . i have array, idindex = [xx1, xx2, xx3, xx4] , used construct id tag using jquery, follows: $("#" + idindex[2]).text("new text here"); unfortunately, not work. javascript dereference actual id in page instead of constructing tag, , tells me idindex[2] [object htmldivelement] , jquery command not work. how build name of id tag? if have div id of xx1 , there global variable called xx1 element in question. when write idindex = [xx1] , you're building array of div elements. if want build array of string ids, need idindex = ["xx1"] etc. quotes important. that said, already have array of elements. instead of re-selecting element dom id, wrap element in jquery object: var $el = $(idindex[2]); by way of explanation, here's single div id of xx1 . can see there xx1 variable , wrapping in $() works fine: console.log(xx1); $(xx1).text(

[php]Upload, edit and download image file within single use of form -

since time i'm digging topic, doing research , not easy seems be. want achieve script loading image file client's pc, edit (add single letter in top left corner of image) , save new file on client's pc. far i've learned how create uploader , secure loading files other images, how open image file edit gd extension. have problems with: how open uploaded file, not want store file in other location /tmp (file should removed right after finishing whole operation). have no idea yet how access uploaded file i'm unable open editing gd , save file on client's device. so far ended think not way should written, should have change make work? <?php //basic info uploaded file $origfilename = $_files['userfile']['name']; $type = $_files['userfile']['type']; $size = $_files['userfile']['size']; $tmpname = $_files['userfile']['tmp_name']; $errors = $_files['userfile'

python - How to call code within Django when new Models are registered -

i'd able trigger code run when new db model registered in django installed_apps . the use case: want add dynamic global permission on django models in app. i have code works, have schedule it, , i'd rather have run when new apps registered once. from django.db import integrityerror django.contrib.auth.models import contenttype, permission perms_map = { 'get': ['%(app_label)s.view_%(model_name)s'], 'options': ['%(app_label)s.view_%(model_name)s'], 'head': ['%(app_label)s.view_%(model_name)s'], 'post': ['%(app_label)s.add_%(model_name)s'], 'put': ['%(app_label)s.change_%(model_name)s'], 'patch': ['%(app_label)s.change_%(model_name)s'], 'delete': ['%(app_label)s.delete_%(model_name)s'], } def _create_model_view_permissions(): ''' create 'view_(model_name)' permission models. run when adding new m

ruby on rails - How to Hide "Private" Show Pages from Other Users? -

in other words if user types in example: http://0.0.0.0:3000/goals/3 they able see user's goal if user submitted "private". had overlooked because stands submitting via "private" hides goal user's profile , feed, not if user directly searches via url. how can fix this? goals_controller class goalscontroller < applicationcontroller before_action :set_goal, only: [:show, :edit, :update, :destroy, :like, :user_goals] before_action :logged_in_user, only: [:create, :destroy] before_action :correct_user, only: [:edit, :update, :destroy] def index if params[:tag] @goals = goal.tagged_with(params[:tag]) elsif params[:user_id] @accomplished_goals = user.find(params[:user_id]).goals.accomplished.order("deadline") @unaccomplished_goals = user.find(params[:user_id]).goals.unaccomplished.order("deadline") else @accomplished_goals = current_user.goals.accomplished.order("deadline")

angularjs - How to load directive in ui-router using $ocLazyLoad -

i've seen similar questions no solution seems work me. i'm trying lazy load directives in ui-router. idea template "<my-directive></my-directive>" , i'm using resolve load js directive. looking around , reading documentation got far. app.config(function($stateprovider, $urlrouterprovider) { $urlrouterprovider.otherwise("/"); var lazydeferred = {}; $stateprovider.state('app',{ url: '/app/:id/:directive', templateprovider: function() { return lazydeferred.promise; }, resolve: { load: ['$oclazyload','$q','$http','$stateparams','$compile', function($oclazyload, $q, $http,$stateparams,$compile) { lazydeferred = $q.defer(); return $oclazyload.load('/directives/calculator.js').then(function() { var template = "<"+$stateparams.directive+"></"+$s

jvm - Are objects prefetched from an array of references in Java? -

imagine have 1000 objects of same type scattered across memory (they created @ different times , other objects have been created in between). we have array holds references each of 1000 objects. question if iterate on array sequentially, prefetched cache of cpu? references array holds or references dereferenced , objects loaded cache well? does java (the jvm) implement kind of software prefetching? if not, there libraries provide software prefetching? after research, common jvm implementation (hotspot) used to support prefetching . has been removed , since there no practicle use them. @apangin link bug report. as @markspace mentioned, objects re-arranged easier access during collections - called "compacting", , present in default gc used hotspot. shouldn't need worry such underlying details, vm handles you. a little deeper compacting.. you've heard of "stop-the-world" - occurs when object graph in inconsistent state. objects bein

jquery - Navbar shows and hide menu in just one click, next click do nothing -

i using zerif-lite theme 1 of projects. in project on smaller screens when click on toggled menu, shows automatically hides again. website can found here there way disable it? add following code css file after bootstrap.css: .navbar-collapse.in { height: auto !important; }

c# - WPF Nesting ItemsControls -

i've began meddling itemscontrols/binding, , i've encountered issue. i've looked @ various tutorials regarding nested itemscontrols, i'm not positive i'm doing wrong. believe coded correctly, expander doesn't display content ought to. header aligns top of parent, scrollviewer won't appear, , scrolls parenting "timescrollviewer". perhaps binding incorrectly? all suggestions appreciated. c#: private string[][] hours = new string[][] { new string[] { "11:00", "11:30", "12:00", "12:30", "1:00", "1:30", "2:00", "2:30", "3:00", "3:30", "4:00", "4:30", "5:00", "5:30", "6:00", "6:30", "7:00", "7:30", "8:00", "8:30" }, new string[] { "5:00", "5:30", "6:00", "6:30", "7:00", "7:30", &qu

android - Null Pointer Exception at pager.setAdapter() -

i getting null pointer exception @ pager.setadapter(tabpager); here code please check out , let me know error java code main activity package com.example.prototype; import android.app.actionbar; import android.app.actionbar.tab; import android.app.actionbar.tablistener; import android.app.activity; import android.app.fragmentmanager; import android.app.fragmenttransaction; import android.os.bundle; import android.support.v4.app.actionbardrawertoggle; import android.support.v4.app.fragmentactivity; import android.support.v4.view.viewpager; import android.support.v4.widget.drawerlayout; import android.support.v4.widget.drawerlayout.drawerlistener; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.arrayadapter; import android.widget.listview; import android.widget.toast; public class mainactivity extends fragmentactivity implements actionbar.tablistener { tabspageradapter tabpager; viewpager pager; drawer