Posts

Showing posts from June, 2013

c# - DTO's and calls between services -

say have 2 services in service layer, servicea , serviceb , each interface ( iservicea , iserviceb respectively). the ui layer has reference service interfaces return dtos methods. concrete service classes responsible mapping domain models (ef pocos) dtos. servicea takes dependency on iserviceb via dependency injection using ioc container, in order call methods on service. there couple of problems arise in doing this: unnecessary/duplicated mapping , dto call method and/or consume result. tightly coupling calling method dto contracts of called methods input parameters , return type. initially thought refactor logic down internal method , call both services. servicea takes dependency on interface iserviceb internal methods not exposed. how go dealing issue? further information (added example code requested): // domain model public class customer { public int id { get; set; } public string name { get; set; } } // dto domain model public class cust

c# - Sum using from clause (linq) -

i've got following command: var sum = mylist.sum(p => p.field); is possible write same command using clause? eg. var sum = mylist ... there no expression sum in notation. here close can get: var sum = (from p in mylist select p.field).sum();

css - jQuery UI Sortable items in one line should have the same height -

Image
i use jquery ui sortable sort teasers. problem ist, teasers include different amounts of text. (red text.) if there more 1 line of teasers happens: want this: teasers should have same height highest teaser in line. it's no option give them same height. maximum count of teasers per line 3. is there easier way measuring height of highest teaser per line , adjust height of other teasers jquery after each sort? $(function () { $('li').addclass('teaser'); $('.sortable').sortable(); $('#fixheights').click(function () { var heights = []; $('.teaser').each(function () { heights.push($(this).height()); }); heights.sort(); var tallest = heights.pop(); alert(tallest); // optional $('.teaser').each(function () { $(this).height(tallest); }) }); }); jsfiddle demo! is there easier way measuring height of highest teaser pe

hyperlink - How to "re-link" tables in VB.net? -

i'm new vb.net, , i'm having problem linking updated tables. link tables adding new data source, selecting tables, views, etc. meanwhile realize that, example, table "customers" needs have 2 new fields, have table "old" structure linked in dataset. how can link newly structured table on startup, or have re-link them manually?

java - Can't play the recorded file -

i'm making app records audio long imagebutton touched , held. achieved following code: public class mainactivity extends activity { mediarecorder recorder; mediaplayer mediaplayer; //storage paths string storagepath; string externalstoragepath; //full output paths string externaloutputpath; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //audio recorder recorder = new mediarecorder(); recorder.reset(); recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(mediarecorder.outputformat.three_gpp); recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb); if (environment.getexternalstoragestate().equals(environment.media_mounted)) { externalstoragepath = environment.getexternalstoragedirectory().getabsolutepath(); externaloutputpath = externalstoragepath + file.separator + "/android/data/c

objective c - What is the naming convention for methods you know will appear in a later SDK? -

i realize there subjectivity in question, considering apple development pretty opinionated naming conventions want in way others understand coding doing. trying ask question in generic way, i'll add of specific details in comments in case affects answer. let's supporting both ios 6 , ios 7. there new method on existing class exists in ios 7 sdk. assume implementing functionality in way "good enough" app straightforward. but, of course, i'd rather use sdk version better supported, more efficient, , better handle edge cases. as documented in this q&a straightforward handle situation. if ([myinstance respondstoselector:@selector(newselector)]) { //use sdk method } else { //use "good enough" implementation. } but don't want litter code whole bunch of conditional invocations. seems better encapsulate dynamic method selection. (especially in case, method hasn't shipped yet , name/signature might change.) my instinct add class

Storing a 7millions keys python dictionary in a database -

i have handle 7 millions keys dictionary (the number of keys can ~50 millions). since have barely enough ram keep in memory i've decided store it. my dictionary looks this: dictionary={(int1,int2):int3,...} first tried store in sqlite database using sqlite3. amount of time required store ok (around 70 secs). using timeit : >>>import sqlite3 >>>conn=sqlite3.connect('test_sqlite.sqlite') >>>c=conn.cursor() >>>c.execute('create table test (int1 int, int2 int, int3 int)') >>>conn.commit() >>>conn.close() >>>import timeit >>>timeit.timeit('c.executemany("insert test values (?,?,?)",((key[0],key[1],dictionary[key]) key in dictionary.iterkeys())),setup='import sqlite3;conn=sqlite3.connect("test_sqlite.sqlite");c=conn.cursor();dictionary={(i,i+1):i+2 in xrange(7000000)}',number=1) 70.7033872604 but then, need use stored dictionary in order retrieve values, e

