Posts

Showing posts from May, 2015

c# - string concatenation and reference equality -

in c# strings immutable , managed. in theory mean concatenation of strings a , b cause allocation of new buffer pretty obfuscated. when concatenate identity (the empty string) reference maintains intact. compile time optimization or overloaded assignment operator making decision not realloc @ runtime? furthermore, how runtime/compiler handle s2 's value/allocation when modify value of s1 ? program indicate memory @ original address of s1 remains intact (and s2 continues pointing there) while relloc occurs new value , s1 pointed there, accurate description of happens under covers? example program; static void main(string[] args) { string s1 = "some random text chose"; string s2 = s1; string s3 = s2; console.writeline(object.referenceequals(s1, s2)); // true s1 = s1 + ""; console.writeline(object.referenceequals(s1, s2)); // true console.writeline(s2); s1 = s1 + " else&qu

Automatically accept shared folder invites in Dropbox with core API -

i'm using dropbox core api. there way, via api, accept invite shared folder, or there setting can use automagically accept folder shared account. no, api doesn't offer calls managing shared folders, can't use programmatically accept shared folder invitations. there isn't setting automatically accepting shared folder invitations.

dockerfile - Getting an "operation not supported" error when trying to RUN something while building a docker image -

i'm trying build docker image following command: docker build -f conf/dockerfile -t my_app_name . the dockerfile starts with: from ubuntu:14.04 copy conf/pubkey pubkey run echo 'deb http://downloads.skewed.de/apt/trusty trusty universe' >> /etc/apt/sources.list \ && apt-key add pubkey \ && rm pubkey and returns info[0000] operation not supported . regardless of put after run (even run echo 1 fails) i tried running shell in intermediate docker image ( docker run a7bb092… -it /bin/sh ) throws fata[0000] error response daemon: cannot start container a7bb092…: operation not supported how can fix this? well, turns out if machine had kernel update didn't restart yet docker freaks out. restarting machine fixed that. oops.

android layout - Bitmap.getPixel(j,i) returns wrong RGB values? -

Image
trying rgb values of pixel in jpeg image. screen shot of original image photoshop @ 2020% magnification i have made image("trial.jpg") in adobe self, , put few red, green , blue pixels in image (30,11) pixel grid starts @ 0,0(ie top left corner). here code: for(int = 0; < 11; i++) { for(int j = 0; j < 30; j++) { int c = garage.getpixel(j,i); int red1 = color.red(c); int green1 = color.green(c); int blue1 = color.blue(c); log.e("pixel",j + "/" + + "= red: " + red1 +" green: " + green1 + " blue: " + blue1); } } i check log, wrong rgb values. know cause put red(255,0,0), blue(0,0,255) , green(0,255,0) in particular squares(pixels). here log : 04-10 03:25:29.171: 0/0= red: 255 green: 7 blue: 0 04-10 03:25:29.171: 1/0= red: 191 green: 5 blue: 1 04-10 03:25:29.171: 2/0= red: 64 green: 1 blue: 3 04-10 03:25:29.171: 3/0= red: 64 green: 0

java - Finding minimum integer in ArrayList without collections -

i'm trying find smallest integer in arraylist using 2 simple for loops. tried 1 for loop, wasn't updating correctly. haven't learned collections yet, should done without using collections code. this have: public static void printinorder(arraylist<integer> data){ int minindex = 0 ; for(int = 0; < data.size(); i++){ minindex = i; for(int j = + 1; j < data.size() - 1; j++){ if(data.get(j) < data.get(minindex)){ minindex = j;} } system.out.println(data.get(minindex) + " "); } }//printinorder my minimum seems last value in list, tried printing data.get(minindex) in first for loop see happens, , seems update different values, , finally, last value. have no idea why happening. this it's printing example: original list: [47, 19, 46, 42, 15, 26, 36, 27, 13, 15, 1, 40, 34, 14, 6, 34, 28, 12, 15, 13] print minimum: 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 12 12 12 15 13 you can quick solution if want avoid u

