Tuesday, 15 May 2012

python - How to clear empty keys in a dictionary with subdictionaries -



python - How to clear empty keys in a dictionary with subdictionaries -

i have next regex in python:

(\"[^"]+":\s)({}|\[\]|null)(,?\s?)

i need match occurrences of "some key": [] or {} or null string, need exclude cases "some key" "note", case string is:

test= {'merda 1': {}, 'merda 2': [1,2,3], 1: """"só pra fude""", 'note': "foda-se", 'não reclama': [], 'tédio da nisso': ordereddict({'note': none, 1:2}), 'none':none, 'quero $$$': (), 'note': [], 12.2: none, 666: ordereddict(), 'fudeu': ordereddict({1:none, 2:1, 3:2}) } string_json = json.dumps(test)

the intention filter empty leafs of dictionary, need maintain ordereddicts nowadays in it.

solution: based in martin answer:

def clean_dict(dictobj): """ clean number of empty leafs of dictionary """ def del_empty_value(dictobj): """ delete empty values recursively """ key, value in dictobj.items(): if not (value or key == 'note'): del dictobj[key] elif isinstance(value, dict): del_empty_value(value) json import dumps initial_hash = len(dumps(dictobj)) while true: del_empty_value(dictobj) new_hash = len(dumps(dictobj)) if new_hash == initial_hash: break initial_hash = new_hash

why don't allow json parser hard work you?

import json s = '{"1": "\\"s\\u00f3 pra fude", "none": null, "note": [], "n\\u00e3o reclama": [], "12.2": null, "666": {}, "merda 2": [1, 2, 3], "merda 1": {}, "t\\u00e9dio da nisso": {"note": null}, "fudeu": {"1": null, "2": 1, "3": 2}, "quero $$$": []}' d = json.loads(s) result = dict((k, v) k, v in d.iteritems() if not v or k == "note")

the lastly line filters out key:value pairing bool(v) not false ([], {} , none satisfy criteria) or key value not "note".

result:

{u'12.2': none, u'666': {}, u'none': none, u'note': [], u'n\xe3o reclama': [], u'quero $$$': [], u'merda 1': {}}

edit:

since question been updated, there's improve answer:

test= {'merda 1': {}, 'merda 2': [1,2,3], 1: """"só pra fude""", 'note': "foda-se", 'não reclama': [], 'tédio da nisso': ordereddict({'note': none, 1:2}), 'none':none, 'quero $$$': (), 'note': [], 12.2: none, 666: ordereddict(), 'fudeu': ordereddict({1:none, 2:1, 3:2}) } def delete_empty_value(test): k, v in test.items(): if not (v or type(k) ordereddict or k == 'note'): del test[k] elif isinstance(v, dict): delete_empty_value(v)

this new filter keeps key:value pair where:

the value not [], {} or none the value instance of ordereddict the key == "note"

python regex string escaping substring

php - Automatically discover composer packages -



php - Automatically discover composer packages -

i'm wondering best way (if there way) application auto-discover [relevant] php "packages" installed composer.

my utilize case specific scenario:

i have php app includes "framework" (for lack of improve word). framework brings basic functionality (routing, admin etc).

i'm building in more advanced functionality, say, blog module. module exclusively self contained in it's own directory (but has dependencies on framework).

i'd blog module self contained composer package, can selectively require bundle in app's root composer.json file.

now, need framework know it's there can, example, set routing correctly , load admin functionality module requires.

what i've thought far:

i'm relatively experienced in php, "proper" oop , autoloading little bit beyond knowledge @ moment, please forgive if there inbuilt functions this. don't know terms google!

i have thought maybe read installed.json file composer puts @ vendor/composer/installed.php i'm not sure how set packages (e.g. blog) announce are. i'd future proof i'm not looking known module names (or regexing vendor or bundle names), rather looking packages "hey framework, know you! can utilize me!"

