Monday, 15 February 2010

php - Yii webcam extension -



php - Yii webcam extension -

in yii,iam using yii-jpegcam webcam extension used taking photos in application , works fine next url format

index.php?r=user/newphoto

but application in "/" format (index.php/user/newphoto). extension not working url format. how can solved?

extension link used : http://www.yiiframew...on/yii-jpegcam/ http://www.yiiframework.com/extension/yii-jpegcam/

and view code :

<?php $onbeforesnap = "document.getelementbyid('upload_results').innerhtml = '<h1>uploading...</h1>';"; $completionhandler = <<<block if (msg == 'ok') { document.getelementbyid('upload_results').innerhtml = '<h1>ok! ...redirecting in 3 seconds</h1>'; // reset photographic camera shot webcam.reset(); settimeout(function(){window.location = "index.php?r=user/index";},3000); } else alert("php error: " + msg); block; $this->widget('application.extensions.jpegcam.ejpegcam', array( 'apiurl' => 'index.php?r=user/jpegcam.savejpg', 'shuttersound' => false, 'stealth' => true, 'buttons' => array( 'configure' => 'configure', 'takesnapshot' => 'take snapshot!' ), 'onbeforesnap' => $onbeforesnap, 'completionhandler' => $completionhandler )); ?>

if urlmanager enabled in config, should alter apiurl value createurl method :

$this->widget('application.extensions.jpegcam.ejpegcam', array( 'apiurl' => yii::app()->urlmanager->createurl('index.php/user/jpegcam.savejpg'), 'shuttersound' => false, 'stealth' => true, 'buttons' => array( 'configure' => 'configure', 'takesnapshot' => 'take snapshot!' ), 'onbeforesnap' => $onbeforesnap, 'completionhandler' => $completionhandler ));

php yii webcam yii-extensions yii-components

java - in working with ejb I have problems understanding something from the code below. it works perfect just confused about the lookup process(see code) -



java - in working with ejb I have problems understanding something from the code below. it works perfect just confused about the lookup process(see code) -

in working ejb have problems understanding code below. works perfect confused lookup process(see code)

import java.util.properties; import javax.naming.context; import javax.naming.initialcontext; import javax.naming.namingexception; import com.coolstory.thebeanremote; public class main { /** * @param args * @throws namingexception */ public static void main(string[] args) { // todo auto-generated method stub properties p= new properties(); p.put((context.provider_url) ,"t3://localhost:7001"); p.put((context.initial_context_factory),"weblogic.jndi.wlinitialcontextfactory"); seek { //create context , pass in properties contain lookup info context ctx= new initialcontext(p); thebeanremote bean= (thebeanremote)ctx.lookup("mrbean#com.coolstory.thebeanremote"); /*what pound sign function here confused */ string x= ctx.getenvironment().tostring(); system.out.println(x); bean.sayhi(); system.out.println("main.main()"+ bean.sayhi()); } grab (namingexception e) { // todo auto-generated grab block e.printstacktrace(); } }

the convention <ejb-name>#<interface-name>, # delimiter between ejb name , interface name.

java ejb-3.0 jndi

c++ - How to return a lambda function? -



c++ - How to return a lambda function? -

for example, can define lambda function as

auto f = [](double value) {double ratio = 100; homecoming value * ratio;}

now want generate function ratio argument , homecoming lambda function like

auto makelambda(double ratio) { homecoming [=](double value) {return value * ratio;}; }

how it?

with c++14 function homecoming type deduction, should work.

in c++11, define lambda (which can deduce homecoming type), rather function (which can't):

auto makelambda = [](double ratio) { homecoming [=](double value) {return value * ratio;}; };

as noted in comments, farther wrapped, if particularly want function:

auto makelambdafn(double ratio) -> decltype(makelambda(ratio)) { homecoming makelambda(ratio); }

c++ c++11 lambda

delphi - Trying to remove all vowels from a phrase -



delphi - Trying to remove all vowels from a phrase -

i trying create programme remove vowels sentence or phrase. don't syntax error, when add together word 'cool' or more 2 vowels next each other, not of them removed. why this? here code:

procedure tform1.btnprocessclick(sender: tobject); var sentence: string; k : integer; begin sentence :=uppercase(edtsentence.text); k := 1 length(sentence) if (sentence[k] in ['a', 'e', 'i', 'o', 'u']) begin delete(sentence,k,1); lbloutput.caption := sentence; end;

you counting when deleting instead of counting down.

your loop should read :-

for k := length(sentence.text) downto 1 do

delphi delphi-xe

C# Regex to C++ boost::regex -



C# Regex to C++ boost::regex -

i have requirement match strings in c++ code of form

l, n{1, 3}, n{1, 3}, n{1, 3}

where in above pseudo-code, l letter (upper or lower case) or fullstop (. character) , n numeric [0-9].

so explicitly, might have b, 999, 999, 999 or ., 8, 8, 8 number of numeric characters same after each , , either 1, 2 or 3 digits in length; d, 23, 232, 23 not possible.

in c# match follows

string s = " b,801, 801, 801 other stuff"; regex reg = new regex(@"[\.\w],\s*\d{1,3},\s*\d{1,3},\s*\d{1,3}"); match m = reg.match(s);

great. however, need similar regex using boost::regex. have attempted

std::string s = " b,801, 801, 801 other stuff"; boost::regex regex("[\\.\w],\s*\d{1,3},\s*\d{1,3},\s*\d{1,3}"); boost::match_results<std::string::const_iterator> results; boost::regex_match(s, results, regex);

but giving me 'w' : unrecognized character escape sequence , same s , d. documentation under impression can utilize \d, \s , \w without issue.

what doing wrong here?

edit. have switched std::regex as-per comment above. now, presumably regex same , next compiles regex does not match...

std::string p = "xx"; std::string s = " b,801, 801, 801 other stuff"; std::regex regex(r"del([\.\w],\s*\d{1,3},\s*\d{1,3},\s*\d{1,3})del"); if (std::regex_match(s, regex)) p = std::regex_replace(s, regex, "");

you can utilize \w, \s, , \d in regular expressions. however, that's not you're doing; you're trying utilize \w character in string. there \ followed w in actual string, need escape \ (same s , d, of course):

boost::regex regex("[\\.\\w],\\s*\\d{1,3},\\s*\\d{1,3},\\s*\\d{1,3}");

as of c++11, can utilize raw string literals create code more similar c# version:

boost::regex regex(r"del([\.\w],\s*\d{1,3},\s*\d{1,3},\s*\d{1,3})del");

c# c++ boost boost-regex

javascript - Rotate Polygon with Coordinates -



javascript - Rotate Polygon with Coordinates -

i trying rotate polygon (3 edges) (i have coordinates of edges). i'm using cos , sin new coordinates of every single point, doesn't work have no thought why.

http://jsfiddle.net/sh3rlock/gqk23/

(m middle-point of polygon , kr radius of circle)

newx = x + ((x - m[0]) * c - (y - m[1]) * s) * kr;

newy = y + ((y - m[1]) * c + (x - m[0]) * s) * kr;

function drawplayer(x, y, r, tcolor) { if (typeof c === "undefined") color = 'rgba(0,0,200,1)'; //canvas.width = canvas.width; var radians = r * (math.pi / 180); var m = getmiddleofpg([ [x, y + 5], [x, y - 5], [x + 15, y] ]); // mitte des polygons var = [x, y + 5]; var b = [x, y - 5]; var c = [x + 15, y]; drawpolygonfromarray([a, b, c], ctx, 'rgba(0,200,0,1)'); var speed = 1; var right = math.cos(radians) * 1; var = -(math.sin(radians) * 1); var x2 = x; var y2 = y; var c = math.cos(radians); var s = math.sin(radians); x = x2; y = y2 + 5; var kr = math.sqrt((x - m[0]) * (x - m[0]) + (y - m[1]) * (y - m[1])); var ax = x + ((x - m[0]) * c - (y - m[1]) * s) * kr; var ay = y + ((y - m[1]) * c + (x - m[0]) * s) * kr; x = x2; y = y2 - 5; kr = math.sqrt((x - m[0]) * (x - m[0]) + (y - m[1]) * (y - m[1])); var bx = x + ((x - m[0]) * c - (y - m[1]) * s) * kr; var = y + ((y - m[1]) * c + (x - m[0]) * s) * kr; x = x2 + 15; y = y2; kr = math.sqrt((x - m[0]) * (x - m[0]) + (y - m[1]) * (y - m[1])); var cx = x + ((x - m[0]) * c - (y - m[1]) * s) * kr; var cy = y + ((y - m[1]) * c + (x - m[0]) * s) * kr; x = x2; y = y2; var = [ax, ay]; var b = [bx, by]; var c = [cx, cy]; drawpolygonfromarray([a, b, c], ctx, tcolor); drawmiddleofpg([a, b, c], 'rgba(255,0,0,1)'); //drawmiddleofpg([[x,y],[x,y-5],[x+15,y]], 'rgba(0,255,0,1)'); //alert(right + " " + up); cr += 20; if (cr > 255) { cb += 20; cr = 0; } if (cb > 255) { cg += 20; cb = 0; cr = 0; } t = settimeout(function () { drawplayer(x, y, r + 1, 'rgba(' + cr + ',' + cb + ',' + cg + ',1)') }, 20); return;

javascript rotation polygon

android - ListView in Fragment won't refresh -



android - ListView in Fragment won't refresh -

i trying create list in fragment, able grow when pressing button.

the list within fragment.

here's part of mainactivity:

public class mainactivity extends fragmentactivity{

public static string[] values = { "" }; private static listview listview; public static notesdbadapter helper; public static arraylist<fragment> fragments; public static viewpager viewpager; public static custompageradapter pageradapter; public static customlistadapter listadapter; @override protected void oncreate(bundle arg0) { super.oncreate(arg0); setcontentview(r.layout.activity_main); viewpager = (viewpager)findviewbyid(r.id.viewpager); listadapter = new customlistadapter(this); helper = new notesdbadapter(this); helper.open(); pageradapter = new custompageradapter(getsupportfragmentmanager()); fragments = new arraylist<fragment>(); fragments.add(new listfragment()); log.d("debug", "helper count: " + integer.tostring(helper.fetchallnotes().getcount())); values = new string[helper.fetchallnotes().getcount()]; for(int = 0; < values.length; i++) { values[i] = "klappt"; } updatelist(); viewpager.setadapter(pageradapter); } public void addnote() { log.d("debug", "new note"); helper.createnote("", ""); updatelist(); } public class customlistadapter extends arrayadapter<string> { private context context; private int res; private textview textview; public customlistadapter(context context) { super(context, r.layout.list_item, values); this.context = context; this.res = r.layout.list_item; } @override public view getview(int position, view convertview, viewgroup parent) { layoutinflater inflater = (layoutinflater) context.getsystemservice(layout_inflater_service); view rowview = inflater.inflate(res, parent, false); textview = (textview)rowview.findviewbyid(r.id.list_item_textview); textview.settext(values[position]); homecoming rowview; } } public static class listfragment extends fragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.fragment_list, container, false); listview = (listview)v.findviewbyid(r.id.fragment_list_listview); listview.setadapter(listadapter); homecoming v; } } public void updatelist() { values = new string[helper.fetchallnotes().getcount()]; for(int = 0; < values.length; i++) { values[i] = "klappt"; } listadapter.notifydatasetchanged(); }

}

so add together item list pressing on actionbar item. works, can confirm that. see alter have leave app , re-enter see changes or alter screen orientation landscape , back. want immeadiately show updated list, don't know how.

listadapter.notifydatasetchanged();

does not work me, don't know why. tried create new listadapter so:

listadapter = new customlistadapter(getapplicationcontext());

and set listview adapter:

listview.setadapter(listadapter);

but forcefulness close (i don't know why).

so know haven't got thought how prepare problem. able refresh listview when calling updatelist() method.

i logcat when trying apply new adapter listview:

06-19 18:17:32.506: e/androidruntime(12259): java.lang.runtimeexception: unable start activity componentinfo{com.ochs.androidnotepad/com.ochs.androidnotepad.mainactivity}: java.lang.nullpointerexception

android listview android-fragments android-listview