linux - scp files using wildcard. Destination contains result of wildcard -

how can user download many text files @ once remote host using scp terminal using wildcards? in addition, using result wildcard save file in same named directory (lets assume exists). remote directories contain other files different names. instance: 4 files in remote host: [remote-host]:1dir/file.txt -> [local-host]:1dir/file.txt [remote-host]:2dir/file.txt -> [local-host]:2dir/file.txt [remote-host]:3dir/file.txt -> [local-host]:3dir/file.txt [remote-host]:4dir/file.txt -> [local-host]:4dir/file.txt i have tried using following no avail. please assist scp [remote-host]:'*dir/file.txt' '*dir/' try following retrieve files: scp user@host:~"/*dir/*.txt" . or can try: scp user@host:"~/*dir/*.txt" . it depends on how user account mapped in environment..

asp.net - Changing the columns titles on a GridView if I set the datasource on codebehind? -

how set gridview category columns titles manually if i'm databinding manually? namespace workforce { public partial class webform1 : system.web.ui.page { protected void page_load(object sender, eventargs e) { var s = work.datalayer.connection("test"); var x = work.datalayer.getcourselist(s); gridview1.datasource = x; gridview1.databind(); } } } in design view, there data source id i'm not using. how this gridview1.headerrow.cells[0].text = "new header";

java - How do I store an input file name -

i using code below read file document (the file different). anyway possible call file name @ end of running code print file called. here code using read in file. // creates file chooser , scans selected file. scanner input = null; file selectedfile = null; jfilechooser chooser = new jfilechooser(); if (chooser.showopendialog(null) == jfilechooser.approve_option) { selectedfile = chooser.getselectedfile(); input = new scanner(selectedfile); } thanks in advance , if need more information ask :) i'm not sure understand problem, maybe method you're looking getname() : string filename = selectedfile.getname(); if still have access file object, have name.

c# - Preprocessor directive "being consumed" building dll -