linux - How to delete the rest of the records after a pattern which occurred for the second time in a .CSV file -

i have .csv file has few records after header, however, there duplicate header before end of file , after duplicate header few more records(which not need). there way check pattern of header occurred second time , delete rest of file after duplicate header? below example of file. col0,col1, col2, col3 , col4 , col5, col6 , 1value0,1value1,1value2,1value3,1value4,1value5,1value6, 2value0, 2value1, 2value2, 2value3, 2value4, 2value5, 2value6, 3value, 3value1, 3value2, 3value3, 3value4, 3value5, 3value6, 2value0, 4value1, 4value2, 4value3, 4value4, 4value5, 4value6, 5value0, 5value1, 5value2, 5value3, 5value4, 5value5, 5value6, 6value0, 6value1, 6value2, 6value3, 6value4, 6value5, 6value6, ,,,,,,, ,,,,,,, ,,,,,,, (n-1)value0, (n-1)value1, (n-1)value2, (n-1)value3, (n-1)value4, (n-1)value5, (n-1)value6, (n)value0, (n)value1, (n)value2, (n)value3, (n)value4, (n)value5, (n)value6, col0,col1, col2, col3 , col4 , col

java - Eclipse Hibernate configurations pane does not display new Table -

i writing eclipse java application using hibernate plugin. i've started out creating schema in mysql workbench, , using hibernate plugin auto-generate .hbm files , pojo code. recently, added new table, , columns in 1 of existing tables. i got hibernate configurations pane refresh, , display columns in existing table, missing new table created! (incidentally, verified schema built under mysql workbench). does know quick method getting eclipse hibernate include new table in configurations pane? thanks. ok guys, figured out... not problem hibernate @ all. the privileges set new table not set correctly in mysql schema - hence hibernate pane not see new table. thanks.

Unix sendmail - html embed image not working -

