Posts

Showing posts from 2015

javascript - Routing doesn't work when in for-loop -

i building website using polymer (>= 1.2.0) based on psk (polymer starter kit) . i running (probably noob) problem attempting centralize and/or automatize router configurations. i have appended following code end of psk's app.js file: //note: app.baseurl set psk's original code earlier in file: app.baseurl = '/'; app.routemap = [ {name: "home", text: "home", icon: "home", url: app.baseurl}, {name: "about", text: "about", icon: "face", url: app.baseurl + "about"}, {name: "portfolio", text: "portfolio", icon: "build", url: app.baseurl + "portfolio"}, {name: "contact", text: "contact", icon: "mail", url: app.baseurl + "contact"} ]; i replaced original routing-configuration code in routing.html new version, uses routemap : page('*', scrolltotop, closedrawer, function (ctx, next) { next(); ...

python - Representing more than single object/list CRUD ops with Django REST Framework ViewSets -

i've been writing game picking style webapp django , decided implement views api endpoints drf, give me more flexibility when comes frontend approaches. have basic serializers , viewsets each of models, , can browse them (excellent) browsable api. here couple: class sheetserializer(serializers.hyperlinkedmodelserializer): user = userserializer(read_only = true) league = leagueserializer(read_only = true) picks = serializers.hyperlinkedrelatedfield( source='pick_set', many=true, view_name='pick-detail', read_only = true ) class meta: model = sheet fields = ('url', 'id', 'league_week', 'user', 'league', 'picks') class gameserializer(serializers.hyperlinkedmodelserializer): class meta: model = game fields = ('url', 'home_team', 'away_team', 'week', 'home_team_score', 'away_team_score') class pickserializer(serializers.hy...

java - How to make some Action dependent on another Action's finish? -

action pasteaction = new defaulteditorkit.pasteaction(); jpopupmenu popmenu = new jpopupmenu(); menuitem = new jmenuitem(); menuitem.addactionlistener(pasteaction); menuitem.addactionlistener(searchaction); menuitem.settext("paste & search"); popmenu menu shown up; on mouse right click on jtextfield pasteaction ready made. searchaction has code check if jtextfield empty or not. if not empty, search... the problem - think - pasteaction , searchaction invoked simultaneously. searchaction invoked no matter pasteaction has finished job. when searchaction invoked check jtextfield content; founds empty! how make searchaction dependent on pasteaction 's finish? one option make generic action implementation takes in list of actions take in serial. loop on list, calling 1 @ time. use new implementation , add action listener.

c# - LINQ to SQL - Checking the field length -

Image
i getting rows access db. need check fields length. got work, problem if field comes null. check fails. how made check length (array[0] column name checked), , works: results = query.where(p => p.field<string>(array[0]).length > 10); now problem if field null. screen shot displays field coming empty , fails check. field number 25. how can make ignore nulls , still check length? you can try avoid nulls. results = query.where(p => !string.isnullorempty(p.field<string>(array[0])) && p.field<string>(array[0]).length > 10);

ios - How to go back to main scene when my game paused in sprite kit -

when pause game have pause scene. i put there 3 buttons : rateapp button backtomain button. resumegame button. what happens: rateapp button working. resumegame button working. not working : backtomain button. why? because game still pause. pausegame function func pausegame() { ispause = true self.view?.paused = true pointslabel.hidden = true boocharacter.hidden = true pausebutton.hidden = true if #available(ios 9, *) { recordbutton.hidden = true } pausescreen = skspritenode() pausescreen.name = "pausescreen" pausescreen.position = cgpointmake(self.size.width/2, self.size.height/2) pausescreen.color = uicolor.blackcolor() pausescreen.alpha = 0.9 pausescreen.size = cgsizemake(1242,2208) addchild(pausescreen) pauselable.text = "pause" pauselable.fontsize = 75 pauselable.fontname = "fut...

dependencies - Official guidelines for using functions newly added to base R -

i writing package performs statistical analysis while handling missing values. using wonderful, life-changing function anyna added sometime after 3.0 ( commit ). added function people might want use olsonnames . so using function, package won't work on older versions of r. see 4 options dealing this. make whole package depend on r >= 3.1 in description. redefine function in source. redefine function if user using <3.1 , don't define if using >= 3.1 or make function check version each time e.g. anyna <- function(x) if(as.numeric(r.version()$minor) > 3.1){ return(anyna(x) } else { return(any(is.na(x)) } } or if(as.numeric(r.version()$minor) > 3.1){ anyna <- base::anyna } else { anyna <- function(x) any(is.na(x)) } i'm not sure second 1 work in package source code. rewrite code using any(is.na(x)) . my concrete question is there official cran preference 1 of these ? failing that, there reasons use 1 ...

Sorting objects in array within mongodb -

i've seen question on google/so/mongo docs, , i've tried implement solution, it's not working me. have following test database: > db.test.find().pretty() { "_id" : objectid("56b4ab167db9acd913ce6e07"), "state" : "helloworld", "items" : [ { "guid" : "123" }, { "guid" : "124" }, { "guid" : "123" } ] } and want sort "guid" element of items. running sort commands yields: > db.test.find().sort( {"items.guid" : 1}).pretty() { "_id" : objectid("56b4ab167db9acd913ce6e07"), "state" : "helloworld", "items" : [ { "guid" : "123" }, { "guid" : "124" }, { "guid...

Batch - How to add several variables to one variable? -

i have problem want add content of 1 parameter another. explain you. of code: set /a a=%a1%+%a2%+%a3%+%a4%+%a5%+%a6%+%a7%+%a8%+%a9% set /a b=%b1%+%b2%+%b3%+%b4%+%b5%+%b6%+%b7%+%b8%+%b9% set /a c=%c1%+%c2%+%c3%+%c4%+%c5%+%c6%+%c7%+%c8%+%c9% set /a d=%d1%+%d2%+%d3%+%d4%+%d5%+%d6%+%d7%+%d8%+%d9% set testtheanswer= following lines wrong: if %a% neq 45 (then should add "a, " %testtheanswer% , of course same other ones.) echo %testtheanswer% and @ end should like: "the following lines wrong: a, b, d ,". have option how in mind complicated... can me this? :) regards ok. there several points here; first 1 set /a command may work the names of variables, variable expansions not needed. should work: set /a a=a1+a2+a3+a4+a5+a6+a7+a8+a9 set /a b=b1+b2+b3+b4+b5+b6+b7+b8+b9 set /a c=c1+c2+c3+c4+c5+c6+c7+c8+c9 set /a d=d1+d2+d3+d4+d5+d6+d7+d8+d9 set "testtheanswer= following lines wrong:" if %a% neq 45 set "testtheanswer=%testtheanswer% a,"...

jquery - Javascript conditional table cell formatting failing in IE -

Image
i've got table in time reporting application renders work group's time 2 week pay cycle before paychecks cut. time reported on weekly basis , formatting (red = not yet reviewed) let's group's approver see ones have been reviewed vs not @ glance. the javascript below works charm in ff, not in ie. advice on how normalize it'll work in both? function formattimetable() { var ttables = $(".timetable"); var celllocs = [1, 10] (var = 0; < ttables.length; a++) { var rows = ttables[a].getelementsbytagname("tr"); (var b = 1; b < rows.length; b++) { var cells = rows[b].getelementsbytagname("td"); (var c = 0; c < celllocs.length; c++) { if (cells[celllocs[c]].innerhtml == "no") { (var d = 0; d <= 7; d++) { var curcell = cells[celllocs[c] + d]; $(curcell).addclass("redtext") } } } } } }

c# - Allow frame from different domain with MVC5 -

i trying load google maps iframe using mvc5 getting blocked error refused display ' https://www.google.com/maps?cid=xxxxx ' in frame because set 'x-frame-options' 'sameorigin'. so after searching, have tried following: adding antiforgeryconfig.suppressxframeoptionsheader = true; application_start in global.ascx creating attribute (have tried , without setting in global.ascx): public override void onactionexecuted(actionexecutedcontext filtercontext) { if (filtercontext != null) { filtercontext.httpcontext.response.headers["x-frame-options"] = "allow-from https://www.google.com"; base.onactionexecuted(filtercontext); } } trying attribute onresultexecuted(resultexecutedcontext filtercontext) instead of onactionexecuted remove in web.config: <httpprotocol> <customheaders> <remove name="x-frame-options" /> </customheaders> </httpprotocol> ...

How to call a result from a function in another one in R -

can please tell me how can call output 2 matrices input function? x1=function(y,z) { output1=y*z output2=y/z } x2=function(p,q) { input=x1(y,z) input1=input$output1 ??? how specify output can call way? output1 , output2 matrices! input2=input$output2 equation=input1+input2 } i tried return() , data.frame both didn't work. tipps? you can't use c might otherwise expect because you'll lose structure of matrices. instead, use list when want return multiple objects r function. x1 <- function(y,z) { list( output1=y*z, output2=y/z ) }

javascript - How to define variable before ajax call -

this question has answer here: how return response asynchronous call? 21 answers i have code: function aaa (){ var db_data; $.ajax({ url: "http://localhost:8888/aaa/{{$article->id}}", type: "get", async: true, datatype: "json", success: function(data) { db_data = data; console.log(db_data); }, error: function (data) { console.log(data); console.log('greska neka'); } }); console.log(db_data); }; but @ least line console.log(aaa) - > undefined... why? first console.log work ok outside ajax cant db_data... why? you ordering pizza, trying eat before delivered! ajax async call , success gets called-back long after last console.log executes. you need only use async data in s...

javascript - Angularjs $http.post and $http.get empty response from API -

Image
i'm trying information api, em run code bellow nothing. on firefox console : app.controller('test', function($scope, $http) { $http.post("http://api.olhovivo.sptrans.com.br/v0/login/autenticar?token=fde20482b4aecc6334096c63a39d714a0ca379dd7ab599c4312c93161ce17781").success(function(data) { $scope.token = "oi"; }); $http.get("http://api.olhovivo.sptrans.com.br/v0/linha/buscar?termosbusca=9").then(function(response) { $scope.token = response; }); // http://api.olhovivo.sptrans.com.br/v0/login/autenticar?token=fde20482b4aecc6334096c63a39d714a0ca379dd7ab599c4312c93161ce17781 }).config(['$httpprovider', function($httpprovider) { $httpprovider.defaults.usexdomain = true; $httpprovider.defaults.withcredentials = true; delete $httpprovider.defaults.headers.common["x-requested-with"]; $httpprovider.defaults.headers.common["accept"] ...

pattern based replace of string in angularjs -

i trying replace based on pattern , getting error. {{n.tostring().replace(/\b(?=(\d{3})+(?!\d))/g, ",")}} n number. error: [$parse:lexerr] lexer error: unexpected next character @ columns 36-36 [] in expression angular's having hard time regex being inline in template, put replace statement helper function on scope: $scope.convert = function(val) { return val.tostring().replace(/\b(?=(\d{3})+(?!\d))/g, ","); } then in template call function: {{ convert(n) }} another option create custom filter: app.filter('convert', function() { return function(input) { return input.tostring().replace(/\b(?=(\d{3})+(?!\d))/g, ","); }; }); then pipe value filter: {{ n | convert }}

Current year in Ruby on Rails -

how can current year in ruby on rails? i tried variety of things, including date.current.year time.now.year the problem return previous year in cases year changes after launching server (eg. after new year's). relevant code: model brewery.rb class brewery < activerecord: :base ... validates :year, numericality: { only_integer: true, less_than_or_equal_to: date.today.year } ... problem occurs when creating new brewery, assumed date.today.year evaluated whenever action takes place. in example date.today.year evaluated once, when class loaded , doesn't change anymore. when use lambda in validator declaration, re-evaluates block each time when validates attribute: validates :year, numericality: { only_integer: true, less_than_or_equal_to: ->(_brewery){ date.current.year } } furthermore suggest use date.current instead of date.today , because current pays attention time zone settings.

c# - Use Primary key or Guid as name of images -

i'm working on small cms friend written while ago. there page user can upload image , display in profile. wonder best way save image. in cms it's goes this: first entity being save database , after getting it's primary key, image being upload server image-{primarykey}.jpg hits database again update same entity full name of image. here part of code: in controller: [httppost] [validateantiforgerytoken] public async task<bool> add([bind(include = "idlanguage,title,address,description,idlinkscategory")]tbllinks tbllinks, string coverpath, string coverbase64) { try { tbllinks.iduser = await _permissionservice.getcurrentiduser(); tbllinks.createddatetime = datetime.now; await _linkservice.add(tbllinks); if (!string.isnullorempty(coverpath)) { byte[] filebyte = _utilityservice.getbytefrombase64string(coverbase64); var filetype = ...

c# - Check if usercontrol is within Window Bounds -

i have project requires ability drag user control (hosted within grid) around screen. works fine below code: void myusercontrol_manipulationdelta(object sender, manipulationdeltaroutedeventargs e) { var ct = (compositetransform) rendertransform ?? new compositetransform {centerx = 0.5, centery = 0.5}; ct.translatex += e.delta.translation.x; ct.translatey += e.delta.translation.y; } the issue user control can dragged way out of screen area. prevent this, tried example shown here: http://msdn.microsoft.com/en-us/library/system.windows.uielement.manipulationdelta.aspx unfortunately, uses containingrect.contains(shapebounds) whereas in windows 8, expected replace shapebounds(this rect) point. not sure on how work this. so question how can ensure user control or uielement cannot dragged out of window.current.bounds area in windows 8 store app? thanks. edit: more details on xaml structure: the mainpage contains grid horizontal , vertical alignment set ...

ruby on rails - Store a list of .rb files inside model -

colleagues! have document model. document should processed 1 of parsers (in project called 'importers' , stored inside 'lib/importers' folder). question best way implement entity importer inside models layer? (for instance associate document importer). first idea create importers table, have 2 independent places importer names saved (database , file system). bad cases: case 1: i've aded new importer, forgot add importers table = can't associate document impoter case 2: importer renamed , forgot rename inside database = error i decided define def document.importers @importers ||= dir.entries("#{rails.root}/lib/importers/") .select { |name| !file.directory?(name) && name != 'base_importer.rb'} .map { |name| name.gsub(/\.rb$/, '') } end for f.association inout , add importer string attribute document model. can importer class in following way -- 'importer.classify.constantize'. work...

css - Are font classes defined by client os or client browser? -

i have noticed @ google fonts never use fantasy fallback class in font-family. script , typical fantasy fonts, use cursive. i wonder if hint chrome not support fantasy fallback class? case, fallback font-classes have handled browser via implemented lists typical serif, sans-serif etc. fonts. alternatively, browser query os such lists? what happens when browser needs fallback serif font on clients system? how info on installed serif fonts? i haven't been able find aswer this, hope here might know it. know web safe fonts , become things of past, still have relevance. typefaces don't map generic font families mechanically. they're categorized way in family names , on font listings such google fonts , adobe typekit. you create font stack consists of sans-serif family, serif family, , ends fantasy keyword: font-family: helvetica, 'times new roman', fantasy; and browsers treat same: use whichever family comes first supported, or fall generic fam...

Problems with a makefile and mixed Fortran and Fortran 90 code -

i trying update old fortran code , want use makefile build it. right now, makefile looks like fc = gfortran fflags = -o2 hdrs = global.h param.h coor.h srcs = xxx.f yyy.f zzz.f newstuff.f90 main.f objs = $(srcs:.f=.o) objs := $(objs:.f90=.o) runit: $(objs) $(fc) $(fflags) -o $@ $^ xxx.o yyy.o main.o : global.h yyy.o zzz.o: coor.h xxx.o yyy.o zzz.o main.o : param.h xxx.o main.o : newstuff.o clean: rm runit *.o *.mod .suffixes: .f .f90 .o .f.o: $(fc) $(fflags) -c $< .f90.o: $(fc) $(fflags) -c $< i have 2 questions. first, edit newstuff.f90 , issue make newstuff.o , expecting new newstuff.o . instead, message newstuff.o date. doesn't happen of other source codes. have convince make newstuff.o indeed out of date? second, trying hack fix, inserted line (not shown above): newstuff.o : newstuff.f90 . line in makefile, make returns m2c -o mpi_wrapper.o mpi_wrapper.mod make: m2c: no such file or directory why make go other u...

keyboard shortcuts - How do I make Visual Studio Replace default to Current Selection? -

in visual studio 2015 i'm having problems ctrl+h shortcut. in past if had text selected , pressed key combo, replace box defaults 'selection'. it's defaulting 'current document'. if change 'selection' not retain setting next time ctrl+h i'm not sure if i've accidentally changed setting, or if it's been since installed 2015 version you can go tools > options in treeview, expand environment node, , choose find , replace , check box automatically limit search selection

ios - Recording video using AVFoundation Swift -

i created avcapturesession , manipulate each frame (morphing) users face,adding layers etc. how can turn frames video can saved camera roll? here's how set avcapturesession func setupcapture() { let session : avcapturesession = avcapturesession() session.sessionpreset = avcapturesessionpreset640x480 let device : avcapturedevice = avcapturedevice.defaultdevicewithmediatype(avmediatypevideo) let deviceinput : avcapturedeviceinput = try! avcapturedeviceinput(device: device) if session.canaddinput(deviceinput) { session.addinput(deviceinput) } stillimageoutput = avcapturestillimageoutput() videodataoutput = avcapturevideodataoutput() let rgboutputsettings = [kcvpixelbufferpixelformattypekey string: nsnumber(unsignedint: kcmpixelformat_32bgra)] videodataoutput.videosettings = rgboutputsettings videodataoutput.alwaysdiscardslatevideoframes = true videodataoutputqueue = dispatch_queue_create("videodataoutputq...

sql - PostgreSQL - How to identify three roles of users in database? -

i'm building database schema needs 3 kind of user roles: normal user, admin , super admin. first approach make 2 tables, 1 normal user , 1 both admin , super admin inherits users table. table definitions this: create table users ( id bigserial not null primary key, email text not null unique, password text not null, name text not null, gender char not null, created_at timestamp not null default current_timestamp ); create table admins ( phone bigint not null, doc bigint not null, super_admin boolean not null, id bigint not null primary key references users(id) ); but i'm not sure how select user or admin when needed. i'm thinking if better leave 1 "users" table , define new table "roles" users matched, in order select them column "role" specifies if user normal, admin or super admin. first, shouldn't storing telephone numbers integers. should using strings. there exist valid phone numbers in world can ...

powershell - How can I implement Get-Credential with a timeout -

in of scripts have fall-back approach getting pscredential object via get-credential cmdlet. useful when running scripts interactively, esp. during testing etc. if & when run these scripts via task scheduler, i'd ensure don't stuck waiting interactive input , fail if don't have necessary credentials. note should never happen if task set run under correct application account. does know of approach allow me prompt input with timeout (and presumably null credential object) script doesn't stuck? happy consider more general case read-host instead of get-credential . i use similar in of scripts based around timeout on read-host, code here : function read-hosttimeout { # description: mimics built-in "read-host" cmdlet adds expiration timer # receiving input. not support -assecurestring # set parameters. keeping prompt mandatory # original param( [parameter(mandatory=$true,position=1)] [string]$prompt, [parameter(mandator...

types - Why must dynamically typed languages store variable names as strings? -

i've read dynamically typed language slower because store variable names string, can't use else? i'm asking question follow of question: why dynamically typed languages slow? aren't there other methods access variable using name hash lookup ? wouldn't opportunity use template programming technique ? there several reasons, next couple. suppose, there code receives variable x , accesses field foo on it, , 1 time variable attached object of type bar , other time attached object of type baz , both have other fields , there no relationship between two. access x.foo valid in both cases, because classes unrelated, it's difficult map identifier foo integer can later used access desired field: location , type may unpredictable. add reality, imagine other classes may come , go in system, , may have field foo . another scenario has nothing object-oriented approaches , learned @ time when lisp , similar languages invented. allow compute not staticall...

textmate - Regex to Find a Word Inside Curly Braces -

i need way search text using regex , find word thats inside latex command (which means it's inside curly braces) here example: tarzan name , knows {tarzan loves jane} now if search regex: ({[^{}]*?)(tarzan)([^}]*}) , replace $1t~a~r~z~a~n$3 this replace word tarzan inside curly braces , ignore other instance! far came. now need same following example: tarzan name , knows {tarzan loves jane} doesn't know because written \grk{tarzan loves jane} in example need last mention of "tarzan" replaced (the 1 within \grk{}) can me modify above regex search that? you can try use pattern: (?:\g(?!\a)|\\grk{)[^}]*?\ktarzan demo details: (?: \g(?!\a) # contiguous previous match | # or \\grk{ # first match ) [^}]*? # not } (non-greedy) until ... \k # reset start of match @ position tarzan # ... target word note: \g matches position after previous match, matches start of string too. that's ad...

python - How do i return to the beginning of my code/have a nested loop? -

i want code run if condition not met (in if loop) return beginning of code, asking user input sentence. how add nested loop (if it's called)? sentence = input("please input sentence: ") word = input("please input word: ") sentence = sentence.lower() word = word.lower() wordlist = sentence.split(' ') print ("your word, {0}, in positions:".format (word)) position,w in enumerate(wordlist): if w == word: print("{0}".format(position+1)) you can put while loop around code , break or continue depending on input: while true: sentence = input("please input sentence: ") if bad(sentence): # replace actual condition continue ... position, w in enumerate(wordlist): ... break

node.js - Use of git tags in package.json (for git dependencies) -

is possible how update behaviour git dependencies npm packages? so have git dependency: "dependencies": { "my-module": "github:me/my-module" } and want updated each time npm install , adding revision hash solution requires more work track , updatei in package.json each time package update on github. there git tags (which can set using npm version.. command - created commit tag v1.2.3 . thought maybe thiere way use tags in dependants package.json? hope clear. git tag on repoe gives me v1.0.1 v1.0.0 .. if try add in package.json after module name version like: #1.0.0 or #v1.0.1 ``` "dependencies": { "my-module": "github:me/my-module#1.0.1" } ``` install fails error: command failed: git -c core.longpaths=true rev-list -n1 1.0.0 fatal: ambiguous argument '1.0.0': unknown revision or path not in ree. use '--' separate paths revisions, this: 'git <command> [<revision>...] --...

android : Opening a file from the list of files listed in a listview -

i working on project displays list of files directory in sd card. files have displayed .xls files. have xls reader in mobile phone , want open file clicked in listview. here code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,windowmanager.layoutparams.flag_fullscreen); setrequestedorientation(activityinfo.screen_orientation_sensor_landscape); setcontentview(r.layout.activity_subjects_list); final animation myanim = animationutils.loadanimation(this, r.anim.abc_grow_fade_in_from_bottom); typeface tf = typeface.createfromasset(getassets(), "fonts/myfont.ttf"); subjectslistview = (listview) findviewbyid(r.id.subjectslistview); addsubjectbutton = (imagebutton) findviewbyid(r.id.subjectslistfabutton); adapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1, filelist); ...

jquery - Removing the :focus state from a link after modal window closes -

i want remove :focus state links open modal window once modal closed. currently, , seems normal bootstrap behavior link maintains focus until user clicks elsewhere on page. i've tried; $('.modal').on('hidden.bs.modal', function () { $('a').unbind('click', '.main-body'); }) doesn't seem want. tried throwing in alert message, , while alert open focus go away returns alert closes. ideas or appreciated. <div class="container"> <div class="row"> <p><a href="#" data-toggle="modal" data-target="#mymodal" class="main-body">click enlarge</a></p> </div> </div> <!-- modal --> <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel"> <div class="modal-dialog" role="document"> <div class=...

python - How to update parent table timestamp when child table is modified? -

how can update parent timestamp when child table modified? i use parent table timestamp checking if rest client should update it's local version of these tables. class parent(db.model): id = db.column(db.integer, primary_key=true) version = db.column(db.integer) timestamp = db.column(db.datetime, default=datetime.utcnow, onupdate=datetime.utcnow) childs = db.relationship('children', backref='parent', lazy='dynamic', cascade="all, delete-orphan") class children(db.model): id = db.column(db.integer, primary_key=true) version = db.column(db.integer) timestamp = db.column(db.datetime, default=datetime.utcnow, onupdate=datetime.utcnow) parent_id = db.column(db.integer, db.foreignkey('parent.id'), nullable=false) and...

c# - Generic error occurred in GDI+ while setting wallpaper twice -

i have code should set wallpaper byte[] data = webclient.downloaddata("http://imageurl"); image yourimage = null; using (memorystream mem = new memorystream(data)) { yourimage = null; yourimage = image.fromstream(mem); yourimage.save("image.jpg", imageformat.jpeg); wallpaper.set(new uri("image.jpg", urikind.relative), wallpaper.style.stretched); yourimage.dispose(); } whenever run twice, stops @ yourimage.save("image.jpg", imageformat.jpeg); saying was system.runtime.interopservices.externalexception unhandled hresult=-2147467259 message=allgemeiner fehler in gdi+. source=system.drawing errorcode=-2147467259 stacktrace: bei system.drawing.image.save(string filename, imagecodecinfo encoder, encoderparameters encoderparams) bei system.drawing.image.save(string filename, imageformat format) bei streetviewhintergrundbild.form1.button1_click(object sender, eventargs e) in d:\form1.cs:zeile ...

linux - Python- Check terminal shell if changed from the environmental shell -

when terminal opened, environmental shell set. if type "csh" starts running c shell program within bash terminal. question is, python script, how can check determine if csh has been executed prior starting python script. thanks you can check shell environment using import os shell = os.environ['shell'] then can make sure shell set /bin/csh

php - mysql multiple keyword search in any order -

this question exact duplicate of: php keyword search engine no results [duplicate] i have simple mysql database keyword search functional. results search not being returned if keywords not in same order entered in database. example searching "dog cat lion" return result, searching "dog lion cat" return no results. on how fix issue appreciated. here code. <!doctype html> <html> <head> <meta charset="utf-8"> <title>part search</title> </head> <body> <?php $username = "xxxx"; $password = "xxxx"; $hostname = "localhost"; //connection database mysql_connect($hostname, $username, $password); mysql_select_db("wesco"); $search = mysql_real_escape_string(trim($_post['searchterm'])); $find_parts = mysql_query("select * `parts` `keywords` '%$search%'"); while($row = mysql_fetch_as...

Wordpress Woocommerce Loop -

hello developing ecommerce , tried loops , not make work properly, should image below , if can me grateful . btw: i'm using wordpress , woocommerce plugin in latest version i stay way: http://i.imgur.com/nuvwh5w.jpg?1 now picture below: http://i.imgur.com/awcdk99.png

sql server - T-SQL: Turn off certain Intellisense suggestions -

using microsoft ssms 2008 (t-sql) edit: clarify, not trying disable intellisense completely. trying remove suggestions provides. is there way remove suggestions intellisense? for example, whenever type 'or', intellisense suggests 'origfinancelab' , accidentally accept hitting [spacebar] , have go , delete 'origfinancelab', type in 'or', , cancel intellisense suggestion. it's annoying. this not word happens with, 1 example. i've looked @ tools --> options --> text editor --> transact-sql, don't see way remove specific intellisense suggestions. there no way selectively turn off individual suggestions in ssms intellisense.you should post suggestion ssms feedback site . you can try out sql assistant in mean-time though. it's free ssms add-in provides excellent intellisense suggestions.

html - positioning a nav bar so it's fixed -

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en""http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link href="main.css" rel="stylesheet"/> <title>vasilios lambos</title> </head> <body> <div class="header"> <a class="logo" href="home.html"><img src="vl-logo.png"></a> </div> <nav role="navigation"> <div class="nav"> <a href="home.html">home</a></li> <a href="portfolio.html">portfolio</a></li> <a href="process.html">process</a></li> <a href="#">contact</a></li> </div> </nav>...

How do I getInt from a ByteBuffer with only 1 remaining byte (Java NIO) -

i new java nio , unsure how things nio-ishly. assume have read data socket bytebuffer , consumed bytes one, using methods of bytebuffer . know next thing 4 bytes integer in binary format, want use getint() , first byte of int in buffer. the natural thing me fill buffer more bytes connection , continue. if understand correctly, achieve with buf.compact(); buf.position(buf.limit()); buf.limit(buf.capacity()); and read more bytes. since there no method behavior, there flip() method, wonder if thinking wrong. there better ways this? this situation naturally occur e.g. if connection delivers stream of length + data messages. buf.compact(); // wrong: buf.position(buf.limit()); // no need to: buf.limit(buf.capacity()); please not change position. position after compact() pointing first byte after un-getted part of buffer - want it. setting limit capacity redundant: compact() you.

github - git checkout olderversion but now checking what version is being used -

i have file, lets say, test.txt. lets empty file , committed it, first commit empty file. lets sha 2d37f7 now lets edited file , added text "hello world" in file , committed file. have hash hello world version , lets that hash eec1598 now when git log, see this eec1598 (my last commit on top) 2d37f7 (my first empty file) now lets want go first file, this git checkout 2d37f7 test.txt when check file, empty , good. when git log test.txt it shows me same thing above eec1598 (my last commit on top) 2d37f7 (my first empty file) at point don't know version of test.txt current version. how find out? thanks note shas shown in git log commits, not file. asking how determine commit current working copy of test.txt came from. unfortunately, information not stored anywhere. in cases, there no single commit can file came from, file have same contents in multiple commits. so in summary, after git checkout <sha> <filename> , git consid...

php - short_open_tag setting ignored by PHPUnit -

my phpunit tests keep failing when trying tests .php files in (legacy code) application begin short open tag ( <? instead of <?php ). but in php.ini file, short_open_tag set on . the application runs fine. why phpunit getting upset on short open tag? i've looked other php.ini files, , find 1 @ /etc/php.ini . .htaccess file doesn't affect setting either. else causing this? general solution 1) check php.ini file loaded (command line: php --ini ) 2a) set in php ini file: short_open_tag = on 2b) set in .htaccess file: php_value short_open_tag 1 3) restart server (command line: service httpd restart )

How can I display all the environment variables on an HTML page using Rails? -

i have bunch of environment variables set on windows machine display on html page. able display 1 not sure how loop , display of them key-value pairs. please guide. rails version: 4.2 environment variables: my_encoding_scheme: utf8 db_conn_pool: 10 db_user_name: guest db_pwd: secret index.html.erb <div class="table-container"> <table class="table"> <thead> <tr> <th colspan="2">environment variables</th> </tr> </thead> <tbody> <tr><td><%= env["my_encoding_scheme"] %></td></tr> </tbody> </table> you loop through environment variables this <table> <thead><tr><td>variable</td><td>value</td></tr></thead> <tbody> <% env.each |k,v| %> <tr><td><%= k %></td><td><%= v %></td...

How to bind data correctly to a ListBox so it would update [C#/WPF/MVVM] -

i'm stuck trouble updating bound data in wpf. basically, i've got data in app, doesn't update when properties change , can't fix it. in app i'm trying use mvvm pattern, there model properties x, y: public class Сross : inotifypropertychanged { private double x; private double y; public double x { { return x; } set { x = value; raisepropertychanged("x"); } } public double y { { return y; } set { y = value; raisepropertychanged("y"); } } public event propertychangedeventhandler propertychanged; protected virtual void raisepropertychanged(string propertyname) { if (propertychanged != null) { propertychanged(this, new propertychangedeventargs(propertyname)); } } } ...there viewmodel, contains observablecollection of crosses: public class main...

c# - How to specify a DataContext whet adding the ContextMenu to the DataGridTemplateColumn? -

i cooking datagridtemplatecolumns programmatically via datatemplate dtstringtemplate = (datatemplate)xamlreader.load(sr, pc); datagridtemplatecolumn.celltemplate = dtstringtemplate; i tried adding contextmenu datagrid, editable cells used own context menu. so far, post has gotten me far getting textbox context menu appear expected: how add contextmenu in wpf datagridcolumn in mvvm? using post mentioned above guide, have created style , contextmenu in app.xaml; when right-click on cell in datagrid, context menu appears. however, can't associated command fire, , suspect binding not right. here's xaml in app.xaml: <contextmenu x:key="datagridcontextmenu"> <menuitem header="menuitem one" command="{binding relativesource={relativesource findancestor, ancestortype={x:type datagrid}}, path=datacontext.cmdmenuitemone}" /> <menuitem header="menuitem two" command="{binding relativesource={rel...