maybe can somehow instruct composer (through package's composer.json file) stick in arbitrary key/value pair in installed.json?

any suggestions welcome, or directions sort of googling should doing.

oh welcome world of managing dependencies on framework.

i have experience auraphp, dealt similar issue. can read blog post composer-assisted two-stage configuration .

so ended-up adding https://github.com/auraphp/aura.web/blob/a3870d1a16ecd3ab6c4807165ac5196384da62cd/composer.json#l26-l36 these lines in packages need understand load framework.

you can see how bundle can autoloaded configurations.

in composer.json

https://github.com/harikt/aura.asset_bundle/blob/6ea787979390e69bf6ecb1e33ce00ed90f306e2f/composer.json#l21-l27

and config/common.php ( https://github.com/harikt/aura.asset_bundle/blob/223126cedb460e486c4f0b242719c96c14be5385/config/common.php ) , note have other development modes also. detailed check https://github.com/auraphp/aura.web_project or https://github.com/auraphp/aura.framework_project

hope helps bit code , work on own solution.

php json composer-php

rest - how to customize grails restful controller error response -



rest - how to customize grails restful controller error response -

how customize grails restfulcontroller error response? illustration 1 of restful controller returning next response default on error while trying save object.

{ "errors": [ { "object": "com.test.task", "field": "description", "rejected-value": null, "message": "property [description] of class [class com.test.task] cannot null" } ] }

i customize response bellow.

{ "errors" : { "message": "property [description] of class [class com.test.task] cannot be" }, { "message": "this going 2nd message" }, ..... }

use internationalization feature described here. add together next resource bundle messages.properties.

task.description.nullable = message

or

com.test.task.description.nullable = message

rest grails grails-controller

schema.org - blog posting schema any suggestion? -



schema.org - blog posting schema any suggestion? -

is ok blogposting schema.org... think there errors?... suggestions... thanks

<div id="blog_post" itemscope="" itemtype="http://schema.org/blogposting"> <div style="float: left;"> <a href="image link here"> <img itemprop="image" src="image source link here" width="150px" alt="image description here"/></a></div> <div style="font-size: 10pt; font-weight: bold; margin-bottom: 10px;" itemprop="name"> <a href="item link here" itemprop="url">item title here</a></div> <div id="description" style="font-family: arial, helvetica, sans-serif;margin-bottom: 10px;"> <span style="font-size: 11pt; font-weight: bold;" itemprop="description">item description here</span></div></div>

removing not related microdata, have:

class="lang-html prettyprint-override"><div itemscope itemtype="http://schema.org/blogposting"> <img itemprop="image" src="…" /> <div itemprop="name"> <a href="…" itemprop="url">…</a> </div> <span itemprop="description">…</span> </div>

that fine microdata , schema.org perspectives.

blogs schema.org posting

dependency injection - Spring AOP: passing parameters for logging -



dependency injection - Spring AOP: passing parameters for logging -

we using org.springframework.beans.factory.beanfactoryaware run chain of commands. services of scheme utilize 1 service audit logging. audit logging service needs unique identifier set in our implementation of beanfactoryaware.

right unique identifier beingness passed downwards in each , every function call. 1 alternative have type of context object pass around. preferiable not because create services less useable other parts of scheme doesn't know beanfactoryaware system.

is there aop way of implementing cleaner solution? 1 audit logging can unique identifier without code between beanfactoryaware , audit code knowing value?

per request, here code:

public class chainrunner implements beanfactoryaware { public int runchain(string chainname, object initparameters, int msglinkid) throws exception { ourcontext ctx = createcontext(initparameters); ctx.setmsglinkid(msglinkid); createchain(chainname).execute(ctx); homecoming retval; } } public class aserviceimpl implements aservice { private loggingservice logger; public loggingservice getlogger() { homecoming logger; } public void setlogger(loggingservice logger) { this.logger = logger; } public void amethod(object params, int msglinkid) { // lots of code snipped logger().saveactiona( msglinkid, otherparams); } } public interface loggingservice { public void saveactiona(int msglinkid, object otherparams); }

chainrunner adds msglinkid chain's context. each message pull the msglinkid out of context , pass integer parameter downwards service, such aserver.amethod. service needs log activity on loggerservice, passing parameters beingness logged, first parameter msglinkid.

as stands now, services wired via xml configuration:

<bean id="loggerservice" class="com.nowhere.loggingserviceimpl"/> <bean id="aservice" class="com.nowhere.aserviceimpl"> <property name="logger" ref="loggerservice" /> </bean>

so question is: possible utilize aop msglinkid jump downwards loggingservice without having pass through many layers of services?

spring dependency-injection aop aspectj aspect

Add a text in a string PHP -



Add a text in a string PHP -

i have text.

$text='userpics/115/x3wgoc0009ja.jpg';

i want add together letter p before x3wgoc0009ja.jpg, output

$text='userpics/115/px3wgoc0009ja.jpg'; ---^

i new php, don't know try, hoping guide me in right direction

you can explode slash 1 way.

$exploded_text = explode('/', $text); $new_text = $exploded_text[0] . $exploded_text[1] . 'p' . $exploded_text[2];

it's not best way, work.

php string

apache - Incapsula - How do I allow socket connection/requests from a specific IP? -



apache - Incapsula - How do I allow socket connection/requests from a specific IP? -

i not familiar incapsula working in project needs send socket messages using simple socket php scripts on both ends (scripts work in localhost):

-client: outside incapsula sends messages server

-server: apache within incapsula (under incapsula protection) receives messages client (a single client)

supposing ip client is: 198.168.123.123, how should proceed allow connections ip if server had no incapsula protection ip?

or impossible?

thank you.

it's recommended restrict server access incapsula ips: https://incapsula.zendesk.com/hc/en-us/articles/200627570-restricting-direct-access-to-your-website-incapsula-s-ip-addresses-

you can restrict client's source ip within incapsula business relationship easily: www.incapsula.com/demo/settings_3.html

if want restrict in code, can utilize x-forwarded-for and/or incap-client-ip headers: https://incapsula.zendesk.com/hc/en-us/articles/200627650-the-ips-in-my-weblogs-have-changed

hth, ofer

apache incapsula

java - Merging two databases in Android -



java - Merging two databases in Android -

in app have implemented options backup , restore database sdcard. when restore database, must have saved info included backed data. how create possible?

this how restoring database.

restore:

seek { file sd = environment.getexternalstoragedirectory(); file info = environment.getdatadirectory(); if (sd.canwrite()) { string currentdbpath= "//data//" + "packagename" + "//databases//" + "databasename"; string backupdbpath = "/backupfolder/databasename"; file backupdb= new file(data, currentdbpath); file currentdb = new file(sd, backupdbpath); filechannel src = new fileinputstream(currentdb).getchannel(); filechannel dest = new fileoutputstream(backupdb).getchannel(); dst.transferfrom(src, 0, src.size()); src.close(); dst.close(); toast.maketext(getbasecontext(), backupdb.tostring(), toast.length_long).show(); } } grab (exception e) { toast.maketext(getbasecontext(), e.tostring(), toast.length_long) .show(); }

try attach backed current db in way:

sqlite> attach database 'testdb1.db' 'db1'; sqlite> attach database 'testdb2.db' 'db2'; sqlite> attach database 'testdb3.db' 'db3';

sqlite - attach database

java android database import restore

Javascript chunked file upload to PHP Server -



Javascript chunked file upload to PHP Server -

so have function in javascript send parts of file server:

function ajaxpartupload(url, packageno, file, attachmentid) { var packagemaxsize = 10240; //1048576; //10485760; //reduced tests var packagecount = math.ceil(file.size / packagemaxsize); var start = packageno * packagemaxsize; var stop = (packageno+1) * packagemaxsize - 1; if ((packageno+1) === packagecount || packagecount === 0) { stop = file.size - 1; } var blob = file.slice(start, stop); var reader = new filereader(); reader.onloadend = function (evt) { if (evt.target.readystate === filereader.done) { var info = { blob: reader.result, partno: packageno, lastpartno: packagecount, filename: file.name, filetype: file.type, filesize: file.size, attachmentid: attachmentid, multipart: true }; $.ajax({ url: url, type: 'post', datatype: 'json', data: data, success: function(response) { if (response.continue === false) { homecoming true; } else { ajaxpartupload(url, packageno+1, file, response.attachmentid); } } }); } }; reader.readasbinarystring(blob); }

and it's working expected, in post binary info of files i'm sending. under specified url have script basicly this:

$attachment = v()->attachment->find($_post['attachmentid']); $destination_path = $attachment->getpath(); $filepointer = fopen($destination_path, 'a'); $written = fwrite($filepointer, $_post['blob']); if ($written == false ) { throw new exception('file info not written'); } fclose($filepointer);

and long have text files it's ok, when seek send binary file, files i'm reciving 50% bigger in size, , corrupted, doesn't matter if create chunk size big plenty hold file in 1 http request or not. i'm doing wrong?

i have dumped length of 'blob' in javascript right before send , length of recived blob in php: i've got 2 compleatly diffrent results 1 chunk max 1 mb file has '28kb' (got ls -lash):

javascript: 25755

php: 36495

what happend? when i've tired text file ok.

@edit: solution in js change:

blob: reader.result,

to

blob: window.btoa(reader.result),

and in php

$written = fwrite($filepointer, $_post['blob']);

to

$written = fwrite($filepointer, base64_decode($_post['blob']));

that solves problem.

i've added atob in javascript on result reader, , decoded info before reading base64_decode. solves problem.

the problem php interprets binary info in other way, string perhaps, don't know. anyway sending 'bit' bigger encoded info saves lot of nerves.

javascript php ajax file-upload fileapi

iphone - Saving parse objects locally on iOS device -



iphone - Saving parse objects locally on iOS device -

what proper way save parse objects locally? placed them in nsmutabledictionary , tried saving them nsuserdefaults failed error, "attempt set non-property-list object nsuserdefaults value".

i want upload object parse , save locally too. kind of caching it. know parse offers query caching need cache when uploading too, not when querying.

if makes difference, items within pfobject strings , piffles (images).

i appreciate if point me in right direction.

parse has added feature on 9th dec ios http://blog.parse.com/2014/12/09/parse-local-datastore-for-ios/

ios iphone objective-c xcode5 parse.com

jquery - how to integrate Bootstrap Markdown in asp.net usin c#.net? -



jquery - how to integrate Bootstrap Markdown in asp.net usin c#.net? -

how can integrate bootstrap markdown in asp.net ?

can guide me resolve solution

bootstrap link

jquery

ios - Launch image not appearing on iPhone -



ios - Launch image not appearing on iPhone -

i'm programming app iphone , launch images i've selected not appearing when specify 'ios-7 , later option' in xcode asset catalog editor.

when uncheck ios-7 , later box , utilize 'ios-6 , prior' alternative images load fine.

normally go this, warning xcode 'ios-7 images required' i'm worried app may rejected because of this.

any suggestions around problem?

thanks!

hi need set image name , size iphone , ipad attach image

ios iphone xcode

html - Create buttons with radius -



html - Create buttons with radius -

i want create on picture, don't have thought how create button in html [bootstrap] bottom-border radious?

here sample if want create

is possible create buttons or in css. here try..

<div class="col-md-12"> <a class=" col-md-6 btn btn-success btn-large btn1" href="#" style="color: rgb(255, 255, 255); background-image: -moz-linear-gradient(center top , rgb(98, 196, 98), rgb(81, 163, 81)); background-color: rgb(81, 163, 81);">success</a> <a class=" col-md-6 btn btn-success btn-large btn2" href="#" style="color: rgb(255, 255, 255); background-image: -moz-linear-gradient(center top , rgb(98, 196, 98), rgb(81, 163, 81)); background-color: rgb(81, 163, 81);">success</a> <div class="circle"> <img class=" logo img-responsive" src="images/biz_club.jpg"/></div> </div> <a class=" col-md-6 btn btn-success btn-large btn3" href="#" style="color: rgb(255, 255, 255); background-image: -moz-linear-gradient(center top , rgb(98, 196, 98), rgb(81, 163, 81)); background-color: rgb(81, 163, 81);">success</a> <a class=" col-md-6 btn btn-success btn-large btn4" href="#" style="color: rgb(255, 255, 255); background-image: -moz-linear-gradient(center top , rgb(98, 196, 98), rgb(81, 163, 81)); background-color: rgb(81, 163, 81);">success</a> </div>

this ok, need border-bottom of button bend.

you utilize : border-radius, overflow, position , transform. demo

html

<div> <a href><span>success</span></a> <a href><span>success</span></a> <a href><span>success</span></a> <a href><span>success</span></a> <img src="http://dummyimage.com/140x140/059/000&text=text"/> </div>

css

div { width:200px; margin:1em auto; position:relative; } { float:left; height:100px; width:100px; background:gray; text-align:center; } span { display:inline-block; transform:rotate(-45deg); line-height:70px; color:white; } a+a span {/* or utilize a:nth-child(2) span or ~ span */ transform:rotate(45deg); } a+a+a span { transform:rotate(-135deg); line-height:125px; } a+a+a+a span { transform:rotate(135deg); line-height:125px; } a+a {/* or utilize a:nth-child(2) or ~ */ background:lime; } a+a+a { background:purple; } a+a+a+a { background:tomato; } img { position:absolute; top:30px; left:30px; } div, img { border-radius:100%; overflow:hidden; box-shadow:0 0 5px; }

html css twitter-bootstrap

java - Deleting elements from multi Dimensional Array -



java - Deleting elements from multi Dimensional Array -

i have 2-dimensional array in java.

for example,

double count=0; double[][] arr1 =new double[3][3]; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { arr1[i][j]=count; count++; } }

now, want remove elements or j value 1.

arr1[1][0], arr1[1][1], arr1[1][2], arr[0][1], arr[2][1] ...

how can accomplish this?

copies arr2. if had

[1][2][3] [4][5][6] [7][8][9]

you'd get

[1][3] [7][9]

if wanted

[1][-][3] [-][-][-] [7][-][9]

see shijima's answer

double[][] arr2 = new double[arr1.length][arr1[0].length]; int ti = 0, tj = 0; for(int i=0; i<arr1.length - 1; i++) { if (i > 0) ti = i+1; else ti = i; for(int j=0; j<arr1[0].length - 1; j++) { if (j > 0) tj = j+1; else tj = j; arr2[i][j] = arr1[ti][tj]; } }

java

Why should I use the DIM statement in VBA or Excel? -



Why should I use the DIM statement in VBA or Excel? -

so there question on what dim is, can't find why want utilize it.

as far can tell, see no difference between these 3 sets of code:

'example 1 myval = 2 'example 2 dim myval integer myval = 2 'example 3 dim myval = 2

if omit dim code still runs, , after 2 or 3 nested loops see no difference in output when omitted. having come python, maintain code clean*.

so why should need declare variables dim? apart stylistic concerns, there technical reason utilize dim?

* i'm lazy , out of habit of declaring variables.

any variable used without declaration of type variant. while variants can useful in circumstances, should avoided when not required, because they:

are slower use more memory are more error prone, either through miss spelling or through assigning value of wrong info type

excel vba excel-vba

java - Why subclasses does not override the value of their superclass variable? -



java - Why subclasses does not override the value of their superclass variable? -

i have 3 classes following, class b , c extending class a. wondering why code not reading value of b , c variables.

public class a{ protected int myvalue = 1; } public class b extends a{ private int myvalue = 2; } public class c extends a{ private int myvalue = 3; }

body of main method

arraylist<a> mylist= new arraylist(); mylist.add(new b()); mylist.add(new c()); for(int =0;i<mylist.size();i++) system.err.println("value is:" + mylist.get(i).myvalue);

output

1 1

from oracle website:

within class, field has same name field in superclass hides superclass's field, if types different. within subclass, field in superclass cannot referenced simple name. instead, field must accessed through super, covered in next section. speaking, don't recommend hiding fields makes code hard read.

you shadowing field myvalue , not overriding it, believe want

public class a{ protected int myvalue = 1; } public class b extends a{ public b() { myvalue = 2; } } public class c extends a{ public c() { myvalue = 3; } }

also, please don't utilize raw types

// arraylist<a> mylist = new arraylist(); arraylist<a> mylist = new arraylist<>(); // <a> on java 5 , 6

java

javascript - JQuery .html can not adding variable value into a href -



javascript - JQuery .html can not adding variable value into a href -

i want create list of news on webpage. when mouse click on content, there url available. illustration apple news

here sample codes, problem is: when seek add together variable's value href, href="www.search.com?keyword="+var.keyword, display apple news

actually there 50 objects in variable model, having 50 model.link , model.keywords, please help me alter sample code works on w3cshools.com "try youself". tried 10 times don't know how prepare it, thanks!

<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> <!-- should end tag--> var model=[{"link":"http://www.google.com?keyword=","keyword":"apple" "content":"this news"}] <!-- miss ";" @ end of line --> </script> <script> $(document).ready(function(){ $("p").html("click <a href=model.link+model.keyword>this link</a>"); <!--finally works: $("p").html("click <a href='"+model[0].link+model[0].keyword+"'>this link</a>");--> }); </script> </head> <body> <p>a content</p> </body> </html>

quote properly:

$("p").html("click <a href="+model.link+model.keyword+">this link</a>");

javascript jquery html json

ios - Jittery / laggy UI updates while dragging UIScrollView -



ios - Jittery / laggy UI updates while dragging UIScrollView -

i have uiscrollview utilize purely it's contentoffset. contentoffset changes, subview's moved around according simple math function. mostly, entails having y positions adjusted, not linearly respect uiscrollview's contentoffset.y.

an illustration of adjusting yposition this:

cgrect newframe = subview.frame; newframe.origin.y = log(scrollview.contentoffset.y) + 300; [subview setframe:newframe];

everything works fine in simulator , works great on device while uiscrollview isn't receiving touches (~24-30fps), while user touching screen , dragging, fps drops ~3-5fps. between dragging , not, there shouldn't difference, except in run loop, potentially. adjust that, i've tried in scrollviewdidscroll:

[self performselector:@selector(updatecards) onthread:[nsthread mainthread] withobject:nil waituntildone:yes modes:@[nsrunloopcommonmodes, uitrackingrunloopmode]];

and variations, no effect.

is there reason fps drop off , there can prepare issue? using ipod 5th generation of these tests.

ios objective-c uiscrollview drag nsrunloop

Ruby Validation When Adding to Database -



Ruby Validation When Adding to Database -

i new in ruby , on lastly step finish project, when i'm trying add together appointment have alter if doc works in time. don't know how :(

it how db works:

in appointment have data_wizyty (visit_date), doctor_id , godzina_wizyty(visit_time) - in adding form.

in schedules have: dzien_tygodnia(day_of_the_week), poczatek_pracy(start_working), koniec_pracy(end_working) , doctors_workplace_id

in doctors_workplace: doctor_id, schedule_id, clinic_id

i want check if doc available in of clinic in choosen date , time :) please help me :) have validated if date , time unique with:

class appointment < activerecord::base validates :doctor_id, uniqueness: { scope: [:data_wizyty, :godzina_wizyty], message: 'ten termin jest juz zajety!' } end

i need check if unique , if doc works.

appointment:

class appointment < activerecord::base validates :doctor_id, uniqueness: { scope: [:data_wizyty, :godzina_wizyty], message: 'ten termin jest juz zajety!' } after_initialize :ainit after_save :asave belongs_to :patient belongs_to :doctor belongs_to :schedule belongs_to :refferal belongs_to :clinic has_many :employees include multistepmodel def self.total_steps 3 end def ainit @wymaga_potwierdzenia = true end def asave if self.refferal_id == nil @potwierdzona = false else @potwierdzona = true end if self.wymaga_potwierdzenia == false @potwierdzona = true end end end

schedule:

class schedule < activerecord::base has_many :appointments belongs_to :clinic belongs_to :doctors_workplace def full_schedule "#{dzien_tygodnia} : #{poczatek_pracy} - #{koniec_pracy}" end end

doctors_workplace:

class doctorsworkplace < activerecord::base has_many :schedules belongs_to :doctor belongs_to :clinic_surgery end

now have :

def check_doctor_available if schedule.where(doctor: doctor, dzien_tygodnia: data_wizyty.wday) .where('poczatek_pracy < ? , koniec_pracy > ?', godzina_wizyty, godzina_wizyty).empty? self.errors.add(:doctor, message: 'nie pracuje w tym terminie!') end

it's have now:

def check_doctor_available if doctorsworkplace.where(doctor_id: doctor_id) , schedule.where(doctors_workplace_id: ????, dzien_tygodnia: data_wizyty.wday) .where('poczatek_pracy < ? , koniec_pracy > ?', godzina_wizyty, godzina_wizyty).empty? self.errors.add(:doctor, message: 'nie pracuje w tym terminie!') end

you can utilize custom validation. create private method in appointment checks if doc available @ given date/time.

validate :check_doctor_available private def check_doctor_available #your implementation end

take @ this if have doubts write in custom validation method.

ruby-on-rails ruby

javascript - Meteor animation for added items -



javascript - Meteor animation for added items -

what's best way of handling animations/transitions in meteor, e.g having fadein when new item appears rather appearing

as david weldon mentioned, meteor going adding back upwards ui hooks in 0.8.2 , create out supported apis 1.0.

the original thread here: https://groups.google.com/forum/#!topic/meteor-core/1kuog2mcarw

here few examples, including 1 i'm particularly happy with:

https://github.com/mizzao/meteor-animated-each, demo @ http://animated-each.meteor.com/ https://github.com/percolatestudio/transition-helper

the first illustration causes items in long scrollable container fade in/out when added/deleted, , adjusts scroll position other people scrolled different position in container don't see jump in view.

javascript jquery animation meteor

Windows Authentication using MVC5, display Username at the top of every View -



Windows Authentication using MVC5, display Username at the top of every View -

i developing mvc5 application doe. utilize windows authentication login our computers. need help getting users name when logged in display "welcome, username"(across pages) when navigate site. problem when navigate page displays our id utilize login, i.e. i5456 , password. much appreciated if assist me , walk me through how set up.

i have disabled forms auth , enabled windows auth in vs 2013. have tried using @user.identity.name in sitelayout, said id thing displayed. i'm not sure how setup model or view, or if have to. there way retrieve username can displayed instead of id?

try @user.identity.getusername() in view works me

windows authentication asp.net-mvc-5

reflection - get field value by its name in java -



reflection - get field value by its name in java -

i need read field value given field name. have class called product, has fields: size, image, link.. , have methods getsize(), getimage() , getlink() read values. if give 'size', want size calling getsize(), given 'image', image calling getimage()...

right have clumsy code phone call getfield(string fieldname) handler this:

public void string getfield(string fieldname, product p) { string value = ""; swtich(fieldname): case 'size': value = p.getsize(); break; case 'image': value = p.getimage(); break; ....

problem have many fields in class, whole code looks ugly. seek avoid reflection page because of poor readability. there other thought handle nicely? thanks

other reflection or explicit switch (as have), real alternative not have fields @ all. instead of getsize(), getimage(), etc., have general-purpose getattribute(attribute a). attribute there enum. like:

enum attribute { size, image, ... } public class product { map<attribute, string> attributes = new enummap<>(attribute.class); public string getattribute(attribute attribute) { homecoming attributes.get(attribute); } public void setattribute(attribute attribute, string value) { attributes.put(attribute, value); } ... }

enummaps efficient, code speedy -- not quite speedy real fields, not noticeably slower in app.

the reason making attribute enum (rather having string attribute keys, instance) gives same type safety explicit getter functions. instance, p.getattribute(attribute.not_a_real_attribute) produce compile-time error, same p.getnotarealattribute() (assuming enum value , method aren't defined, of course).

java reflection

java - Why doesn't this change the value -



java - Why doesn't this change the value -

this question has reply here:

is java “pass-by-reference” or “pass-by-value”? 58 answers public class subiectlicentatrei { public static void main(string args[]) { double d = 12.34; scadeunitate su = new scadeunitate(); su.scadeunitate(d); system.out.println(d); } } class scadeunitate { public void scadeunitate(double d) { d = d - 1.0; } }

outputs 12.34 when expect 11.34.

java pass value

so when pass here

ksu.scadeunitate(d);

d pass-by-value , when deduct here

d = d - 1.0;

d wont reference value 11.34. destroyed when out-of-scope

solution:

put homecoming value of scadeunitate method

public double scadeunitate(double d)

get homecoming value reference returned value.

d = su.scadeunitate(d);

java

android - Use Firebase connections properly for building a chat app -



android - Use Firebase connections properly for building a chat app -

i'm evaluating firebase building chat app. , it's plan makes me concern: 10,000 concurrent connections/$1,499/month.

it seems me chat app have always-on connection firebase, receive incoming messages instantly. means if app 10,000 active installs on android, no matter whether they're opening app or not, have pay $1,499/a month.

anyone know solution reducing concurrent connections firebase without impacting perceived quality of chat app? thanks.

note

this chat app, , perceived quality of chat app important. connection on android never released if device has net connection.

having 10k users or 10k downloads of app not equate having 10k concurrent users logged in , looking @ chat app @ same time.

a more accurate rule of thumb 1 concurrent > 1200 monthly visits typical website or app (apps average higher). example, 50 concurrent connections equals 50,000 visits month, 750 nearing 1000000 visitors.

most developers vastly overestimate number of concurrent users have. info point, web sites operate comfortably on "free" firebase plan days. in fact, more 99.5% of of firebases never nail 50 concurrent limit.

so, long story short, 10k concurrents more plenty our self-serve customers , 1 time you've approached 12 1000000 users, well, enterprise alternative appealing point.

android chat firebase

c# - How do I report to a ProgressBar when working with BackgroundWorker? -



c# - How do I report to a ProgressBar when working with BackgroundWorker? -

i have in form1 progressbar1 , backgroundworker , when clicking button create avi file want study progressbar according avi file creation progress.

this class create avi file:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using avifile; using system.drawing; using system.io; namespace windowsformsapplication1 { class createavi { public static void avimovie(fileinfo[] filenames) { bitmap bitmap = (bitmap)image.fromfile(filenames[0].fullname); avimanager avimanager = new avimanager(@"c:\temp\new.avi", false); videostream avistream = avimanager.addvideostream(false, 25, bitmap); int count = 0; (int n = 1; n < filenames.length; n++) { if (filenames[n].length > 0) { bitmap = (bitmap)bitmap.fromfile(filenames[n].fullname); avistream.addframe(bitmap); bitmap.dispose(); count++; } } avimanager.close(); } } }

in form1:

private void backgroundworker1_dowork(object sender, doworkeventargs e) { createavi.avimovie(allfiles); }

progress:

private void backgroundworker1_progresschanged(object sender, progresschangedeventargs e) { }

completed:

private void backgroundworker1_runworkercompleted(object sender, runworkercompletedeventargs e) { }

this did in form1:

this method in createavi class changed backgroundworker form1 (called variable bgw1):

public static void avimovie(fileinfo[] filenames,backgroundworker bgw1) { bitmap bitmap = (bitmap)image.fromfile(filenames[0].fullname); avimanager avimanager = new avimanager(@"c:\temp\new.avi", false); videostream avistream = avimanager.addvideostream(false, 25, bitmap); int count = 0; (int n = 0; n < filenames.length; n++) { if (filenames[n].length > 0) { bitmap = (bitmap)bitmap.fromfile(filenames[n].fullname); avistream.addframe(bitmap); bitmap.dispose(); count++; int pctdone = count * 100 / filenames.length; bgw1.reportprogress(pctdone); } } avimanager.close(); }

then in form1 changed in dowork event backgroundworker1:

private void backgroundworker1_dowork(object sender, doworkeventargs e) { createavi.avimovie(allfiles,backgroundworker1); } private void backgroundworker1_progresschanged(object sender, progresschangedeventargs e) { progressbar1.value = e.progresspercentage; label9.text = getallfiles[e.progresspercentage].fullname; }

so progressbar 100% end. however, in label19 see until file 000101.jpg , in idrectory there 167 files lastly 1 000167.jpg

getallfiles fileinfo[] , in form1 constructor did:

var directory = new directoryinfo(maindirectory); getallfiles = directory.getfiles("*.jpg");

and see getallfiles contain 167 files. how can study label files names process ?

reportprogress needs called method progress occurring:

public static void avimovie(fileinfo[] filenames,backgroundworker bgw1) { bitmap bitmap = (bitmap)image.fromfile(filenames[0].fullname); avimanager avimanager =new avimanager(@"c:\temp\new.avi", false); videostream avistream =avimanager.addvideostream(false, 25, bitmap); int count = 0; (int n = 0; n < filenames.length; n++) { if (filenames[n].length > 0) { bitmap =(bitmap)bitmap.fromfile(filenames[n].fullname); avistream.addframe(bitmap); bitmap.dispose(); count++; int pctdone = count * 100 / filenames.length; bgw1.reportprogress(pctdone); } } avimanager.close(); }

also, loop needs start @ 0--you skipping first element in filenames.

edit: in background worker's progresschanged event, can't utilize e.progresspercentage array index, have work backward percent index:

private void backgroundworker1_progresschanged(object sender, progresschangedeventargs e) { progressbar1.value = e.progresspercentage; int fileindex = e.progresspercentage * filenames.length/100; label9.text = getallfiles[fileindex].fullname; }

c# .net winforms

css - styling a vertical HTML5 range input -



css - styling a vertical HTML5 range input -

i'm trying style vertical range input , have:

input[type='range'] { -webkit-appearance: slider-vertical; background-color: #ccc; height: 158px; width: 2px; margin: 8px auto; } input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; border-radius: 20px; background-color: #3ebede; height: 30px; width: 30px; }

but seems because have '-webkit-appearance: slider-vertical;' create vertical, styles won't apply.

is there way style vertical range without transforms/plugins...?

note: need work on chrome

update: here jsfiddle have.

so answer, guess. need utilize other selectors. read more here.

-webkit-transform:rotate(90deg); - create vertical, tweak margins suit.

google friend!

from article:

webkit based browsers (chrome, safari, opera)

in webkit based browsers, track styled special pseudo selector ::-webkit-slider-runnable-track, , thumb ::webkit-slider-thumb.

custom focus styles can applied on thumb , track. if go route, you'll have remove default focus styles on input itself.

here an illustration in fiddle. css taken previous source.

html

<input type="range" />

css

input[type=range]{ -webkit-appearance: none; } input[type=range]::-webkit-slider-runnable-track { width: 300px; height: 5px; background: #ddd; border: none; border-radius: 3px; } input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; border: none; height: 16px; width: 16px; border-radius: 50%; background: goldenrod; margin-top: -4px; } input[type=range]:focus { outline: none; } input[type=range]:focus::-webkit-slider-runnable-track { background: #ccc; }

css html5

python - Django image resizing and convert before upload -



python - Django image resizing and convert before upload -

i searched lot on subject couldn't find need. i'll explain problem :

on website, user can upload image. need resize image , convert jpeg before uploading it.

i saw solutions using method in views.py, i'd overriding save() method in models.py. problem is, solutions found resizing image in save method after saving first time (calling super fonction), means it'd utilize bandwidth (if utilize cdn) nil (am right on point?).

thank help

first, it's best found right language. django , python exist on server side. therefore, manipulate, save, or otherwise use, has first sent server. if django or python manage photo, user must upload photo server first. 1 time photo uploaded, django free create changes before storing file.

if concern bandwidth, , don't want big files beingness uploaded, have resize , reformat photo on client side. if web application, can done using javascript, can not done python, since python not operate on client side application yours.

if concern not bandwidth, you're free have user "upload" file, have django resize , reformat before saving.

you right want override save function photo object. recommend using library handle resizing , reformatting, such sorl.

from sorl.thumbnail import imagefield, get_thumbnail class myphoto(models.model): image = imagefield() def save(self, *args, **kwargs): if self.image: self.image = get_thumbnail(self.image, '500x600', quality=99, format='jpeg') super(myphoto, self).save(*args, **kwargs)

sorl library confident , familiar with, takes tuning , configuration. can check out pillow or instead, , replace line overriding self.image.

i found similar question here.

edit: saw update comment response above. note if webserver handling django, , files beingness saved database on cdn, method work. image resized on webserver before beingness uploaded cdn (assuming configuration i'm assuming).

hope helps!

python django django-models

oracle - PL/SQL procedure to cascade delete child tables -



oracle - PL/SQL procedure to cascade delete child tables -

i have situation this.

i have write pl/sql procedure delete kid tables of parent table , modify length of column referenced in kid table.

i need take input user these parameters. parent table name parent column name (whose column size altered ) new column size

i new pl/sql programming .please help me.

thanks in advance.

i'm not going job here, these hints should help you:

find name of primary key constraint of parent table in all_cons_columns table_name='*name of parent table*' , column_name='*name of column want alter*' find kid tables in all_conststraints constraint_type='r' , r_constraint_name='*name of primary key constraint found in step one*' use execute immediate execute dml statements drop kid tables , alter parent table

sql oracle plsql

ios - how to route iPhone audio to the google-glass bluetooth headset -



ios - how to route iPhone audio to the google-glass bluetooth headset -

i have google-glass , iphone.in app needed iphone music sound hear google-glass bluetooth headset.first please tell me it's possible or not? , started googling found

how route iphone sound bluetooth headset

if possible redirect iphone sound output google-glass headset.please give me idea.

ios iphone audio bluetooth avaudioplayer

sql server - Reader not returning rows on check of Table Existance -



sql server - Reader not returning rows on check of Table Existance -

i know sure table exists yet reader has no rows. expect name of table come if exists

using (var cmd = new sqlcommand("select name sys.objects object_id = object_id(n'" + tablename + "') , type in (n'u')", sqlconnection)) { var reader = cmd.executereader(); { using (reader) { if (!reader.hasrows) homecoming false; while (reader.read()) tablenamefound = reader.getstring(0); } } }

i ran query straight in management studio , "cars":

select name sys.objects object_id = object_id(n'cars') , type in (n'u')

so maybe shouldn't using reader here? don't know.

your query fine.

check:

if run on right database / schema. query fail when running in master illustration when table in database / schema; if parameter come in doesn't contain spaces, etc.

sql-server tsql

postgresql - Matching algorithm in SQL -



postgresql - Matching algorithm in SQL -

i have next table in database.

# select * matches; name | prop | rank ------+------+------- carl | 1 | 4 carl | 2 | 3 carl | 3 | 9 alex | 1 | 8 alex | 2 | 5 alex | 3 | 6 alex | 3 | 8 alex | 2 | 11 anna | 3 | 8 anna | 3 | 13 anna | 2 | 14 (11 rows)

each person ranked @ work different properties/criterias called 'prop' , performance called 'rank'. table contains multiple values of (name, prop) illustration shows. want best candidate next requirements. e.g. need candidate have (prop=1 , rank > 5) , (prop=3 , rank >= 8). must able sort candidates rankings best candidate.

edit: each person must fulfill requirements

how can in sql?

select x.name, max(x.rank) matches x bring together ( select name matches prop = 1 , rank > 5 intersect select name matches prop = 3 , rank >= 8 ) y on x.name = y.name grouping x.name order max(rank);

sql postgresql relational-division

SAS Hotkey permanent binding -



SAS Hotkey permanent binding -

i know f9 opens definitions windows in sas enhanced editor changes made here seem lastly current session.

is there way configure sas hotkeys remain effective subsequent sessions ?

check 'save settings on exit' alternative selected in 'preferences' (menu: tools -> options -> preferences). alternative should on 'general' tab. can't sure trick though expect so.

go here read more it:- http://support.sas.com/documentation/cdl/en/hostwin/63285/html/default/viewer.htm#customizing.htm

sas

security - How to create a secure one-user login without using SQL? -



security - How to create a secure one-user login without using SQL? -

i planning on creating little web service host on site, know how create simple, secure login form (username + password) 1 username + password combination, without using sql. doesn't have super-secure, nice if couldn't crack peeking @ source code. can done?

you utilize basic auth?

http://en.wikipedia.org/wiki/basic_access_authentication

sql security login

c# - Self-Host SignalR and Local Http Server on the same port -



c# - Self-Host SignalR and Local Http Server on the same port -

i want host a self-host signalr process locally on port 80 , having local http directory hosted on same port (serving files directory, mapping directory construction http requests).

for illustration accessing localhost:80/index.html homecoming html file located in directory, communicates signalr process on same port, because having different ports cause error in chrome browser due same origin policy.

any thought how can accomplish it? since cannot bind same port 2 different applications.

as long we're talking signalr 2.x , can serve other content via webapi, possible since both utilize owin. mvc, things more complicated.

to run signalr , webapi on same port, you'd have install microsoft.aspnet.webapi.owinselfhost in signalr applilcation , modify owin.iappbuilder utilize web api:

public static class startup { public static void configuration(iappbuilder app) { var httpconfig = new httpconfiguration(); httpconfig.routes.maphttproute("default", "api/{controller}/{id}", new {id = routeparameter.optional}); app.usewebapi(httpconfig); app.mapsignalr(); } }

note use cors around browser issue.

c# localhost signalr self-hosting

layout - How to add margin for a button in Flex -



layout - How to add margin for a button in Flex -

in flex application have button next declaration placed above custom data-grid component.

<mx:button id="resetbutton" label="reset" visible="true" />

the button placed above grid , need move few pixels higher there little space between them.

i noticed there paddingbottom attribute button component no marginbottom equivalent.

i not find advice on google. right way accomplish this?

edit:

the bottom property did not have effect in case (perhaps due layout used) ended surrounding button new vbox component this:

<mx:vbox paddingbottom="5"> <mx:button id="resetbutton" label="reset" visible="true" /> </mx:vbox>

you can utilize top, bottom, left, right attribute instead of margintop, marginbottom, marginleft, marginright. function of top same margintop

<mx:button id="btnsave" top="50" bottom="50" left="50" right="50" click="btnsave_clickhandler(event)" label="save file" />

may help you.

flex layout

javascript - Validate Regex with minimum length and new line -



javascript - Validate Regex with minimum length and new line -

i trying match string having length > 10

var value = "lorem ipsum dummy text of printing , type"; /^.{10,}$/.test(value);

returns true;

but, if have string new line character fails.

how can update regular look prepare that.

i know can check .length > 10 or replace new line space in value. but, want update regular expression.

if it's length you're testing should utilize .length. if insist in regex, dot matching except newline. can alter searching \s\s instead:

([\s\s]{10,})

this matches whitespace , non whitespace, covering entire spectrum. sadly, s modifier not supported js regex.

javascript

php - Continue execution after sending file to client -



php - Continue execution after sending file to client -

i'm creating dynamically pdf file , sending client:

private function createpdf($foo) { //delete pdf file if exists if(file_exists('path_to_directory' . $foo->getid() . '.pdf')) unlink('path_to_directory' . $foo->getid() . '.pdf'); //create new pdf file $this->get('knp_snappy.pdf')->generatefromhtml( $this->renderview( 'acmefoobundle:default:pdftemplate.html.twig', array( 'foo' => $foo) ), 'path_to_directory' . $foo->getid() . '.pdf' ); // open file in binary mode $fp = fopen('path_to_directory' . $foo->getid() . '.pdf', 'rb'); header("content-type: application/pdf"); header('content-disposition: attachment; filename="foo.pdf"'); // dump image , stop script fpassthru($fp); exit; }

this function works right, i'd want go on execution after sending file client render "success" template , send client. i've tried things removing exit; , this: continue execution after calling php passthru() function, no success. idea?

achieved adding javascript event file generation button:

pure js:

<script> window.onload = function() { function redirecttomeeting() { window.settimeout(function() { window.location.href="url_to_go"; }, 2000); } if(document.getelementsbyclassname('create-file-button')) { document.getelementsbyclassname('create-file-button')[0].addeventlistener('click', redirecttomeeting); } }; </script>

then, when button clicked, new file created , sent client, , (after 2 seconds) client redirected url_to_go.

jquery:

$(function(){ $('#create-file-button').submit(function(ev) { $("#continue").show(); }); });

when form submitted, new button (#continue) shown lets user go next page (url_to_go).

php symfony2

android - How to install packaged app on Firefox for mobile? -



android - How to install packaged app on Firefox for mobile? -

how test-install packaged (zip) app on fennec?

device: physical android phone or android emulator, don't care.

install mozilla-apk-cli using npm:

npm install -g mozilla-apk-cli

use generate "debuggable" apk app either source directory or url mini-manifest:

mozilla-apk-cli /path/to/source/dir/ arbitrary-name.apk mozilla-apk-cli http://example.com/path/to/mini/manifest.webapp arbitrary-name.apk

(context-click > inspect element on "free" button in marketplace find mini-manifest url app in marketplace.)

install apk on android device:

adb install -r arbitrary-name.apk

launch app on device. notification area notification port remote debugger server listening on. forwards port on desktop, f.e. if port 12345:

adb forwards tcp:12345 tcp:12345

go web developer > connect… in firefox on desktop , connect localhost @ forwarded port. commence debugging!

notes:

use nightly builds of fennec best experience. bug 929382 tracks webide (née app manager) integration. file bugs on problems encounter!

android firefox web-applications fennec

Absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application error in tomcat -



Absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application error in tomcat -

i deleted tomcat server , added in eclipse kepler , getting error when run project.before deleting server there no issues.

part of pom contains :

<dependency> <groupid>javax.servlet</groupid> <artifactid>javax.servlet-api</artifactid> <version>3.1.0</version> </dependency> <dependency> <groupid>javax.servlet</groupid> <artifactid>jstl</artifactid> <version>1.2</version> <scope>provided</scope> </dependency>

and jsp page contains :

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

i tried other solutions here did not resolve issue.any help appreciated.

try 1 mvnrepository

<dependency> <groupid>jstl</groupid> <artifactid>jstl</artifactid> <version>1.2</version> </dependency>

read similar post here

java jsp maven

html - How to get the value(only) of an attribute using xpath? -



html - How to get the value(only) of an attribute using xpath? -

i have question using xpath value of attribute. know using @ can attributename-value pair, if want value?

let me give example: fr link: http://www.campbellskitchen.com/?pd=yes&sekw=10941064280

if utilize chrome , utilize $x("//a[contains(.,'brand')]/following-sibling::div//a/@title")

it homecoming me array of this:

[title="campbell's condensed soup", title="campbell's gravies", title="swanson broth , stock" ...]

this not want, want homecoming array be:

[campbell's condensed soup, campbell's gravies, swanson broth , stock ...]

<li role="menuitem" class="parent"><a href="/brands?fm=link_navigated" title="brands" role="link" tabindex="10" accesskey="b"> brands</a> <div class="subnavi dropdown_5columns"> <!-- begin 5 columns container --> <div class="ddheader"> <div class="leftcorner"> <div class="rightcorner"> &nbsp; </div> </div> </div> <div class="leftshadow"> <div class="rightshadow"> <div class="ddcontent clearfix"> <div class="col_1_logo"> <a href="/wisestkid/home?fm=link_navigated" title="campbell’s&reg; condensed soup"> <img width="65" height="27" alt="campbell’s&reg; condensed soup" src="~/media/ourbrands/logos/campbells.ashx?mh=38&amp;mw=65"></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_0" title="campbell&#39;s® gravies" href="/brands/campbells%20gravies?fm=link_navigated"><img src="/~/media/ourbrands/logos/campbells_gravy.ashx?h=38&amp;mh=38&amp;mw=65&amp;w=57" alt="campbells gravy" width="57" height="38" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_1" title="swanson® broth , stock" href="http://www.campbellskitchen.com/swanson/home.aspx?fm=theater"><img src="/~/media/ourbrands/logos/swansonfb_llogo.ashx?h=36&amp;mh=38&amp;mw=65&amp;w=65" alt="swanson" width="65" height="36" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_2" title="pace® sauces" href="/brands/pace%20sauces?fm=link_navigated"><img src="/~/media/ourbrands/logos/pace.ashx?h=38&amp;mh=38&amp;mw=65&amp;w=60" alt="pace" width="60" height="38" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_3" title="prego® sauce" href="/brands/prego%20sauce?fm=link_navigated"><img src="/~/media/ourbrands/logos/prego.ashx?h=25&amp;mh=38&amp;mw=65&amp;w=65" alt="prego" width="65" height="25" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_4" title="pepperidge farm®" href="/brands/pepperidge%20farm?fm=link_navigated"><img src="/~/media/ourbrands/logos/pepperidge_farm.ashx?h=22&amp;mh=38&amp;mw=65&amp;w=65" alt="pepperidge farms" width="65" height="22" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_5" title="soup plus" href="/brands/soup%20plus?fm=link_navigated"></a> </div> <div class="col_3"> <a href="/brands?fm=link_navigated" title="see our brands"> see our brands</a> </div> </div> <!-- ddcontent --> </div> </div> <div class="ddfooter"> <div class="leftcorner"> <div class="rightcorner"> &nbsp; </div> </div> </div> </div> <!-- end 5 columns container --> </li>

$x returns selected dom nodes, if want extract info nodes you'll have in javascript sec step, e.g.

$x(somexpath).map(function(n) { homecoming n.nodevalue; });

html xpath

user interface - git gui - add new remote -



user interface - git gui - add new remote -

i trying initialize remote git , force folder files using git gui. doing same sequence in windows git gui works perfectly. when doing remote->add in ubuntu, name: test location: /home/ubuntu/test.git

i next error: fatal: git_work_tree (or --work-tree=) not allowed without specifying git_dir (or --git-dir=) should set git_dir=/home/ubuntu/test.git? , after doing that, repeat remote->add step ?

thanks, ran

it's been resloved. intialized shell commands, , homecoming utilize git gui. functions ok.

cd <server_dir> mkdir <name>.git cd <name>.git git init --bare cd <work_dir> git init git add together * git commit -m "adding me files, luck" git remote add together <git_name> <server_dir>/<name>.git git force -u <git_name> master

git user-interface

Selenium-webdriver java dropdown issue element should have been select -



Selenium-webdriver java dropdown issue element should have been select -

i have html code dropdown:

<div class="column two"> <select id="cctype" name="cctype"> <option value="">please select...</option> <option value="mcard">master card</option> <option value="visa ">visa</option> </select>

my script:

javascriptexecutor js = (javascriptexecutor) driver; js.executescript("arguments[0].select();", selectcreditcardtype); selectcreditcardtype.selectbyvalue("visa");

or

selectcreditcardtype.selectbyvisibletext(customer.creditcardtype);

result: element should have been select input.

tried different options stackoverflow: selenium webdriver c# css dropdown issue - element should have been select div no luck yet.

it should work if utilize openqa.selenium.support.ui.selectelement class

c# example:

var selelement = new openqa.selenium.support.ui.selectelement([web element goes here]); foreach (var alternative in selelement.options) { if (option.text == "desired text here") selelement.selectbytext(option.text); }

you can value, attribute selection , comparing on alternative of select element.

option.getattribute("value");

java webdriver

How to append existing html Header tag in javascript/jQuery with some text and setting its font size? -



How to append existing html Header tag in javascript/jQuery with some text and setting its font size? -

this question has reply here:

how can append <h1> tag within span jquery? 4 answers

i want show header content "rolling app hello, sanjayb" rolling app static content left side of header whereas hello, sanjayb i.e. appended text should @ right side of header font size 10.

i trying no luck

$("#mainheader").html("<h2>rolling app </h2>"+"<p font-size: 5px;>"+appusername+"</p>");

try :

$(function(){ $("#mainheader").append("<h2>rolling app " +"<span style='font-size:10pt;'>" +appusername+"</span></h2>"); });

working jsfiddle

javascript jquery html5

javascript - How can I get a value from xml? -



javascript - How can I get a value from xml? -

i have next xml:

<order> <moulding> <imgsrc>imgsrc</imgsrc> <width>1.13</width> </moulding> </order>

i tried getting moulding width by:

moulding_width = doc.getelementsbytagname('moulding')[0].childnodes[1].nodevalue;

however not working. how can moulding width?

assume

var xml = "<order><moulding><imgsrc>imgsrc</imgsrc><width>1.13</width></moulding></order>";

following, xml parsing of variable string in javascript can utilize (this requires jquery)

var order = $.parsexml(xml).getelementsbytagname("order")[0] var moulding = order.getelementsbytagname("moulding")[0] var width = moulding.getelementsbytagname("width")[0]; var moulding_width = parsefloat(width.textcontent);

or, using method of node access

var moulding_width = parsefloat($.parsexml(xml).getelementsbytagname("order")[0].childnodes[0].childnodes[1].textcontent);

note getelementsbytagname gives list of desired elements, , not contents, why there additional childnodes compared approach.

if you're not using jquery, might consider (see http://www.w3schools.com/dom/dom_parser.asp )

function parsexml(text) { if (window.domparser) { parser=new domparser(); homecoming parser.parsefromstring(text,"text/xml"); } else { // code ie xmldoc=new activexobject("microsoft.xmldom"); xmldoc.async=false; xmldoc.loadxml(text); homecoming xmldoc; } } var moulding_width = parsefloat(parsexml(xml).getelementsbytagname("order")[0].childnodes[0].childnodes[1].textcontent);

javascript xml

oauth - How do you get a access token for postman? -



oauth - How do you get a access token for postman? -

i using postman create request instead of using creditials utilize token oauth 1.0.

i've looked info how access token , im assuming method similar article describes.

https://developer.yahoo.com/oauth/guide/oauth-auth-flow.html#oauth-consumerkey

i don't understand mean when have register application. how go doing that? in next steps there seem's code writing involved in making other request. how work? please give me more detailed explanation on how process works.

oauth access-token postman

javascript - Div does not show on change function but in ajax success it does -



javascript - Div does not show on change function but in ajax success it does -

it's simple thing want do, on alter function want loading div visible, & through ajax request i'm filling content. thing loading div not working in alter function it's working in ajax success function, not know i'm making mistake. please have @ code.

<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script> <script> $(document).ready(function(){ $('#sub').change(function(){ $('.autoload').empty(); $('.loading').show(); // here doesn't work var val=$(this).val(); $(this).value= val; if(val=='one'){ var sub_cat=11; } else if(val=='two'){ var sub_cat=12; } else{ var sub_cat=13; } var cat_id= <?php echo $cat_id; ?>; $.ajax({ type: "post", url: "ajax_showsubdiv.php", data: {cat_id:cat_id,sub_cat:sub_cat}, success: function(option){ $('.loading').show(); // here it's working $('.autoload').replacewith(option); flag=false; } }); $('.loading').hide(); }); }); </script>

html

<div class='autoload'></div> <div class='loading'> <img src='acz.gif'> </div>

everything working fine, info coming fine, replacing perfectly, thing takes time show loading div because lies in success function, after ajax request completed, div shows. can tell why it's not working?

the statement $('loading').hide(); @ bottom of alter function executing , hiding element after calling $('loading').show();. since ajax asynchronous browser not wait $.ajax() calls finish before continuing execution. seek removing statement.

javascript ajax

html - Four Evenly-Spaced Table Boxes -



html - Four Evenly-Spaced Table Boxes -

i'm trying create 4 evenly-spaced <table> cells reason, having little difficulty doing (even though have set widths them).

an illustration can seen below, sec cell appears larger others:

<tr> <td style="width: 100%; padding: 0px 20px 0px 20px;" cellspacing="0" cellpadding="20" border="0" colspan="12" align="center"> <table style="width: 600px; border-collapse: collapse; border: 1px solid orange;" cellspacing="0" cellpadding="20" border="0" colspan="12" align="center"> <tbody cellspacing="0" cellpadding="0" border="0" colspan="12" align="center" style="width: 100%;" width="100%"> <tr cellspacing="0" cellpadding="0" border="0" colspan="12" align="center" style="width: 100%;" width="100%"> <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1f1f1f; text-align: center; border: 1px solid orange; font-family: helvetica, arial, verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" > <img src="http://dummyimage.com/50x50/000/fff.jpg&text=icon" alt="bullhorn icon" width="50" height="50" /><br /> <p style="font-family: helvetica, arial, verdana; font-size: 10px; color: #1f1f1f; text-align: center;">dolorla ti <br />amet silio</p> </td> <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1f1f1f; text-align: center; border: 1px solid orange; font-family: helvetica, arial, verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" > <img src="http://dummyimage.com/50x50/000/fff.jpg&text=icon" alt="lab icon" width="50" height="50" /><br /> <p style="font-family: helvetica, arial, verdana; font-size: 10px; color: #1f1f1f; text-align: center;">adipiscing <br />consecteture</p> </td> <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1f1f1f; text-align: center; border: 1px solid orange; font-family: helvetica, arial, verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" > <img src="http://dummyimage.com/50x50/000/fff.jpg&text=icon" alt="atom icon" width="50" height="50" /><br /> <p style="font-family: helvetica, arial, verdana; font-size: 10px; color: #1f1f1f; text-align: center;">facili elit <br />torem</p> </td> <td cellspacing="0" cellpadding="0" width="148" style="width: 148px; color: #1f1f1f; text-align: center; border: 1px solid orange; font-family: helvetica, arial, verdana; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;" > <img src="http://dummyimage.com/50x50/000/fff.jpg&text=icon" alt="file icon" width="50" height="50" /><br /> <p style="font-family: helvetica, arial, verdana; font-size: 10px; color: #1f1f1f; text-align: center;">ipsum sit down <br />sepida colt</p> </td> </tr> </tbody> </table> </td> </tr>

jsfiddle

how create 4 evenly-spaced table cells?

you need utilize table-layout propertie.

http://www.w3.org/tr/css21/tables.html#fixed-table-layout

in case:

<table style="width: 600px; border-collapse: collapse; border: 1px solid orange;table-layout:fixed;" cellspacing="0" cellpadding="20" border="0" colspan="12" align="center">

demo

html css html5 css3

angularjs - Using flexbox layout with angular-ui tabs -



angularjs - Using flexbox layout with angular-ui tabs -

i wan't utilize flexbox layout angular ui tabs (ui.bootstrap.tabs). have plunker:

http://plnkr.co/edit/9tol1wlwgdvt0dldmnaa

i changed ui-template div's flexbox classes. still tab content div not filling available space.

any idea?

i have found solution. here updated plunker:

http://plnkr.co/edit/oswsgyapfj9ssohms0fs?p=preview

the key override display property of '.tab-content>.active' class. default set 'display: block'. has set 'display: flex'.

angularjs tabs angular-ui flexbox

html5 - Trying to play audio using JavaScript. But is not playing? -



html5 - Trying to play audio using JavaScript. But is not playing? -

so trying create radio station project fun. in start play sound file saying like: "welcome beat @ 97.5" or whatever , take random song , after ends play sound file saying "that awesome beat. moving on next!" , play different random song

exciting part! code! tried doing this:

var sound = new audio("test.mp3"); audio.play();

it wouldnt play anything? whats easiest , fastest way play sound javascript? please no html involved.

edit: tried utilize howler.js wouldnt still? here code:

//i moved var sound = new howl({ urls: ['/audio/test.mp3'] }).play();

this directory: c:\websites\infiniteradiostation\audio\test.mp3

the code have posted looks good, please check javascript console there no errors , create sure path of file correct.

other have multiple options can utilize enhance functionality.

soundmanager2

soundmanager2 first-class library provides tons of features(and backward compatibility if prefer).

the sample code this.

<script src="/path/to/soundmanager2.js"></script> <script> soundmanager.setup({ url: '/path/to/swf-files/', onready: function() { var mysound = soundmanager.createsound({ id: 'asound', url: '/path/to/an.mp3' }); mysound.play(); } }); </script> howler.js

howler first-class library thats worth looking.its illustration code thing this

var sound = new howl({ urls: ['sound.mp3', 'sound.ogg', 'sound.wav'], autoplay: true, loop: true, volume: 0.5, onend: function() { alert('finished!'); } });

javascript html5 audio playback

javascript - How to process HTML forms? -

This summary is not available. Please click here to view the post.

javascript - Placement of jQuery -



javascript - Placement of jQuery -

so code below simple slider. wondering why not work when move jquery code bottom (before )?-- works when @ top did reading seems preach placing @ bottom.

<!doctype html> <html> <head> <title>slide panel</title> <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> <script type="text/javascript" src="script.js"></script> <link rel="stylesheet" type="text/css" href="stylesheet.css"></link> </head> <body> <div class="panel"> <br /> <br /> <p>now see me!</p> </div> <p class="slide"><div class="pull-me">slide up/down</div></p> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> </body> </html>

because main script, script.js set before declaration of jquery. main script should declared after jquery. can set script.js under jquery script tags @ bottom of page , still work or can set jquery script tags on top of script.js tag @ top of page , still work.

javascript jquery

javascript - Snapjs Drawer issue and scrolling content -



javascript - Snapjs Drawer issue and scrolling content -

i using snap js such have drawer on left , content right. when drawer opened, can still scroll content on left.

what right way can disable div on left. in jquery:

if (state == 'right')                   "disable left side can't scroll' ( $('.idofelement').disable();) ;

is there overlooking in snap within controller left can disabled, without dom manipulation.

in snap.js file

set this

disable: 'left'

javascript angularjs scroll snapjs

javascript - KineticJS: Get the mouse button, x and y from the 'click' event on a Circle -



javascript - KineticJS: Get the mouse button, x and y from the 'click' event on a Circle -

using kineticjs, created circle: using next line:

var circle = new kinetic.circle({...});

then, started listening 'click' event way:

circle.on("click", function(evt) { // hope mouse button, x , y here... });

using evt object above, hope mouse button used click, , x , y of click location. inspected evt object, , not find of these.

i did target node, , event type 'evt' object though.

am missing anything? may argument click handler?

i post sscce if info not enough.

any response appreciated!

in latest kineticjs version (5.1.0), can position accessing evt.evt.clientx , evt.evt.clienty.

regarding detection of mouse button clicked, take @ this approach jquery cross-browser back upwards

javascript click mouse kineticjs

c - gcc raises "unrecognized command line option" error with pkg-config -



c - gcc raises "unrecognized command line option" error with pkg-config -

i trying compile gtk programme using tutorial here. when issue command

gcc -o tut tut.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-2.0)

i next error:

gcc: error: unrecognized command line alternative ‘-pthread -i/usr/include/gtk-2.0 -i/usr/lib/x86_64-linux-gnu/gtk-2.0/include -i/usr/include/atk-1.0 -i/usr/include/cairo -i/usr/include/gdk-pixbuf-2.0 -i/usr/include/pango-1.0 -i/usr/include/gio-unix-2.0/ -i/usr/include/freetype2 -i/usr/include/glib-2.0 -i/usr/lib/x86_64-linux-gnu/glib-2.0/include -i/usr/include/pixman-1 -i/usr/include/libpng12 -i/usr/include/harfbuzz -wl,--export-dynamic -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lfreetype -lgmodule-2.0 -lglib-2.0 ’

gcc version 4.8.2. pkg-config version 0.26. have libgtk2.0-dev installed.

i can compile simple c programs fine.

how resolve "unrecognized command" problem?

[update comment]

i using zsh.

this looks shell issue.

what shell using?

in case it's not bash, give bash try.

c gcc gtk zsh pkg-config

ruby on rails - validating checkbox acceptance for a form that doesn't have a model -



ruby on rails - validating checkbox acceptance for a form that doesn't have a model -

i add together validator checkbox, if not accepted form not sent. ideally rails solution.

the form emailed straight admin opposed beingness stored in db, so, in limited rails wisdom assume model validations not work.

here part of form concerned validation.

<%= f.check_box :agree, {}, 'agree', "don't agree" %>

edit

i had tried adding

validates :agree, acceptance: true

but model, wether accepted or not, form keeps failing

thanks in advance

rico

ruby-on-rails forms validation

android - Controll buffering in VideoView -



android - Controll buffering in VideoView -

i'm trying utilize videoview display mp4 video vimeo. works fine there way can command buffering of video? problem have 6 videoview's in 1 view , view loads of them starts buffering right away. them start buffering when press play on 1 of them lower net usage.

is there way start/stop buffering?

android streaming video-streaming videoview

regex - IIS rewrite URL rule - OR condition -



regex - IIS rewrite URL rule - OR condition -

in iis rewrite url rules seek grab url start fr , de or ru .

for single look - ^fr(.*)$

how create multiple ("fr" , "de" or "de") ?

i tried - ^(fr | de | ru)(.*)$ no success .

take spaces out of expression:

^(fr|de|ru)(.*)$

regex url iis url-rewriting rewrite

vb.net - SSRS - Group Consecutive Rows of Same Time Spans -



vb.net - SSRS - Group Consecutive Rows of Same Time Spans -

related sql question - grouping consecutive rows of same value using time spans

i want convert table:

╔═══════════╦════════════╦═══════════╦═══════════╦═════════╗ ║ classroom ║ coursename ║ lesson ║ starttime ║ endtime ║ ╠═══════════╬════════════╬═══════════╬═══════════╬═════════╣ ║ 1001 ║ course of study 1 ║ lesson 1 ║ 0800 ║ 0900 ║ ║ 1001 ║ course of study 1 ║ lesson 2 ║ 0900 ║ 1000 ║ ║ 1001 ║ course of study 1 ║ lesson 3 ║ 1000 ║ 1100 ║ ║ 1001 ║ course of study 2 ║ lesson 10 ║ 1100 ║ 1200 ║ ║ 1001 ║ course of study 2 ║ lesson 11 ║ 1200 ║ 1300 ║ ║ 1001 ║ course of study 1 ║ lesson 4 ║ 1300 ║ 1400 ║ ║ 1001 ║ course of study 1 ║ lesson 5 ║ 1400 ║ 1500 ║ ╚═══════════╩════════════╩═══════════╩═══════════╩═════════╝

to table:

╔═══════════╦════════════╦═══════════╦═════════╗ ║ classroom ║ coursename ║ starttime ║ endtime ║ ╠═══════════╬════════════╬═══════════╬═════════╣ ║ 1001 ║ course of study 1 ║ 0800 ║ 1100 ║ ║ 1001 ║ course of study 2 ║ 1100 ║ 1300 ║ ║ 1001 ║ course of study 1 ║ 1300 ║ 1500 ║ ╚═══════════╩════════════╩═══════════╩═════════╝

the sql solution related question works query takes forever because have lot of info in tables , sql query using 2 sub queries. original table query 3 joins in complexity bigger.

i looking ssrs solution. possible using "vb magic" or other kind of magic in ssrs 2008 r2 ?

vb.net reporting-services ssrs-tablix ssrs-2008-r2 ssrs-grouping

How to reconstruct a C struct given memory content? -



How to reconstruct a C struct given memory content? -

given memory content (e.g. gdb) reconstruct content of c struct. struct defined follows (see man semop):

unsigned short sem_num; /* semaphore number */ short sem_op; /* semaphore operation */ short sem_flg; /* operation flags */

and memory content (as indicated address of struct using debugger) follows:

00000000 00 00 ff ff 00 10 78 bd 21 0a 8c c8 24 0a c4 95 |......x.!...$...| 00000010 5e 09 d0 69 22 08 18 78 c9 bf ed f4 28 08 00 00 |^..i"..x....(...| 00000020 00 00 01 00 00 00 01 00 00 00 00 00 00 00 01 00 |................|

what values of sem_num, sem_op , sem_flag? safe assume first variable uses 1 byte, while other 2 utilize 2 bytes each? can next mapping?

sem_num = 00 sem_op = 00 ff sem_flg = ff 00

following suggestion of dark falcon, next code seems job:

#include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> int main (void) { struct sembuf my_sembuf[1]= { {0,-1,16*256} }; unsigned char data[sizeof my_sembuf]; size_t i; memcpy(data, &my_sembuf, sizeof my_sembuf); (i=0; < sizeof my_sembuf; ++i) printf("%02x\n", data[i]); homecoming 0; }

the include ensure semop construction defined, need filled , compared memory dump. turns out, content of semop construction must following:

unsigned short sem_num = 0; short sem_op = -1; short sem_flg = 16*256; /* corresponding flag sem_undo */

c struct gdb

int - Fail to Understand Java Two's Complement -



int - Fail to Understand Java Two's Complement -

i have code:

package com.company; import java.net.inetaddress; import java.net.unknownhostexception; public class main { private final static int broadcast = 0xffffffff; //4294967295, or 255.255.255.255 private final static int firstclasse = 0xf0000000; //4026531840, or 240.0.0.0 public static int getintinetaddress(inetaddress toconvert) { final byte[] addr = toconvert.getaddress(); final int ipaddr = ((addr[0] & 0xff) << (3 * 8)) + ((addr[1] & 0xff) << (2 * 8)) + ((addr[2] & 0xff) << (1 * 8)) + (addr[3] & 0xff); homecoming ipaddr; } public static boolean isclasseaddress(inetaddress address) { int curaddr = getintinetaddress(address); boolean test1 = curaddr >= firstclasse; boolean test2 = curaddr < broadcast; system.out.println(string.format("\ncuraddr: %s, firstclasse: 240.0.0.0, broadcast: 255.255.255.255", address.gethostaddress())); system.out.println(string.format("curaddr: %d, firstclasse: %d, broadcast: %d, curaddr >= firstclasse: %s, curaddr < broadcast: %s", curaddr, firstclasse, broadcast, test1 ? "true" : "false", test2 ? "true" : "false")); homecoming (test1 && test2) ? true : false; } public static void main(string[] args) throws unknownhostexception { if (isclasseaddress(inetaddress.getbyname("1.0.0.0"))) { // raise flag system.out.println("class e ip address detected."); } if (isclasseaddress(inetaddress.getbyname("250.0.0.0"))) { // raise flag system.out.println("class e ip address detected."); } if (isclasseaddress(inetaddress.getbyname("239.255.255.255"))) { // raise flag system.out.println("class e ip address detected."); } if (isclasseaddress(inetaddress.getbyname("240.0.0.0"))) { // raise flag system.out.println("class e ip address detected."); } if (isclasseaddress(inetaddress.getbyname("240.0.0.1"))) { // raise flag system.out.println("class e ip address detected."); } if (isclasseaddress(inetaddress.getbyname("255.255.255.255"))) { // raise flag system.out.println("class e ip address detected."); } } }

which produces next output:

curaddr: 1.0.0.0, firstclasse: 240.0.0.0, broadcast: 255.255.255.255 curaddr: 16777216, firstclasse: -268435456, broadcast: -1, curaddr >= firstclasse: true, curaddr < broadcast: false curaddr: 250.0.0.0, firstclasse: 240.0.0.0, broadcast: 255.255.255.255 curaddr: -100663296, firstclasse: -268435456, broadcast: -1, curaddr >= firstclasse: true, curaddr < broadcast: true class e ip address detected. curaddr: 239.255.255.255, firstclasse: 240.0.0.0, broadcast: 255.255.255.255 curaddr: -268435457, firstclasse: -268435456, broadcast: -1, curaddr >= firstclasse: false, curaddr < broadcast: true curaddr: 240.0.0.0, firstclasse: 240.0.0.0, broadcast: 255.255.255.255 curaddr: -268435456, firstclasse: -268435456, broadcast: -1, curaddr >= firstclasse: true, curaddr < broadcast: true class e ip address detected. curaddr: 240.0.0.1, firstclasse: 240.0.0.0, broadcast: 255.255.255.255 curaddr: -268435455, firstclasse: -268435456, broadcast: -1, curaddr >= firstclasse: true, curaddr < broadcast: true class e ip address detected. curaddr: 255.255.255.255, firstclasse: 240.0.0.0, broadcast: 255.255.255.255 curaddr: -1, firstclasse: -268435456, broadcast: -1, curaddr >= firstclasse: true, curaddr < broadcast: false

what not understanding why numbers , comparisons not expect them be, yet code produces results want. gather it's whole two's complement thing, don't "get" reason. mechanically, know (two's complement) flipping bits , adding 1 don't is, why comparisons working if of numbers inverted?

for example, in first check ip 1.0.0.0, int value 16777216 checked see if it's smaller int value 255.255.255.255, -1. result false, broadcast ip, when converted int, larger, not smaller, ip 1.0.0.0. likewise, check 1.0.0.0 beingness @ least, or higher than, 240.0.0.0 returns true, when know isn't case.

i've checked boundary cases , working... don't understand why (and wrote code, go figure!). if there more clear method of determining if ip fals within range, explore way must not making sense, despite working (or it?)

in intellij, there's unusual illustration of behaviour. when examine address, inspector showing both proper value , negative value, i've highlighted reddish arrows in pic below. using windows calc, set in -84 , converted hex , received fff...fac. when set in 172, received ac... why same hex number, preceeded 1 in sig position?

update:

thanks patient give-and-take , great answers! think mechanics of thing, still grappling subtleties of usage. :) cheers!

to summarize, want isclasseaddress(inetaddress address) homecoming true if address between 240.0.0.0 , 255.255.255.254 inclusive. takes 2 lines of code:

public static boolean isclasseaddress(inetaddress address) { int curaddr = getintinetaddress(address); homecoming ((curaddr & 0xf0000000) == 0xf0000000) && (curaddr != 0xffffffff); }

java int twos-complement

match - Sum a column in Excel based on two references in the column and two filter reference columns -



match - Sum a column in Excel based on two references in the column and two filter reference columns -

i need sum valumes of column, need identify column based on 2 values in column , have filter values in 2 adjecent columns.

here example:

reference1 act. act. act. ... bud. bud. bud. reference2 jan feb mar ... jan feb mar reference3 reference4 auto bluish 1 2 3 4 5 6 auto bluish 1 2 3 4 5 6 auto reddish 1 2 3 4 5 6

so, have add together auto & bluish & act. & jan = 1+1 = 2. , other columns.

i accomplish follows:

reference3 reference4 reference1 reference2 value auto bluish act. jan 2 auto bluish act. feb 4

the problem have formula utilize in value column above. can not sumifs columns in original source table change. vlookup don't work there no single column lookup_value. thought using match identify column, have 2 references(1&2) doesn't work either.

any ideas on formula(s) utilize achive above.

thanks

try making pivot table info (this not create formulas, though, nevertheless give desired results).

here simple guide on doing in excel 2003 - http://www.techonthenet.com/excel/pivottbls/create.php

excel match vlookup sumifs

linux - Installing amd_64 or i386 packages on raspbian (arm hf) -



linux - Installing amd_64 or i386 packages on raspbian (arm hf) -

i trying install driver rfid reader on raspberry pi, pc/sc daemon can recognize reader when plug in. unfortunately, drivers packaged company i386 or amd64 architectures. on pi, raspian installed, believe architecture (armhf) unable install binaries.

i have heard there cross-architecture solutions, don't want break pi. can utilize dpkg --add-architecture add together amd64 supported architectures, , kosher? or bad idea? if so, recommended solution other "harass company made drivers!"

thanks much!

can utilize dpkg --add-architecture add together amd64 supported architectures, , kosher?

no, not work.

the raspberry pi uses arm cpu, uses arm instruction set. different instruction set used i386 , x86-64/amd64. if utilize dpkg --add-architecture you'll able install packages, cpu not able run installed code.

you have find drivers compiled arm cpu, or compile/develop them yourself. or supported hardware.

note:

dpkg --add-architecture meant cpus back upwards multiple instruction sets. think introduced x86-64 (i.e. 64bit) cpus, back upwards i386 (i.e. 32bit) instructions. allows install packages compiled i386 on scheme otherwise uses x86-64 packages.

linux raspberry-pi cpu-architecture raspbian

nullpointerexception - Liferay : Java NullPointer exception -



nullpointerexception - Liferay : Java NullPointer exception -

i deployed first liferay portlet, portlet not seem work. error on consol (i'm new java developement , liferay !) :

23:22:03,954 error [http-bio-8080-exec-10][render_portlet_jsp:132] null java.lang.nullpointerexception @ me.hicham.portlet_view.films.doedit(films.java:102)

in line 102 have :

if(mode.equalsignorecase("edit")) {...}

here films.java :

package me.hicham.portlet_view; import me.hicham.portlet_controller.film; import me.hicham.portlet_model.*; import javax.portlet.actionrequest; import javax.portlet.portletmode; import javax.portlet.portleturl; import javax.portlet.renderrequest; import javax.portlet.actionresponse; import javax.portlet.renderresponse; import javax.portlet.portletexception; import javax.portlet.windowstate; import com.liferay.util.bridges.mvc.mvcportlet; import java.io.ioexception; import javax.portlet.portletrequestdispatcher; public class films extends mvcportlet { public void doview(renderrequest request, renderresponse response) throws portletexception, ioexception { string nomfilm = request.getparameter("nom"); if (nomfilm == null ) { nomfilm=""; } string listefilm=""; portleturl renderurl = response.createrenderurl(); renderurl.setportletmode(portletmode.view); renderurl.setwindowstate(windowstate.maximized); renderurl.setwindowstate(windowstate.normal); listefilm=listefilm+"<div id=\"container\">"; listefilm=listefilm+"<form name=\"input\" action=\""+renderurl+"\" method=\"post\" class=\"zebra\">"; listefilm=listefilm+"<table>"; listefilm=listefilm+"<tr><td>nom:</td><td><input type=\"text\" name=\"nom\" value=\""+nomfilm+"\"></td></tr>"; listefilm=listefilm+"<tr><td></td><td><input type=\"submit\" value=\"rechercher\"></td></tr>"; listefilm=listefilm+"<table>"; listefilm=listefilm+"</form> "; seek { listefilm=listefilm+"\n<table class=\"zebra\">"; listefilm=listefilm+"\n<tr>"; listefilm=listefilm+"\n<td></td><td> nom </td><td> genre </td><td> synopsis </td><td> date sortie </td>"; listefilm=listefilm+"\n</tr>"; string id=""; (film cinema : mediadao.listertouslesfilms(nomfilm)) { id=string.valueof(film.getid_film()); portleturl renderurl2 = response.createrenderurl(); renderurl2.setportletmode(portletmode.edit); renderurl2.setwindowstate(windowstate.maximized); renderurl2.setwindowstate(windowstate.normal); renderurl2.setparameter("mode","edit"); renderurl2.setparameter("id",id); listefilm=listefilm+"\n<tr>"; listefilm=listefilm+"\n<td><a href=\""+renderurl2+"\"><img src=\"http://localhost:8080/html/themes/classic/images/common/edit.jpg\" alt=\"modifier\"/></a></td><td>"+film.getnom()+"</td><td>"+ mediadao.getgenre(film.getid_genre()).getlibelle()+"</td><td>"+film.getsynopsis()+"</td><td>"+film.getdatesortie()+"</td>"; listefilm=listefilm+"\n</tr>"; } listefilm=listefilm+"\n</table>"; portleturl renderurl2 = response.createrenderurl(); renderurl2.setportletmode(portletmode.edit); renderurl2.setwindowstate(windowstate.maximized); renderurl2.setwindowstate(windowstate.normal); renderurl2.setparameter("mode","add"); listefilm=listefilm+"\n<a href=\""+renderurl2+"\"><img src=\"http://localhost:8080/html/themes/classic/images/common/ajout.jpg\" alt=\"ajouter\"/></a>"; listefilm=listefilm+"</div>"; } grab (exception e) { // todo auto-generated grab block listefilm=listefilm+e.getmessage(); } request.setattribute("att",listefilm); response.setcontenttype("text/html"); portletrequestdispatcher dispatcher = getportletcontext().getrequestdispatcher("/web-inf/jsp/films_view.jsp"); dispatcher.include(request, response); } public void doedit(renderrequest request, renderresponse response) throws portletexception, ioexception { response.setcontenttype("text/html"); string mode=request.getparameter("mode"); request.setattribute("att1", mode); if(mode.equalsignorecase("edit")) { string chainehtml=" "; seek { string id_film="0"; id_film = request.getparameter("id"); cinema film = mediadao.getfilm(id_film); chainehtml=chainehtml+"\n<table class=\"zebra\">"; chainehtml=chainehtml+"\n<tr>"; chainehtml=chainehtml+"\n<td colspan=\"2\">modification</td>"; chainehtml=chainehtml+"\n</tr>"; chainehtml=chainehtml+"\n<tr><td><input type=\"hidden\" name=\"mode\" value=\"edit\"><input type=\"hidden\" name=\"id\" value=\""+film.getid_film()+"\">nom :</td><td><input type=\"text\" name=\"nom\" value=\""+film.getnom()+"\"></td></tr>"; chainehtml=chainehtml+"\n<tr><td>genre :</td><td><input type=\"text\" name=\"genre\" value=\""+ mediadao.getgenre(film.getid_genre()).getlibelle()+"\"></td></tr>"; chainehtml=chainehtml+"\n<tr><td>synopsis :</td><td><input type=\"text\" name=\"synopsis\" value=\""+film.getsynopsis()+"\"></td></tr>"; //chainehtml=chainehtml+"\n<tr><td>image :</td><td><input type=\"text\" name=\"image\" value=\""+film.getimage()+"\"></td></tr>"; chainehtml=chainehtml+"\n<tr><td>date sortie :</td><td><input type=\"text\" name=\"datesortie\" value=\""+film.getdatesortie()+"\"></td></tr>"; chainehtml=chainehtml+"\n<tr><td></td><td><input type=\"submit\" value=\"valider\"></td></tr>"; chainehtml=chainehtml+"\n</table>"; chainehtml=chainehtml+"\n"; } grab (exception e) { // todo auto-generated grab block chainehtml=chainehtml+e.getmessage(); } request.setattribute("att",chainehtml); } else { string chainehtml=""; seek { chainehtml=chainehtml+"\n<table class=\"zebra\">"; chainehtml=chainehtml+"\n<tr>"; chainehtml=chainehtml+"\n<td colspan=\"2\">insertion</td>"; chainehtml=chainehtml+"\n</tr>"; chainehtml=chainehtml+"\n<tr><td><input type=\"hidden\" name=\"mode\" value=\"add\"><input type=\"hidden\" name=\"id\" >nom :</td><td><input type=\"text\" name=\"nom\" ></td></tr>"; chainehtml=chainehtml+"\n<tr><td>genre :</td><td><input type=\"text\" name=\"genre\" ></td></tr>"; chainehtml=chainehtml+"\n<tr><td>synopsis :</td><td><input type=\"text\" name=\"synopsis\" ></td></tr>"; //chainehtml=chainehtml+"\n<tr><td>image :</td><td><input type=\"text\" name=\"image\" ></td></tr>"; chainehtml=chainehtml+"\n<tr><td>date sortie :</td><td><input type=\"text\" name=\"datesortie\" ></td></tr>"; chainehtml=chainehtml+"\n<tr><td></td><td><input type=\"submit\" value=\"valider\"></td></tr>"; chainehtml=chainehtml+"\n</table>"; chainehtml=chainehtml+"\n"; } grab (exception e) { // todo auto-generated grab block chainehtml=chainehtml+e.getmessage(); } request.setattribute("att",chainehtml); } portletrequestdispatcher dispatcher = getportletcontext().getrequestdispatcher("/web-inf/jsp/films_edit.jsp"); dispatcher.include(request, response); } public void dohelp(renderrequest request, renderresponse response) throws portletexception, ioexception { response.setcontenttype("text/html"); portletrequestdispatcher dispatcher = getportletcontext().getrequestdispatcher("/web-inf/jsp/films_help.jsp"); dispatcher.include(request, response); } public void processaction(actionrequest request, actionresponse response) throws portletexception, ioexception { seek { system.out.println("processaction"); string mode = request.getparameter("mode"); if(mode.equalsignorecase("edit")) { string id_film = request.getparameter("id"); string nom = request.getparameter("nom"); string genre = request.getparameter("genre"); string synopsis = request.getparameter("synopsis"); //string image = request.getparameter("image"); string datesortie = request.getparameter("datesortie"); system.out.println("begin...................."); mediadao._edit(id_film, nom, genre, synopsis, datesortie); system.out.println("end.................."); } else { string nom = request.getparameter("nom"); string genre = request.getparameter("genre"); string synopsis = request.getparameter("synopsis"); //string image = request.getparameter("image"); string datesortie = request.getparameter("datesortie"); system.out.println("begin...................."); mediadao._add( nom, genre, synopsis, datesortie); system.out.println("end.................."); } response.setportletmode(portletmode.edit); }catch (exception e) { e.printstacktrace(); system.err.println("process action err "+e.getmessage()); } } }

thank guys help.

this looks throw npe if don't include mode parameter.

string mode=request.getparameter("mode"); // returns null if mode isn't set. request.setattribute("att1", mode); if(mode.equalsignorecase("edit")) // can't phone call methods on null object.

you check if mode null before comparing "edit" or swap mode/"edit" since "edit" never null

if("edit".equalsignorecase(mode))

java nullpointerexception liferay