i have class several utility functions. class compiled dll used in user editor, of there 3 operative versions. these 3 versions (let's call them a, b , c) use core library different across 3 versions, named identically file, , overlapping functions , classes. to compile dll , able interface editor chose 1 version of core library, , referenced in solution. convenience in terms of cross compatibility other versions, choose b version of core library. now problem i'm facing: of functions / class properties in core libraries missing in 1 version in respect others, need able address these functions , classes , 'decide' (at runtime?) property use, address version-specific property of class / function user running. each version of editor exposes global define version. simple example: version class_a property_1 property_2 version b class_a identical version version c class_a property_1 property_3 <= property 2 has disappeared, must use per new api specifications

php - Looping total not same in database -

hello have script looping php, , each loop 4 data/row show ads . but have problem.. because in database have data 123 row. in show in php 92 row/data :'( this script <?php include "connection.php"; $i=0; $data_school=mysql_query("select * school"); while ($school=mysql_fetch_object($data_school)) { if($i%4==0) { echo "<br/><a href='#'><img src='ads.jpg' alt=''></a><br/>"; } else { echo $school->name_school"<br/>"; } $i++; } ?> when run in browser, , ads show school show " 92 row/data " if remove script if($i%4==0) { echo "<br/><a href='#'><img src='ads.jpg' alt=''></a><br/>"; } then script this <?php include "connection.php"; $i=0; $data_school=mysql_query("select * school");

ios - UITextView is partially scrolled down when view opened -

Image
i create uitextview , add lot of text it. when launch view, uitextview partially scrolled down. of cause user can scroll up, feels weird. what happens? did miss obvious settings? please refer following image. part of text cut out. borrow text link . i started simple single view application. how viewdidload looks like: - (void)viewdidload { [super viewdidload]; nsstring* path = [[nsbundle mainbundle] pathforresource:@"license" oftype:@"txt"]; nsstring* terms = [nsstring stringwithcontentsoffile:path encoding:nsutf8stringencoding error:nil]; self.textfield.text = terms; } and storyboard: this how looks after manually scroll top. add line @ end of viewdidload : [self.textfield scrollrangetovisible:nsmakerange(0, 1)]; like this: - (void)viewdidload { [super vie

angularjs - Wrapping directive with HTML -

i hoping more straight forward, i'm stuck. i'm trying figure out how can wrap select html without disrupting select itself. as far can see, if make directive called 'select', it'll trigger when add select html. , unless don't understand correctly, transclusion right means of doing this. so setup simple enough directive add html around select, doesn't anything. if add both transclude: true , replace: true , sorta works, though takes attributes of select , moves template div. i figured plnkr easiest way share code. should type out here too? http://plnkr.co/edit/mhadl7dkfrv7nechpxep?p=preview if don't need write template html , want adjust dom around select element, 1 of simple way wrap directive this. .directive('select', function(){ return { restrict: 'e', link: function(scope, element){ // adjust element want //element.addclass('prettyselect'); element.w

javascript - CSS style button look difference in FF and Chromium -

here example: http://jsbin.com/zirayuzose/2/ for reason need inputs borders styled in wrapper elements, , works fine andd looks fine in chromium, in firefox "ok" button has different height here, should not happen according css. idea how struggle it. html: <div class="inpwrap" style="width:25%"> <input class="inp" type="text"> </div> <div class="inpwrap" style="width:110px"> <button type="submit" class="inp1" style="margin: 0">ok</button> </div> css: .inpwrap { display: inline-block; border: 2px solid orange; } .inp { width: 96%; margin: 0px; padding: 3px; font-size: 20px; border: none; background: #fff; } .inp1 { margin: 0px; padding: 3px; font-size: 20px; border: none; background: #fff; } with minor adjustments looks want html <!doctype html> <html&g

many to many - Sequelize belongsToMany -

i have used sequelize , setup many-to-many relationship using belongstomany() . however, when query out data, this: api.models.operator.find({ where: { id: connection.params.id }, include: [ { model: api.models.permission, include: [ { model: api.models.activity } ] } ] }) i activity not associated permission! error. why? doesn't fact belongstomany connects activity through permission operator imply association? my permission model: module.exports = function(sequelize, datatypes) { return sequelize.define("permission", { id: { type: datatypes.bigint, allownull: false, primarykey: true, autoincrement: true }, operator_id: { type: datatypes.bigint, allownull: false, references: 'operator', referenceskey: 'id', comment: "the operator in permission." }, ac

android - Where do I bind my service? -

Image
i have fragementactivity class sub classed various activities. have service class handles communication between phone , device(ble device). not know bind activity? in base framgmentactivity class? if how work when switch between activities ? unbind every time because oncreate() called every time subclass called?

rest - C++ boost bad file descriptor -

above code im using calling browser , other client. doesnt seem work. there wrong? want know on ip im running server , how can used create restful webservice. #include <ctime> #include <iostream> #include <string> #include <boost/asio.hpp> using boost::asio::ip::tcp; using namespace std; std::string make_daytime_string() { using namespace std; // time_t, time , ctime; time_t = time(0); return ctime(&now); } int main() { try { boost::asio::io_service io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 13)); (;;) { cout << "listening socket" << endl; tcp::socket socket(io_service); acceptor.accept(socket); cout << "listening socket" << endl; std::string message = make_daytime_string(); boost::system::error_code ignored_error; boost::asio::write(socket, boost

Python: Trying to use polymorphism with pygame -

i'm trying use polymorphism in pygame project keep getting errors. i have moveable class , objects class inherits moveable , attributeerror: 'nonetype' object has no attribute 'ypos' in game loop. i plan on having more moveable objects in project people, houses, road signs... if can working. class moveable: __name = "" __xpos = 0 __ypos = 0 __hight = 0 __width = 0 __speed = 0 __image = 0 def __init__(self, xpos, ypos, hight, width, speed, image): self.__xpos = xpos self.__ypos = ypos self.__hight = hight self.__width = width self.__image = image def set_xpos(self, xpos): self.__xpos = xpos def get_xpos(self): return self.__xpos # ... , other getters , setters... class objects(moveable): def car(xpos, ypos, width, hight, speed, image): pygame.surface.blit(gamedisplay, image, [xpos, ypos, hight, width]) def game_loop(): game_exi

Using the DateDiff function in VBA to get number of days between 2 dates -

so i'm trying 2 dates in excel sheet , use datediff function number of days between 2 dates. adding number of days , dividing the number of rows , average amount of days. far have total amount of days every row gets added , displayed on column "e" , number of rows placed on column "f". know close because @ 1 point worked dumb , changed , not. here code , excel sheet. sub getdays() range("c1").select until activecell.value = "" date1 = datevalue(activecell.offset(1, 0).value) date2 = datevalue(activecell.offset(1, 0).entirerow.cells(1, "d").value) daycount = datediff("d", date1, date2) + daycount activecell.offset(1, 0).entirerow.cells(1, "e").value = daycount studentcount = studentcount + 1 activecell.offset(1, 0).entirerow.cells(1, "f").value = studentcount activecell.offset(1, 0).select loop end sub! here snippet of s

javascript - AngularJS including partial template -

i'm using angularjs ui router code .state('posts', { url: '/posts/{id}', templateurl: '/javascripts/templates/posts.ejs', controller: 'postsctrl', resolve: { post: ['$stateparams', 'posts', function($stateparams, posts) { console.log("post: ", posts.get($stateparams.id)); return posts.get($stateparams.id); }] } }) and script inclusion <body ng-app="..."> <div> <ui-view></ui-view> </div> .... <script type="text/ng-template" id="/javascripts/templates/posts.ejs" src="/javascripts/templates/posts.ejs"> this ejs(html) file itself <div class="page-header"> .... </div> however, cannot source holds ejs file load. when go correct url /posts/{id}

variables - Show text under img file with php echo -

someone can tell me how change code show variables in link: echo '<a href="download.php?q='.$title.'"><img src="'.$img.'" /></a>'; this shows img file want under img show title text. try this, don't work: echo '<a href="download.php?q='.$title.'">'.$title'</a>'; you forgot ending dot. replace echo '<a href="download.php?q='.$title.'">'.$title'</a>'; with echo '<a href="download.php?q='.$title.'">'.$title.'</a>';

excel - CONCATENATE function for two columns -

so have 2 columns in excel, , b. column has letters - j, , column b has number 1 - 9. write concatenate function string each letter in column number in column b. it's going a1, a2, ...a9, , @ b1, b2, ... b9. there anyway me put in macro? i assume this: dim rnga range dim rngb range but don't know should next. thank help. no macro necessary. assuming data in cell a1 , b1, place formula =a1&b1 into desired cell wish have concatenated result be. can dragged down using lower right hand corner of cell assuming entirety of columns concatenated.

How does RequireJS download a new script file? -

i'm trying wrap mind around requirejs. understand modularity provides , on-demand script loading. my doubt was: how can script download script? wondering whether exists api allows custom javascript code call script download, or how other way requirejs use accomplish that. i've searched around answer without success. i've found answer @ requirejs source code . i’ve found load function, if runtime environment browser, create <script> tag , put in <head> of document, appropriate url in src attribute. check createnode function also. once tag created , added document, browser download script file.

"Fixed default value provided" after upgrading to Django 1.8 -

django 1.8 has problem detection models, nice. however, 1 warning giving me, understand problem, don't understand how hint giving me better. this (bad) model field: my_date = datefield(default=datetime.now()) and it's easy see why that's bad. hint it's giving me: mymoel.my_date: (fields.w161) fixed default value provided.     hint: seems set fixed date / time / datetime value default field. may not want. if want have current date default, use `django.utils.timezone.now` so, says use timezone.now , how better datetime.now ? they're both "fixed default" values... timezone.now returns datetime instance, fixed value... i suspect wants me insert sort of flag says "use timezone.now later ". that's not hint says... flag? the function datetime.now() executed code imported, i.e. when (re)start server. subsequent model instances have same value. instead, should pass callable function default , executed eac

shell - Combine bash commands with each other -

i using following code execute bash command swift: func runcommand(cmd : string, args : string...) -> (output: [string], error: [string], exitcode: int32) { var output : [string] = [] var error : [string] = [] let task = nstask() task.launchpath = cmd task.arguments = args let outpipe = nspipe() task.standardoutput = outpipe let errpipe = nspipe() task.standarderror = errpipe task.launch() let outdata = outpipe.filehandleforreading.readdatatoendoffile() if var string = string.fromcstring(unsafepointer(outdata.bytes)) { string = string.stringbytrimmingcharactersinset(nscharacterset.newlinecharacterset()) output = string.componentsseparatedbystring("\n") } let errdata = errpipe.filehandleforreading.readdatatoendoffile() if var string = string.fromcstring(unsafepointer(errdata.bytes)) { string = string.stringbytrimmingcharactersinset(nscharacterset.newlinecharacterset()) er

c++ - How do I include GLFW 3.x, without errors? -

i have downloaded glfw 3.1.1(glfw-3.1.1.zip) computer. i want execute code: #include <glfw/glfw3.h> int main() { return 0; } in other words, want able include glfw in code, later on can open context (for opengl use). but error message when running code: error 1 error c1083: cannot open include file: 'glfw/glfw3.h': no such file or directory f:\opengl_coding\video_tut_test\video_tut_test\main.cpp 1 1 video_tut_test i know there step haven't done, don't understand step is. linking? see being talked lot in tutorials, never explain properly. how remove error , make possible execute above code? i use visual studio express 2013, on windows 8 machine. come java background.

How to find the sum of all numbers between 1 and N using JavaScript -

i'm trying find way calculate sum of numbers between 1 n using javascript. following code have tried far doesn't seem work. function numbersum(n) { var total = 0; for(var = 1; <= n; i++){ total += i; } return total; } i have tried using jslint , other validators online check if might have missed doesn't seem me find reason code not working either. there i'm missing above that's preventing script executing addition?? your code fine. keep simple: var res = (n * (n+1)) / 2; wiki .

html - VBA to click a button on a website and extract tables -

i want click button on website vba , extract table appears when clicked. my code here not working right now, how can that? i want click "get price quoted" button on right corner of table , extract appearing information. sub test() dim ie object dim doc object dim strurl string dim objelement object dim objcollection object strurl = "http://financials.morningstar.com/competitors/industry-peer.action?t=goog&region=usa&culture=en-us" set ie = createobject("internetexplorer.application") ie .visible = true .navigate strurl until .readystate = 4: doevents: loop while .busy: doevents: loop dim item object set item = ie.document.getelementsbyclassname("hspacer0") item.item(0).click until .readystate = 4: doevents: loop while .busy: doevents: loop set doc = ie.document getalltables6 doc .quit

python - how to partially apply arbitrary argument of a function? -

i want use partial functools partially apply function's second argument, know easy lambda rather partial follows >>> def func1(a,b): ... return a/b ... >>> func2 = lambda x:func1(x,2) >>> func2(4) 2 but strictly want use partial here (for sake of learning) came this. >>> def swap_binary_args(func): ... return lambda x,y: func(y,x) ... >>> func3 = partial(swap_binary_args(func1),2) >>> func3(4) 2 is possible extend strategy level can partial apply arguments @ place in following pseudocode >>>def indexed_partial(func, list_of_index, *args): ... ###do_something### ... return partially_applied_function >>>func5=indexed_partial(func1, [1,4,3,5], 2,4,5,6) in our case can use function follows >>>func6=indexed_partial(func1, [1], 2) is possible have indexed partial want ? there similar not aware of ? , more importantly idea of indexed partial or bad idea why ? this questi

Server side Java - where to start -

i'm starting hang of client-side java programming, , understand java great developing stable server sides large amounts of traffic. the problem i'm new server development, don't know start or information, despite java's documentation. more specific questions: do know good, non-specific tutorials server-side java? i've seen tutorials google's cloud platform , netscape, don't want dependent on infrastructure. is common practice develop code in eclipse , "ship" server? said i've never done server-side development , i've tried learning little node.js. thank in advance, hope these questions aren't wide-scoped. i suggest start simple setup told us: eclipse + let's easy use tomcat . if comes server side need create servlet shows allows access other application data server in format define or let's + client's define. suggest start familiar json. have little "startingpoint" you. clone simple exam

amazon web services - How to set content-length-range for s3 browser upload via boto -

the issue i'm trying upload images directly s3 browser , getting stuck applying content-length-range permission via boto's s3connection.generate_url method. there's plenty of information signing post forms , setting policies in general , heroku method doing similar submission . can't figure out life of me how add "content-length-range" signed url. with boto's generate_url method (example below), can specify policy headers , have got working normal uploads. can't seem add policy restriction on max file size. server signing code ## django request handler boto.s3.connection import s3connection django.conf import settings django.http import httpresponse import mimetypes import json conn = s3connection(settings.s3_access_key, settings.s3_secret_key) object_name = request.get['objectname'] content_type = mimetypes.guess_type(object_name)[0] signed_url = conn.generate_url( expires_in = 300, method = "put", buc

How do I stop testing in Python unittest tearDown()? -

i've got large number of tests written using python unittest (python 2.7.8) large testsuite . many of these tests invoke other programs. these other programs dump core. when do, want discover , ensure test fails. if number of cores dumped, want abort entire test environment , exit rather continuing: total test suite has >6000 tests , if dumping core it's useless (and dangerous: disk space etc.) continue. in order ensure coredumps after every test (so have best possible idea of program/invocation dumped core) decided cores in teardown() , doing successfully. if find core, can run assert variant in teardown() specify test failed. but can't figure out how give on testing within teardown() if find many cores. tried run sys.exit("too many cores") , unittest case.py catches every exception thrown teardown() except keyboardinterrupt (if try raise hand script hangs until real ^c ). i thought trying call stop() , method on result , can't find w

linux - Communication between linked docker containers -

i have 2 docker containers in following setup on host machine: container 1 - udp port 5043 mapped host port 5043 (0.0.0.0:5043:5043) container 2 - needs send data container 1 on port 5043 udp. scenario 1 i start container 1 , obtain it's ip address. i use ip address , configure container 2 , start it. container 2 able send udp data container 1 calling udp://container_1_ip:5043 everything works!! scenario 2 i start container 1 mapping 5043 udp port host's 5043 port ( 0.0.0.0:5043:5043 ) i link container 2 , container 1 using ' --links '. now, when container 2 invokes url udp://container_1_ip:5043 , error thrown " connection refused ". i did verify able ping container 1 inside container 2 using ip. any scenario 2 working me appreciated!! as mentioned in docker links : docker defines set of environment variables each port exposed source container. each variable has unique prefix in form: <name>_port_<po

java - Float value with 2 decimal places -

in android, value entered edittext converted float using following line of code. float addpurchunitcostprice = float.valueof(addpurchasecostprice.gettext().tostring()); i have value of addpurchunitcostprice 2 decimal places (always). how can done? floating-point values don't have decimal places. have binary places, , 2 incommensurable. if want decimal places have use decimal radix, i.e. bigdecimal.

jquery - Wait for complete execution of javascript code in an injected <script> element -

i'm loading javascript code via ajax (as <script> block inside html string), , i'm using jquery.html() inject payload <div> . jquery.html() method automatically evals injected <script> elements. i wait code in <script> block complete execution before releasing execution main event loop. if <script> contains callbacks, $.ajax().done() or setinterval() . if causes infinite loop, , if blocks other events being processed long time. is possible? i'm wondering if there's kind of synchronization-wrapper browser-supported utility in javascript. hunch no, since seems contrary single event-loop nature of javascript, thought i'd check :) ultimately, goal insert custom javascript page upon specific user action, , guarantee code executed in entirety. note don't need use jquery.html() or <script> injection, that's starting point. maybe best can tell client invoke specific pre-defined callback function when code fin

android - not able to launch the application on Samsung 4.0.4 devices -

i working on application. in project.properties file, using target=android-9 recently use dragevent , had updated target=android-17 after can install app on device android 4.0.4. cannot launch application. when click on app, not launch. i dont know why cannot launch on devices 4.0.4 version. is there mistake doing updagrading target=android-17 inside manifsest file have given please guide me know why cannot launch app on devices android 4.0 version is mistake cannot launch app on older 4.0.4 versions? sometimes code log shows native code library failed load.java.lang.unsatisfiedlinkerror: cannot load library: reloc_library[1285]: 165 cannot locate 'log2'... is hidden issues in android 4.0.4? or compiled using higher api version 17 . the crash show missing native library call. has nothing target change. target change problem though- 4.0.4 devices not have v17 functions, no matter target is. if put on devices without if statement preven

c - How to use perror with dup2? -

i'm adding error handling small c program , i've gotten work fork , execvp not dup2. int spawn_proc (int in, int out, struct command *cmd) { pid_t pid; if ((pid = fork ()) == 0) { if (in != 0) { dup2 (in, 0); close (in); } if (out != 1) { dup2 (out, 1); close (out); } if (execvp(cmd->argv [0], (char * const *)cmd->argv) < 0) { perror("execvp failed"); exit(1); } } else if (pid < 0) { perror("fork failed"); exit(1); } return pid; } how should perror used dup2 ? asked before don't think answer dup2 correct since program exits error dup2 if run no arguments if use code answer here. perror usage in case? my c program this. #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> st

working with php if statement -

i have following php if statements <?php if ($crs_cat1 == "business"){ $catimage ="businessimage.png"; } else if ($crs_cat1 == "leadership") { $catimage = "leadershipimage.png"; } else if ($crs_cat1 == "media , design") { $catimage = "mediadesignimage.png"; } else if ($crs_cat1 == "web development") { $catimage = "webdevelopmentimage.png"; } else if ($crs_cat1 == "mobile development") { $catimage = "mobiledevelopment.png"; } else if ($crs_cat1 == "project management") { $catimage = "business5.png"; } else if ($crs_cat1 == "databases , business intelligence") { $catimage = "businessanalysis.png"; } else if ($crs_cat1 == "it service management") { $catimage = "itservice.png"; } else if ($crs_cat1 == "business analysis , agile") { $catimage = "businessanalysis.png"; } e

tooltip - using CSS to change node design -

i dont know i'am doing wrong adding css style node. i have main application window. click menu item , modal window opens below( modalwindow extends stage ): fxmlloader loader = new fxmlloader(getclass().getresource(constants.root_user_edit.string)); borderpane editpane; try { editpane = new borderpane(loader.load()); modalwindow editwindow = new modalwindow(main.mainstage, editpane, "edit user"); //its new stage new scene, need load file again editwindow.getscene().getstylesheets().add(getclass().getresource(constants.css_path.string).toexternalform()); userdata userdata = (userdata)userstable.getselectionmodel().getselecteditem(); usereditwindowcontroller usereditwindowcontroller = loader.getcontroller(); usereditwindowcontroller.fillwithdata(userdata); editwindow.initmodality(modality.application_modal); editwindow.showandwait(); } catch (ioexception exception) { exceptiondi

php - How to fetch the row from MySQL having latest date -

i have table "poem" fields "dated","content" etc. i want content of recent dated field. $sql="select content, max(dated) latestdate poem"; this not working. if want 1 row, use order by , limit : select p.* poem p order dated desc limit 1; if want rows recent date: select p.* poem p p.dated = (select max(dated) poem);

c# - How to use WWW class to change the Sprite? -

i'm struggling change sprite image use www class in unity. i have picture of profile png on website i'd load in game. i'd change sprite of sprite renderer attached game object new sprite of personal profile. i think ienumerator can't used event, rearranged below. there no error didn't work. please let me know how this. using unityengine; using system.collections; using system.io; using uxlib.user; using uxlib.connect; public class userimage : monobehaviour { uxandroidmanager androidmanager; private spriterenderer spriterenderer; public material mat; void start(){ spriterenderer = getcomponent<spriterenderer> (); androidmanager.startgallery (login.userid); } void awake () { gameobject go = gameobject.find ("androidmanager"); androidmanager = go.getcomponent<uxandroidmanager> (); androidmanager.initandroid (); androidmanager.onand_profileimagechanged += onprofileimagechaned; } void ondestroy(

java - How to avoid null checking - OOP -

i making game , have tile class contains item. public clas tile{ item item; .... public void setitem(item item){ this.item = item; } } when have reference tile want call interact() method on item. how can without checking if object null . don't think null object pattern work in scenario because there mixed instance cohesion - subclass of item represent empty item have empty interact() method. you trying find way not check if object null, when null option. in case, design check if item != null , before execute item.interact() , not anti-pattern or hacking solution.

php - Wordpress Custom Post Type conflict with sub page -

heres setup: • page called weddings children pages called winter, spring, fall, summer. • custom post type called 'weddings'. • taxonomy called wedding_type assigned custom post type weddings. when go page website.com/weddings, shows of weddings posts, types on 1 page. when go website.com/weddings/summer, want use different template can query wedding posts, taxomomy 'wedding_type' of summer. 404. believe because looking wedding post called 'summer'. any ideas? don't have code post, set via cpt ui plugin. just change slug of parent page "weddings". slug of page may "weddings", can change "all-weddings" or "list-weddings". your problem automatically resolve change slug of page named "weddings".

PHP, Create dynamic list from files in a directory -

i have directory of files who's main purpose store php variables inclusion other files in site. each file contains same set of variables, different values. for example: event1.php <?php $eventactive = 'true'; $eventname = first event; $eventdate = 01/15; ?> event2.php <?php $eventactive = 'true'; $eventname = second event; $eventdate = 02/15; ?> in addition calling these variables in other pages, want create page contains dynamic list, based on variables stored in each file within directory. something (basic concept): for each file in directory ('/events') { if $eventactive = 'true'{ <p><? echo $eventname ?></p> } } what best way this? create event class or array of each event. populate directory. $index = 0; foreach (array_filter(glob($dir.'/*'), 'is_file') $file) { @include $file; // parses file, variables within set. $events[$index]['activ

php - How do I turn the debug bar off in one view in Yii2? -

how turn debug bar off in yii2? tried <?php use app\assets\appasset; define('yii_debug', false); appasset::register($this); $this->beginpage() ?> <!doctype html> but gave error constant yii_debug defined . don't want turn off whole app, view. tried yii::$app->modules['debug'] = null; , got php notice – yii\base\errorexception indirect modification of overloaded property yii\web\application::$modules has no effect this executed, debug bar still shows. $modules = yii::$app->modules; $module['debug'] = null; yii::$app->setmodules($modules);

rest - erlang response http request in decimal instead of letter -

i'm beginning using erlang cowboy , leptus create rest api. so tried simple: myapp_handler.erl -module(myapp_handler). -compile({parse_transform, leptus_pt}). -export([init/3]). -export([cross_domains/3]). -export([terminate/4]). -export([post/3]). %% cross domain origin %% accepts host cross-domain requests cross_domains(_route, _req, state) -> {['_'], state}. %% start init(_route, _req, state) -> {ok, state}. post("/myrequest", req, state) -> json = "[ { \"test\": \"hello\" } ]", {200, {json, json}, state}. %% end terminate(_reason, _route, _req, _state) -> ok. after launching server, tried run post request through curl: curl -x post http://127.0.0.1:8080/myrequest --header "content-type:text/json" and answer of request is: [91,10,32,32,32,32,123,10,32,32,32,32,32,32,34,116,101,115,116,34,58,32,34,104,101,108,108,111,34,10,32,32,32,32,125,10,32,32,93]