with prior posts in so.com have tried building script send email outlook account image inline in email body. html contents getting displayed in html rather displaying image. please help. here snippet { echo "to: xxx@yyy.com" echo "from: test_image@yyy.com>" echo "subject: embed image test" echo "mime-version: 1.0" echo "content-type: multipart/related;boundary="--xyz"" echo "--xyz" echo "content-type: text/html; charset=iso-8859-15" echo "content-transfer-encoding: 7bit" echo "<html>" echo "<head>" echo "<meta http-equiv="content-type" content="text/html; charset=iso-8859-15">" echo "</head>" echo "<body bgcolor="#ffffff" text="#000000">" echo "<img src="cid:part1.06090408.01060107" alt="">" echo "</body>" echo "

Paypal Payments Pro - Advanced Fraud Protection not working -

i need annoying problem. have paypal payments pro account , use paypal_merchant_sdk (.net) process direct payments on our site via api calls using live credentials got paypal.com. have been live several months, transactions processing successfully. now want small change way accept payments. want reject transactions wrong cv2 code. after calls paypal support told needed advanced fraud protection added our manager account (manager.paypal.com). added , set "csc failure" fraud filter reject transactions on non-matches , deployed live (active mode). status messages deployed successfully. waited several hours , tested, didn't work - still processes transactions wrong cv2 code , message "this transaction approved. however, card security code provided had few, many, or invalid character types but, per account option settings, not required in approval process." can tell me why csc failure setting not working , how working? edit : ok, on phone paypal support aga

asp.net - Image from localhost does not appear inside of Telerik RadImageEditor -

when load radimageeditor using image localhost, image not appear inside of control. tested loading image true domain, , image loads. any ideas? .aspx <telerik:radimageeditor id="rieimagecrop" runat="server" width="720px" height="720px"> <tools><telerik:imageeditortoolgroup> <telerik:imageeditortoolstrip commandname="undo"> </telerik:imageeditortoolstrip> <telerik:imageeditortoolstrip commandname="redo"> </telerik:imageeditortoolstrip> <telerik:imageeditortoolseparator></telerik:imageeditortoolseparator> <telerik:imageeditortool commandname="crop"></telerik:imageeditortool> </telerik:imageeditortoolgroup> </tools> </telerik:radimageeditor> code behind string host = httpcontext.current.request.servervariables["http_host"]; newimage = "http://" + host + p

Facebook interaction between different apps possible? -

is there possibility exchange information 1 app via facebook? instance receive information of whether fb user made interaction app? background question want reward users activities, not on facebook on different fb apps. ideas? guess chances low. best regards, phil

internet explorer - Sencha-Touch 2.2.1 Simple drag works on Webkit browsers but not IE 10 -

i have complex application uses drag , drop in sencha 2.2.1 - works brilliant on webkit browsers, sencha touch supports ie 10 wanted try it. i not drag working, started simple test scratch. i built new "hello world" app using sencha cmd generate , used main.js see below. can drag inner panel in webkit browsers no problem, inner panel not show in ie 10. tried days, can't quite figure out how new ext.util.translatable deal works , how supposed work in ie 10. (environment: win 7 64 bit; sencha 2.2.1 commercial sdk; sencha cmd v3.1.2.342; build package 'sencha app build package' , run index.html file folder w/ no webserver) view\main.js: ext.define('mytest.view.main', { extend: 'ext.tab.panel', xtype: 'main', requires: [ 'ext.titlebar', 'ext.video', 'ext.util.draggable' ], config: { tabbarposition: 'bottom', items: [ { title: 'welcome', ico

three.js - How can I create a specular with a specular map on a custom shader in three js? -

i creating earth in webgl using three.js, , far have earth day , night texture , atmosphere. finish off, want add specular earth shows on water sections. now, have specular map this, can't seem puzzle together. i'm doing in custom shader because of earth/night/atmosphere-thingy, , read have include specular calculation in equation, since three.js can't stack multiple shaders. this shader, , i'm stuck @ specular part: <script id="earthfragmentshader" type="x-shader/x-fragment"> uniform sampler2d daytexture; uniform sampler2d nighttexture; uniform sampler2d speculartexture; uniform vec3 sundirection; varying vec3 vnormal; varying vec2 vuv; void main() { // textures day , night: vec3 daycolor = texture2d( daytexture, vuv ).xyz; vec3 nightcolor = texture2d( nighttexture, vuv ).xyz; // compute cosine sun normal -1 away sun , +1 toward sun. float cosineanglesunto

android - Service is not starting -

i have written service streaming url. there twitter button open link browser. when clicked button start service in button event, not starting. service's codes here; public class mymediaplayerservice extends service implements onbufferingupdatelistener, oncompletionlistener, onpreparedlistener, onvideosizechangedlistener, surfaceholder.callback { private string path = "http://someurl.m3u8"; private mediaplayer mmediaplayer; private static final string media = "media";; private boolean misvideosizeknown = false; private boolean misvideoreadytobeplayed = false; private int mvideowidth; private int mvideoheight; @override public ibinder onbind(intent intent) { return null; } @override public void oncreate() { super.oncreate(); mmediaplayer = new mediaplayer(this); } public void onbufferingupdate(mediaplayer arg0, int percent) { } public void oncompletion(mediaplayer arg0) { } public void onvideosizechanged(mediaplayer mp, int width,

python - Scheduler going idle under multithreading -

i'm running python 3.3.2, win7/pro, 64-bit , have code in i'm trying run scheduler in own thread. appears when scheduler empties working queue, goes idle , not resume when new entry added queue. it's not obvious me docs supposed resume, not expect user code (running in thread outside control of scheduler) have worry possibility of scheduler has "finished". suspect there i'm not understanding and/or i'm misusing somehow, don't know where. in example below, solved problem replacing scheduler's enter method own checks queue length , if zero, enters request , calls scheduler's run method again. seem work, feels wrong. there i'm missing? class a(threading.thread): def __init__(self): super().__init__() self.schedcontrol = sched.scheduler(time.time, time.sleep) self.senter = self.schedcontrol.enter self.schedcontrol.enter = self.enter def print_time(self, a=''): ""

scala - Is there any difference between this syntax of curried functions? -

another scala newbie question. trying find difference between: def _1_sumuntil(n: int) = (f: int => int) => (0 n).tolist.foldleft(0){(a,b) => + f(b)} and def _2_sumuntil(n: int)(f: int => int) = (0 n).tolist.foldleft(0){(a,b) => + f(b)} what advantage of 1 on other (if @ all) ? the first method 1 parameter list returns function int => int int , second method 2 parameter lists returns int . technically, means of called eta-expansion—a method can transparently converted function value—, second method can partially applied, yielding same function first method: val = _1_sumuntil(33) // (int => int) => int val b = _2_sumuntil(33) _ // (int => int) => int via eta-expansion my advise use second variant , avoid explicit function values. advantage of second that—unless do use eta-expansion—no function value instantiated (apart function passed foldleft ) applied. arguably easier read. i use first version if main purpose of meth

c++ - Transforming pass-by reference into pass-by return -

i have following function: void read_int(std::vector<int> &myvector) which allows me fill myvector through reference. used this: std::vector<int> myvector; read_int(myvector); i want refactor bit code (keeping original function) in end have this: auto myvector = read_int(); // auto std::vector<int> what best intermediate function achieve this? it seems me following straight-forward answer suboptimal: std::vector<int> read_int() { std::vector<int> myvector_temp; read_int(myvector_temp); return myvector_temp; } the obvious answer correct, , optimal. void do_stuff(std::vector<int>& on_this); // (1) std::vector<int> do_stuff_better() { // (2) std::vector<int> myvector_temp; // (3) do_stuff(myvector_temp); // (4) return myvector_temp; // (5) } at (3) create named return value in automatic storage (on stack). at (5)

powershell - how to find all .bat files and execute them one by one? -

i still new powershell , need help. i have .bat files in folder called: c:\scripts\run\ , want run them 1 one don't know how many have, changes time time. so want run loop foreach this: foreach ($file in get-childitem c:\scripts\run | {$_.extension -eq ".bat"}) but don't know how run them now. know can run them 1 1 : ./run1.bat ./run2.bat ./run3.bat but how implement that? thanks!! try this: get-childitem -path c:\scripts\run -filter *.bat | % {& $_.fullname}

c# - How to get ScriptManager to work with ScriptmanagerProxy -

i have been dealing unusual set of errors when try compile asp.net page. page inheriting masterpage. should getting scriptmanager there. errors getting suggest not. now have in page: <%@ page title="massupdate" language="c#" masterpagefile="~/site1.master" autoeventwireup="true" codebehind="update.aspx.cs" inherits="adminsite.update" maintainscrollpositiononpostback="true" %> <asp:content id="content2" contentplaceholderid="maincontent" runat="server" > <div id="contentarea"> <div> <h3 style="color:red; padding-left:5px;"> warning - page can push large amounts of data database. use care when using it! </h3> </div> <asp:scriptmanagerproxy runat="server"

android - How can I convert a string with integers to array with integers in java? -

i want convert string integers array integers in java. how can this?i have array strings.every string integers. want access every string click button. string[] int_array={ //0 "250,125,20,20,20,40,20,20,20,40,20,20,20,2500", //1 "233,63,28,63,29,63,28,16,28,17,26,63,29,17,26,16.... ........ } public void onclick(view v) { counter++; string intstring = int_array[counter]; string[] parts = intstring.split(","); final int[] = new int[parts.length()]; for(int i=0; i<parts.length(); i++){ a[i] = integer.parseint(parts(i)); toast.maketext(getapplicationcontext(),string.valueof(a[i]), toast.length_short).show(); } } private integer[] splitintegers(string s){ object[] numbersasstring = s.split(","); return arrays.copyof(numbersasstring

html - What format do the most browsers support? -

i uploaded mp3 audio website, because of format browsers or operating systems not support it, format browser support convert audio that? according w3schools , here chart shows browsers support each file: browser mp3 wav ogg internet explorer 9+ yes no no chrome 6+ yes yes yes firefox 3.6+ no yes yes safari 5+ yes yes no opera 10+ no yes yes

c++ - Store class member function in a template -

i need store member function pointer somewhere: void class1::function1(int a, int b) { ... } struct parameters { int a; int b; } mystoreclass.store(&class1::function1, parameters); and able call later this: mystoreclass.call(); so function called appropriate parameters. since it's member function suppose should store class1 object pointer too, how can store member function pointer template? you need parameterize type of object member function on, , pass pointer function. in order call member function need pass pointer object, , parameters call. here sample: class foo { public: void doit (int a, int b) { } }; class bar { public: void doitagain (int x, int y) { } }; template <typename obj> void dosomething (obj* that, void (obj::*fnthat)(int,int), int i, int j) { (that->*fnthat)(i, j); } int main() { foo foo; bar bar; void (foo::*fnfoo)(int,int) = &foo::doit; (foo.*fn

neo4j - Aggregating relationship properties on a path -

i'm trying to sum of weights on each path match finds. query below: start n=node(10200) match p=(n)-[r*1..5]->(m:facility) reduce(weights=0, rel in r : weights + rel.weight) weight_sum all(n in nodes(p) 1=length(filter(m in nodes(p) : m=n))) return p paths, length(p) pc, (weight_sum / (length(p) * (length(p) / 2))) sp; every time run it, i'm getting... unknown identifier `p` if remove line (and weight_sum return value), query knows 'p' , executes fine. there problem query value of 'p' being lost? there better alternative sum of these relationship properties? you can pipe "p" next part of query via with: start n=node(10200) match p=(n)-[r*1..5]->(m:facility) reduce(weights=0, rel in r : weights + rel.weight) weight_sum, p all(n in nodes(p) 1=length(filter(m in nodes(p) : m=n))) return p paths, length(p) pc, (weight_sum / (length(p) * (length(p) / 2))) sp;

How do I resolve sys.path differences in Python and IronPython -

i running pathing issues scripts wrote test parsers i've written. appear python (27 , 3) both not act ironpython when comes using current working directory part of sys.path. result inner package pathings not work. this package layout. mypackage __init__.py _test __init__.py common.py parsers __init__.py _test my_test.py i attempting call scripts within mypackage directory. command line statements: python ./parsers/_test/my_test.py ipy ./parsers/_test/my_test.py the import statement located in my_test.py file is. from _test.common import testclass in python scenario mypackage/parsers/_test directory appended sys.path result mypackage cannot found. in ironpython scenario both mypackage/parsers/_test directory , mypackage/ in sys.path. same bad reference if called test within _test directory (it have no idea mypackage). if consolidated test files _test directory still have pathing issue. i should note, tested , if did like

CakePHP redirect routing -

in cakephp 2.3 application, want example.com/come/harry redirect example.com/myworks/people/harry . this works, connects. router::connect ('/come/:myname', array('controller' => 'myworks', 'action' => 'people'), array( 'pass' => array('myname') ) ); i need 301 redirection. tried this: router::redirect ('/come/:myname', array('controller' => 'myworks', 'action' => 'people'), array( 'pass' => array('myname') ) ); but redirected example.com/myworks/people/ . how can pass argument action while redirecting ? per the documentation want use persist rather pass redirects. code should work want: router::redirect ('/come/*', array('controller' => 'myworks', 'action' => 'people', '?' => array('processed' => 1)), arra

ios - ABPersonSocialProfile crash app -

i have problem adding new social profiles abrecordref. return crash on abadressbooksave "[__nscfstring count]: unrecognized selector sent instance" abmultivalueref social = abmultivaluecreatemutable(kabmultidictionarypropertytype); if(contact.socialtwitter != nil) abmultivalueaddvalueandlabel(social, (__bridge cftyperef)([nsdictionary dictionarywithobjectsandkeys: (nsstring*)kabpersonsocialprofileservicetwitter, kabpersonsocialprofileservicekey, (__bridge cfstringref)contact.socialtwitter, kabpersonsocialprofileusernamekey, nil]), kabpersonsocialprofileservicetwitter, null); abrecordsetvalue(record, kabpersonsocialprofileproperty, social, &error); cfrelease(social); i had same issue while saving new contact. seems can't save attributes this. below code worked me

PHP after submit on a form how to I keep the button appropriate checked -

i building calculator , done. on form have 2 radio buttons on top either s.a.e units or metric units. when click calculate works inn calculator radio button check goes being unchecked. if clicks on metric , clicks submit how keep metric radio button checked after results, same sae? here whole code: <?php if (isset($_post['units'])) $units = $_post['units']; if (isset($_post['dia'])) $dia = $_post['dia']; if (isset($_post['wt'])) $wt = $_post['wt']; if (isset($_post['l'])) $l = $_post['l']; if (isset($_post['num'])) $num = $_post['num']; if (isset($_post['waste'])) $waste = $_post['waste']; if (isset($_post['surface'])) $surface = $_post['surface']; $denom = ($units == "us" ? 12 : 100); $coverage = ($units == "us" ? 1000 : 92.9); //$measurements = ($units == "us" ? "in" : "cm"); $measurements == $units; if($units =

javascript - How to check event Listeners on an element in IE9 -

i have page has td elements in table user can click , drag reorder. page built using prototype. in ie9, works, in ie9, when try click , drag, highlight of things on page. suspicion handler isn't attaching td element. is there way check listeners attached element in ie9? (the code not in place can share it, why have not posted any.) edit: turns out using prototype 1.6.1, , problem caused not knowing ie9 , ie10 less awful < 9. it's going bigger fix thought. the latest prototypejs (1.7.1) stores event observers in event cache so example <div> id 'mydiv' <div id="mydiv"></div> after create observer via observe() or on() methods this $('mydiv').observe('click',function(){ alert('click happened'); }); the click property of event cache set below event.cache[$('mydiv')._prototypeuid].click however might not source of problem said working in other browsers except ie9 - ther

ubuntu - debugging a php.ini syntax error -

i have vm ubuntu 12.04 , running apache2 web server. i've installed php 5.3.10 , every time run php application, php.ini throws error: php: syntax error, unexpected bool_false in /etc/php5/cli/php.ini on line 1020 i'd expect wasn't commented out correctly in php.ini when @ it, can't see what's wrong: 1007 [pcre] 1008 ;pcre library backtracking limit. 1009 ; http://php.net/pcre.backtrack-limit 1010 ;pcre.backtrack_limit=100000 1011 1012 ;pcre library recursion limit. 1013 ;please note if set value high number may consume 1014 ;the available process stack , crash php (due reaching 1015 ;stack size limit imposed operating system). 1016 ; http://php.net/pcre.recursion-limit 1017 ;pcre.recursion_limit=100000 1018 1019 [pdo] 1020 ; whether pool odbc connections. can 1 of "strict", "relaxed" or "off" 1021 ; http://php.net/pdo-odbc.connection-pooling 1022 ;pdo_odbc.connection_pooling=strict 1023 1024 ;pdo_odbc.db2_instance_name 1

android - Splash screen displays white screen and then black before it sets the menu page -

my app has splash screen animated logo(using thread) , menu page displayed. now want background activity in splash screen. want convert images string etc. i have placed code in oncreate() function. problem instead of splash screen see blank white screen , black screen. after sometime menu page displayed usual. if comment code of background processing functions perfectly. background code working correctly. not working together. there no errors in logcat , unable know wrong. please help. urgent... thanks. java code of splash screen public class splash extends activity { protected int _splashtime = 10000; private thread splashtread; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //makefolder(); this.requestwindowfeature(window.feature_no_title); //remove notification bar this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layo

iphone - iOS: EKEventStore sources / defaultCalendarForNewEvents / calendarsForEntityType all return nothing AFTER authorization -

i have app trying out door. code written ios5 in mind team. added requestaccesstoentitytype:completion: call runs successfully. however, after being granted access, no sources / defaultcalendar or calendars based on entity. , cannot create new calendar. when calling defaultcalendarfornewevents error error domain=ekcaderrordomain code=1013 "the operation couldn’t completed. (ekcaderrordomain error 1013.)" , result nil. if out of viewcontroller trying , go in, works fine. if, after getting alert no source, keep trying (without backing out viewcontroller), repeatedly fails. i want stress, authorization call works (the user asked access calendars , gives it, , later calls confirm authorization pass). other questions have found similar have solution -- making sure requestaccesstoentitytype [eventstore requestaccesstoentitytype:ekentitytypeevent completion:^(bool granted, nserror *error) { if (granted) { //[self performselectoronmainthread:

php - Safe to use strpos with UTF-8 strings? -

i have bunch of strings different charsets. $charset variable contains charset of current string. $content = iconv($charset, 'utf-8', $content); with done, safe use strpos , strlen , substr etcetera , not multibyte equivalent? i'm asking because use preg_match lot well. if use preg_offset_capture position of word in string can't use value mb_substr remove before word. that entirely depends on want do. core strlen , similar functions work on bytes . every number accept , return byte count or byte offset. mb_* functions work encoding-aware on characters . numbers accept , return character counts or offsets. if have safe way of getting byte offset in string ("safe" meaning offset not in middle of multi-byte character) , then, example, crop before offset using substr , that'll work fine. instance: $str = '漢字'; $offset = strpos($str, '字'); $cropped = substr($str, $offset); works fine. however, won't work:

elisp - Changing key bindings in emacs -

i want change commands setting bookmarks, listing them , finding them in emacs. emacs lisp code have tried: (global-set-key (kbd "c-c c-z") (kbd "c-x r m")) this failing. correct method? if want define key other key does, want do (global-set-key (kbd "c-c c-z") (global-key-binding (kbd "c-x r m"))) if can rebind c-x r m else , c-c c-z still bound bookmark-set (this similar file copying). if, on other hand, want make c-c c-z alias c-x r m , need use function-key-map : (define-key function-key-map (kbd "c-c c-z") (kbd "c-x r m")) in case c-c c-z doing whatever c-x r m doing if rebind latter (this similar symbolic file links).

user interface - Android Fixed Tabs on a Processing PApplet -

i developing android app based on processing i show 2 fixed tabs content when menu button pressed. tab1 contain settings , maybe button tab2 should have listview show list of presets. trying create 2 textviews sake of simplicity. trying approach of ketai library ketailist there's inner class extends tabhost inside papplet class extended application: public class myprocessingapp extends papplet { public void setup() { } public void draw() { } public void keypressed() { if (key == coded) { if (keycode == keyevent.keycode_menu) { tabhost th = new gbtab(this); } } } public class gbtab extends tabhost { private papplet parent; tabhost self; tabwidget tab1, tab2; linearlayout layout; public gbtab(papplet _parent) { super(_parent.getapplicationcontext()); parent = _parent; init(); } public void init() { println("gbtab init"); self = this; layout = new li

python - user_id not in auth_user table after changing UserModel -

i have had normal custom user model. have many users in database , other models pointing user model. changed user model inherits django's user model. i did this: from django.contrib.auth.models import user class userprofile(user): #custom fields... ... and tried migrate. giving me error saying (user_id)=(9) not in auth_user table. because other models pointing auth_user , auth_user new , doesnot contain user id 9. i have many data in db, stuck. do?

Chrome issue : Enable/Disable sorting on columns fails in chrome in GWT -

i using celltable gwt. when user click on column header sort, disable sorting untill data retrieved. this, using following code: private void setheaderssortable(boolean enable) { if (_table.getcolumncount() > 0) { if (enable) { // enable columns specified in _sortpropertybycolumn iterator<column<t, ?>> sortablecolsiter = _sortpropertybycolumn.keyset().iterator(); while (sortablecolsiter.hasnext()) { sortablecolsiter.next().setsortable(enable); } } else { // disable columns (int = 0; < _table.getcolumncount(); i++) { _table.getcolumn(i).setsortable(enable); } } _table.redrawheaders(); } } this works fine in firefox , ie not in chrome. it seems in chrome, fails in _table.redrawheaders(). call fails in gwt class abstracthasdata throws indexoutofboundsexception protected void checkrowbounds(int row) { if (!isrowwithinbounds(row)) { throw new inde

powershell - Why Does Get-ADObject Not Filter ObjectClass="user" Correctly? -

problem get-adobject -filter {objectclass = "user"} returns both users , computers. object classes display correctly "user" or "computer". get-adobject -filter {objectclass = "computer"} returns computers. other observations get-adobject "cn=desktop1,cn=computers,dc=contoso,dc=com" ` | get-member -property objectclass returns typename: microsoft.activedirectory.management.adobject name membertype definition ---- ---------- ---------- objectclass property system.string objectclass {get;set;} furthermore, returns false , expected: $(get-adobject "cn=desktop1,cn=computers,dc=contoso,dc=com").objectclass -eq "user" queries objectclass=user return user and computer objects, because computer class derived user class. if want user objects, filter objectclass=user and objectcategory=person . see here .

java - SSLPeerUnverifiedException: peer not authenticated in eclipse but not intellij -

so have code interfaces external rest service. imported ssl cert java keystore , unit tests work fine...while i'm using intellij. other members on team use eclipse , though cert in keystore dreaded peer not authenticated exception. even on computer certs in chain in keystore works in intellij not eclipse. my great google skills have failed me on one. me, stackoverflow, you're hope. eclipse stack trace javax.net.ssl.sslpeerunverifiedexception: peer not authenticated @ sun.security.ssl.sslsessionimpl.getpeercertificates(unknown source) @ org.apache.http.conn.ssl.abstractverifier.verify(abstractverifier.java:126) @ org.apache.http.conn.ssl.sslsocketfactory.connectsocket(sslsocketfactory.java:437) @ org.apache.http.impl.conn.defaultclientconnectionoperator.openconnection(defaultclientconnectionoperator.java:180) @ org.apache.http.impl.conn.managedclientconnectionimpl.open(managedclientconnectionimpl.java:294) @ org.apache.http.impl.client.defaul

Add extra link to google custom search engine result -

i need build search results page, using google custom search engine. problem though need add link or icon each item in search result. it icon generate custom short-link particular result. what best way go doing that? if want add html , stuff google result, couldn't use simple google custom search engine. you should use google search api, , process results , display them screen.

responsive design - Fix menu on the background image position -

it's problem: http://jsfiddle.net/vqa7v/ body { background: url("http://imgs.ir/imgs/201307/1336_menu.png") no-repeat scroll center top transparent; } #menu { display: block; height: 193px; margin: auto; position: relative; top: 32px; width: 400px; } nav { left: 0; min-width: 426px; position: absolute; text-align: center; top: 79px; } nav { padding: 5px 7px; color:white; } <div id="menu"> <nav> <a href="#">home</a> <a href="#">services</a> <a href="#">about</a> <a href="#">blog</a> <a href="#">contact</a> </nav> </div> at first, menu fit background position, make result window smaller & smaller see when menu out of background position. how avoid , fix menu background image position? (i want have menu in center of website on background image) had real tro

java - Easiest way to build a Karaf plugin -

i have prior java coding experience not knowledge of whole diverse java ecosystem. have been tasked develop small karaf plugin huge system. system utilizing countless of java goodies: camel, karaf, maven , whatnot. have example code need minor changes in , rebuild. the example maven project (atleast there pom.xml) , should karaf plugin in end. easiest way changes example , rebuild plugin? have never used of above before , changes small installing , configuring alot of stuff seems bit overkill. where start? :) i agree tech-idiot, best bet spending time karaf-maven-plugin , can set bundle hand, @ least realize achieved of maven plugin (specially if have lot of dependencies). a basic osgi bundle (what refer "plugin"), nothing else jar file special plain text file in there, manifest.mf file. the manifest.mf describes bundle, name, description, how want activate it, , bundle requires run (its dependencies, or imports ), has offer other bundles (its exports