Posts

Showing posts from April, 2013

ios - drawInRect: losing Quality of Image resolution -

ios - drawInRect: losing Quality of Image resolution - i trying erase image using next code cgcolorref strokecolor = [uicolor whitecolor].cgcolor; uigraphicsbeginimagecontext(imgforeground.frame.size); cgcontextref context = uigraphicsgetcurrentcontext(); [imgforeground.image drawinrect:cgrectmake(0, 0, imgforeground.frame.size.width, imgforeground.frame.size.height)]; cgcontextsetlinecap(context, kcglinecapround); cgcontextsetlinewidth(context, 10); cgcontextsetstrokecolorwithcolor(context, strokecolor); cgcontextsetblendmode(context, kcgblendmodeclear); cgcontextbeginpath(context); cgcontextmovetopoint(context, lastpoint.x, lastpoint.y); cgcontextaddlinetopoint(context, currentpoint.x, currentpoint.y); cgcontextstrokepath(context); imgforeground.image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); but find out image losing resolution due drawinrect. you should go uigraphicsbeginimagecontextwithoptions instead o...

android - How to prevent Thread.Sleep in onDraw affecting other Activities? -

android - How to prevent Thread.Sleep in onDraw affecting other Activities? - i have custom view class drawing images. problem when utilize thread.sleep(200); in ondraw method, affects xml elements in same activity. have wait 200 miliseconds untill happens. mainpage extends activity implements onclicklistener{ oncreate(...){ relativelayout rl = (relativelayout) findviewbyid(r.id.main_rl); rl.addview(new customview(this)); } onclick(view v){ switch(v.getid){ ... }; } } customview extends view{ ondraw(){ try{ thread.sleep(200); .... } } } any help appreciated. never run long operations in ui listener callback (or anywhere else runs on ui thread) in android. instead, create new thread perform sleep , whatever needs done. remember if want interact ui again, need within ui thread, can schedule calling runonuithread() . customview extends view{ ondraw(){...

Is this a JavaScript counter? -

Is this a JavaScript counter? - i've seen pattern on place, i'm not sure does: x.memb = x.memb ? x.memb + 1 : 1; i think it's counter i'm not sure. can explain , logic? if x.memb defined , isn't 0 , increments it. in other cases, sets value 1 . it's increment taking care of case x.memb isn't defined. you have written as x.memb = (x.memb||0) +1; which might more idiomatic value||defaultvalue usual build in javascript. javascript counter

python type function for built-in types -

python type function for built-in types - i see can utilize type create object @ runtime using class name type('foo',(object,), dict(x=1)) how can int or str or datetimetype. type('datetimetype', (object,), dict(???) what dict value be? storing tuple(row) db query csv. when read back, want convert original tuple can utilize existing functions process tuple. read back joe,23,dec 11 2001 i have saved type string of each type know cast to. python python-2.7

Transaction undefined error when creating object store in indexedDB -

Transaction undefined error when creating object store in indexedDB - i have problem code hope can help me with. i've set .open , it's next code (unupgradeneede, onsuccess, onerror aso.) in js file , phone call js file. seems code openingen indexeddb , creating object stores never executes. code window.indexeddb = window.indexeddb || window.mozindexeddb || window.webkitindexeddb || window.msindexeddb; contosodata = { db: null, usedb: function (successcallback) { var request = window.indexeddb.open("contosodata", 2); request.onsuccess = function (e) { contosodata.db = request.result; console.log('indexeddb.success'); successcallback(); }; request.onupgradeneeded = function (e) { console.log('indexeddb.upgradeneeded'); contosodata.db = e.target.result; if (contosodata.db.objectstorenames.contains("bookingstore")) ...

php - Use method of parent class when extending -

php - Use method of parent class when extending - probably silly question.. how correctly utilize methods of class test in class testb without overriding them? <?php class test { private $name; public function __construct($name) { $this->name = $name; } public function getname() { homecoming $this->name; } } <?php class testb extends test { public function __construct() { parent::__construct($name); } } <?php include('test.php'); include('testb.php'); $a = new test('john'); $b = new testb('batman'); echo $b->getname(); you need give testb constructor $name parameter if want able initialize argument. modified testb class constructor takes argument. way have it, should not able initialize testb class. utilize code follows: <?php class test { private $name; public function __construct($name) { $this->name = $name; } pu...

javascript regex duplicates parenthesis -

javascript regex duplicates parenthesis - i want replace ...('2073')... ....('2074')... end ...(('2074'))... , can't understand why. given next javascript code: var sgroupidentifier = "2073"; var sselectedgrouptr = "... onclick=\"makenewgroup('2073')\">new</a> ... "; var rex = new regexp("\('" + sgroupidentifier + "'\)", "g") snewgroupidentifier = "2074"; var snewgrouptr = sselectedgrouptr.replace(rex, "(\'" + snewgroupidentifier + "\')"); alert(snewgrouptr) of course of study can remove parenthesis in .replace don't understand it. far see there match ('2073') , not '2073' because used ( , not \ anyone care explain... you're creating regular look string literal, , \( ends beingness ( regex compiler, not \( . if want regex compiler see \ , you'll need escape in string literal: va...

css - How to Change Default Bootstrap Fluid Grid 12 Column Gutter Width -

css - How to Change Default Bootstrap Fluid Grid 12 Column Gutter Width - i looking know if there simple solution known alter gutter on fluid default 12 grid bootstrap scheme (2.3.0). i not familiar less if answer, please describe how changed. same sass. please note acceptable alter gutter width, by half or one fourth, illustration if may create things simpler. the next goals must met: must able update bootstrap in future. means not editing actual bootstrap files. functionality should remain other objects. must simple. less 10 lines of css. example, added class or something. i have searched throughout stack overflow , still have no thought how may go doing this. best of understanding, downloading customized bootstrap renders custom gutter widths non-fluid grids. have coded own fluid grid scheme before, understand math, worried there may consequences , helpful if known issues on class overrides shared. i promise give credit due. update: changing less...

asp.net - How to add a module to dnn published solution? -

asp.net - How to add a module to dnn published solution? - i have published dnn solution.i need add together module solution.how possible? i made module in fresh solution , pack without publishing , install in published solution.but problem there no app_code directory published solution.so there shows error while deleting app_code directory.because cannot find controller directory.if need not controller concept work fine.but in scenario need database connection.so need controller.so there shortcut implementing app_code of specific module published website. how did develop module? if used module development templates @ http://christoctemplate.codeplex.com find packaging , deploying modules easy across websites. using "app_code" approach can more hard if trying deploy modules. asp.net dotnetnuke dotnetnuke-module

android - How much time does a webview take to load the images attached in the webview/webpage.? -

android - How much time does a webview take to load the images attached in the webview/webpage.? - i have been looking android webview loading time quite long time now. want find out how much time webview take load images (and images) attached in webview/webpage. please help. appreciate. i don't think images loaded in webview. said here implement onpagefinished() . that's @ to the lowest degree somewhere. android image webview load

c++ - How to check shared library is loaded successfully or not loaded using dlopen? -

c++ - How to check shared library is loaded successfully or not loaded using dlopen? - im loading shared library using dlopen() function in c++ program. then how check loaded or not? or can check loading of library using mangled name of function nowadays in library? from manual page: if dlopen() fails reason, returns null. the dlsym function can not handle c++ identifiers, unless have been declared extern "c" , or using mangled name. c++ linux shared-libraries

lockscreen - Windows Phone 8 Lock screen timeout option in settings -

lockscreen - Windows Phone 8 Lock screen timeout option in settings - a couple of questions regarding windows phone 8 lock screen: the windows phone 8 emulator has alternative "never" in lock screen time out settings. why alternative not available in actual windows phone 8 devices (i have checked nokia lumia 820 , htc 8s)? can lock screen time-out set programmatically? it's available. it's htc 8s (international eu) yes, can disabling useridledetection. samples , more background info here. phoneapplicationservice.useridledetectionmode property (microsoft.phone.shell) idle detection windows phone windows-phone-8 lockscreen

How to verify username and password in Java-mysql? -

How to verify username and password in Java-mysql? - how verify in right way username , password inputted user database? in c++, used verify using if-else: if((user == "username")&&(pass == "password")){ cout<<"you logon!"; } in java-mysql i'm not sure if i'm on right track: login button private void jbutton1actionperformed(java.awt.event.actionevent evt) { // todo add together handling code here: user = jtextfield1.gettext(); pass = jpasswordfield1.getpassword(); login(); } method/function private void login() { seek { if (user != null) { sql = "select * users_table username='" + user + "'"; rs = stmt.executequery(sql); rs.next(); username = rs.getstring("username"); password = rs.getstring("password"); ...

java - Interrupting a thread prior to calling Future.get() -

java - Interrupting a thread prior to calling Future.get() - i'm trying write integration test causes interruptedexception raised production code: @test public void test() { productionobject = new productionobject( com.google.common.util.concurrent.moreexecutors.samethreadexecutor()); thread.currentthread().interrupt(); assertthat(productionobject.execute(), equalto(defaultresponse)); } inside productionobject 's implementation: try { (future<t> future : executorservice.invokeall(tasks))) { results.add(future.get()); } homecoming results; } grab (interruptedexception e) { thread.currentthread().interrupt(); // preserve interrupt flag homecoming defaultresponse; } inside abstractqueuedsynchronizer.acquiresharedinterruptibly() see: if (thread.interrupted()) throw new interruptedexception(); so expect test pass consistently. i've seen fail in our build server ( results returned r...

android Spinner followed by ListView - onItemSelected not called -

android Spinner followed by ListView - onItemSelected not called - i have had search around , can't seem find answer. method onitemselected not beingness called. here's code featured in activity's oncreate method: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_view_trips); seek { // if network present.. todo // load devices devicelist = new arraylist<device>(); dataasynctask loaddevices = new dataasynctask(0); loaddevices.execute(someurl); list<device> devicelistnames = devicelist; final listview triplistview = (listview)findviewbyid(r.id.trip_list); spinner devicespinner = (spinner) findviewbyid(r.id.select_device_spinner); arrayadapter<device> deviceadapter = new arrayadapter<device>(this, android.r.layout.simple_spinner_dropdown_item, devicelistnames); deviceadapter.setdropdownviewresource(android...

java - Running a Websocket connexion with an embedded atmosphere and jersey servlet -

java - Running a Websocket connexion with an embedded atmosphere and jersey servlet - i trying instance of atmosphere run servlet without using web.xml , using websocket functionnality. it seems mapping not working, because able connect server (localhost:8080) , javascript tells me ws connection working, handler not beingness recognized (methods never called). websockethandleradapter seems never used atmosphereservlet. all examples found using web.xml setup servlets, need able instanciate servlets (atmosphere , bailiwick of jersey in jetty container) programmatically. i have been working on lastly couple days , starting bang head.. please give me advice :). i have been using illustration atmosphere websocket chat websockethandleradapter setup , jersey atmosphere servlet instanciate servlets in jetty. many thanks! bruno gagnon-adam here code instanciate server / servlets. : public server create() throws exception { logger.info("creating http server...

Ajax array post using ASP.NET MVC? -

Ajax array post using ASP.NET MVC? - here acript created generate array: var data_points = $("#bcc_datapoint_selection").find("input:checked").map(function () { homecoming $(this).val(); }).get(); console log output: ["3","4","6"] ajax post script: $.ajax({ url: '@url.action("bccgetmeterreadingschart", "widget")', type: 'post', data: { datapoints: data_points }, success: function (result) { $("#bcc_chart").html(result); }, error: function () { alert("seçilen kritere uygun veri bulunamadı!"); } }); //end ajax controller method: public actionresult bccgetmeterreadingschart(string[] datapoints) { // code homecoming json("", jsonrequestbehavior.allowget); } debug output: datapoints : null request info output: datapoints%5b%5d=3&datapoints%5b%5d=4&datapoints%5b%5d=6 wh...

haskell - yesod respond plain text -

haskell - yesod respond plain text - as i'm new haskell, kindly force me right direction of solving next problem...? i started yesod's scaffolding application. serving html generated database content works fine, there elegant way create plain text responses iterating on database tables? simple plain text using handler like gettestr = homecoming . repplain . tocontent ... works too, i'd serve: config/models: file path text conf key text val text file fileid as plaintext in sql query: select path, key, val file, conf order path, key; as hamlet generating html, think must generate response (iterate on database contents) exclusively in haskell? how convert between database entity , text (or int, if row of type int), how convert , database column id? with plain text template!! ''#{expr}'' admits text, string, int32 or int64 expressions instances of text.shakespeare.text.totext {-# language overloadedstri...

Android: Launch Calculator when pressing button -

Android: Launch Calculator when pressing button - i'm developing app , need when user clicks on calculator button launches android calculator. there way of doing or need create calculator myself? in case have create calculator myself , show in specific part of screen android calculator type of thing 1 (showdialog, popup, toast etc)? you can launch calculator app this: intent = new intent(); i.setclassname("com.android.calculator2", "com.android.calculator2.calculator"); startactivity(i); with starting activity in other package, setclassname(...) takes bundle , class parameter. note not work on devices not utilize default calculator app. android calculator

c preprocessor - Syntax error while using a #define in initializing an array, and as arguments to a function in C? -

c preprocessor - Syntax error while using a #define in initializing an array, and as arguments to a function in C? - using #define while initializing array #include <stdio.h> #define test 1; int main(int argc, const char *argv[]) { int array[] = { test }; printf("%d\n", array[0]); homecoming 0; } compiler complains: test.c: in function ‘main’: test.c:7: error: expected ‘}’ before ‘;’ token make: *** [test] error 1 using #define functional input arguments #include <stdio.h> #define test 1; void print_arg(int arg) { printf("%d", arg); } int main(int argc, const char *argv[]) { print_arg(test); homecoming 0; ...

ruby on rails - Has-Many and Belongs-to-one Relation -

ruby on rails - Has-Many and Belongs-to-one Relation - i'm trying maintain track of how many signup_conversions user creates. therefore, have 2 next models: signup_conversion.rb class signupconversion < activerecord::base belongs_to :user belongs_to :convertee, :class_name => "user", :foreign_key => 'convertee_id' attr_accessible :convertee_id end user.rb class user < activerecord::base attr_accessible :name, :email, :password, :password_confirmation belongs_to :signup_conversion has_many :signup_conversions end would work way? or missing crucial here? i haven't tried code, give tips hope find useful. i think every has_many / has_one statement should have correspondent belongs_to , 3 belongs_to , 1 has_many doesn't good. i'm not sure has_one :signup_conversion , has_many :signup_conversions play together, i'd rather alter names. changed other names seek create associations clearer althou...

testing - why writing unit test methods? -

testing - why writing unit test methods? - i find many people wasting lot of time write hundreds of lines test applications. changing application architecture create test methods easier write. why don't test methods using. mean deed users , seek give different inputs , see if result expecting ? i'll seek , reply more details. think argument why write ton of unit tests instead of clicking around application see if works expected. logic takes less time click few buttons write thousands of lines of code test. i've worked in several companies public facing websites , can tell "click around" testing approach terrible. reasons: it doesn't scale. if have non-trivial application, spend hours every release testing acting user. it's waste. end running through same tests on , on own bias. you'll test features know best , end in routine. "i click on this, that, ... , application good!" it's waste of time if test same things....

objective c - interface orientation in iOS6 -

objective c - interface orientation in iOS6 - i have create changes in existing app. app lastly update in june when ios6.0 not launched. wondering how orientation works on devices running ios6.0?? build contains deprecated methods of oreintation? - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation this method doesnt called in ios6.0 how app in app store working fine in ios6 devices? additionally if run app xcode using code, doesnt back upwards orientation ios6. client saying app on app store working fine orientation in devices , new build not supporting orientation. know can prepare issue using new methods orientation -(bool)shouldautorotate but curious know how older app working fine on ios6 devices using deprecated methods when method not getting called in when run using xcode. the older applications compiled using ios 5.x sdk, that's why can run fine on ios 6, problem occurs when compile non ios 6 compliant co...

html - Whitespace added when browser is smaller than content -

html - Whitespace added when browser is smaller than content - i have bizarre issue noticed i'm working on wordpress theme friend, , i'm using relative/absolute positions add together social/connect buttons on side of divs -- works fine proper design. the issue, however, arises on "social" div on right side of page. if browser smaller main content's size, adds white-space right side of page. if move div left side, it's fine; adds whitespace @ half page length (which more confusing). i can't life of me figure out why happening; can't figure out if it's standard behavior, or issue created on own. i hoping perhaps here might have had similar experiences, or thought how prepare it. the site reference http://betacreations.com/example/uberpotato edit: css #social div is: #social{ width: 90px; height: 250px; padding: 10px; position: absolute; right: -40px; top: 40px; background: #efefef; box-shadow: 2px 2px 5px 0 rgba(...

objective c - iOS binary data column not showing up in Sqlite database? -

objective c - iOS binary data column not showing up in Sqlite database? - hi have next setup: this definition @interface item : nsmanagedobject @property (nonatomic, retain) nsnumber * cid; @property (nonatomic, retain) nsdata * image_data; @property (nonatomic, retain) nsstring * image_url; @property (nonatomic, retain) nsnumber * order_id; @property (nonatomic, retain) nsnumber * status; @property (nonatomic, retain) nsstring * title; @property (nonatomic, retain) nsstring * url; yet somehow see next in sqlite3 database: sqlite> .schema zitem create table zitem ( z_pk integer primary key, z_ent integer, z_opt integer, zcid integer, zorder_id integer, zstatus integer, zimage_url varchar, ztitle varchar, zurl varchar ); anyone here knows why there isn't zimage_data 1 of these columns? find out whether value of image_data still there after fetch. that'll give thought whether value beingness kept elsewhere, external storage. also, create sur...

android - GyroListener created in onCreate() is null in onResume() -

android - GyroListener created in onCreate() is null in onResume() - i create gyrolistener in oncreate() , utilize in onresume() . nullpointerexception in onresume() , don't understand how can be, because oncreate() called onresume() . happens in android versions 2.2 3.2.1, users have android 4+, , don't have single study of error devices. this code (the nullpointerexception thrown in lastly line of onresume() ): class="lang-java prettyprint-override"> @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_lock_screen); sensormanager = (sensormanager) getsystemservice(sensor_service); sensors = sensormanager.getsensorlist(sensor.type_gyroscope); gyrolistener = new gyrolistener(); gyrolistener.setongyroeventlistener(new ongyroeventlistener() { @override public void ontimereset() { toast.maketext(getapplicationcontext(), ...

php - How can I fetch correct datatypes from MySQL with PDO? -

php - How can I fetch correct datatypes from MySQL with PDO? - my pdo fetch returns string. i have user class id (int) , username (varchar). when seek next sql request $db->prepare('select * users id=:id_user'); $db->bindparam(':id_user', $id_user); $db->execute(); $user_data = $db->fetch(pdo::fetch_assoc); and var_dump($user_data), id parameter string. how can create pdo respects right datatypes mysql ? you utilize different *fetch_style*. if have user class, forcefulness pdo homecoming instance of user class with $statement->fetchall(pdo::fetch_class, "user"); you can take care of properties validations , casting within user class, belongs. related: php pdo: fetching info objects - properties assigned before __construct called. correct? pdo php fetch class php mysql pdo

java - Array of primitives or objects initialization -

java - Array of primitives or objects initialization - array of string objects can created // acceptable declarations , initialization line 1: string[]s = new string[2]; line 2: string[]s = new string[]{"a","b"}; // below init looks me compiler errors out line 3: string[] s = new string[2] { "a", "b" }; 1) why cant specify size of array in line 3? 2) when create array using line 3, strings "a" , "b" created on heap or in string pool? you can't both initialize array , specify size, redundant. all string literals stored in constant pool , happens before code runs, @ class loading time. also note new string[] redundant initializer: string[] s = {"a","b"}; java string initialization

javascript - Calculate distance between two points in google maps V3 -

javascript - Calculate distance between two points in google maps V3 - how calculate distance between 2 markers in google maps v3? (similar distancefrom function inv2.) thanks.. if want calculate yourself, can utilize haversine formula: var rad = function(x) { homecoming x * math.pi / 180; }; var getdistance = function(p1, p2) { var r = 6378137; // earth’s mean radius in meter var dlat = rad(p2.lat() - p1.lat()); var dlong = rad(p2.lng() - p1.lng()); var = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(rad(p1.lat())) * math.cos(rad(p2.lat())) * math.sin(dlong / 2) * math.sin(dlong / 2); var c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)); var d = r * c; homecoming d; // returns distance in meter }; javascript google-maps-api-3

html - How do you make a div stay centered when using the static navigation -

html - How do you make a div stay centered when using the static navigation - when ever restore window or test screen resolution on screenfly. the content html5 player @ hides navigation. here website http://djwckd.com/ css #sidenav { background-image:url('http://i1285.photobucket.com/albums/a592/djwckd/wckd-bg2_zps36505f8f.jpg'); width: 225px; position: fixed; /*--fix sidenav remain in 1 spot--*/ float: left; /*--keeps sidenav place when fixed positioning fails--*/ text-align:center; height: 100%; } #content { background-image:url('http://i1285.photobucket.com/albums/a592/djwckd/wckd-bg1_zpsf32da4c1.jpg'); float: right; /*--keeps content right side--*/ width:85%; text-align: center; font-family:trebuchet ms; color: #000; height: 100%; } .bottom { background-image:url('http://i1285.photobucket.com/albums/a592/djwckd/wckd-bg3_zps849e973b.png'); font-fa...

asp.net mvc - Validating a drop-down in mvc4? -

asp.net mvc - Validating a drop-down in mvc4? - i want create sure user selects value drop-down before submitting form. please have @ code below. doing wrong ? thanks view @model store.models.storedto list<store.models.countrydto> countrieslist= viewbag.countries; var countryitems = new selectlist(countrieslist, "cid", "cname"); @html.dropdownlistfor(x => x.countries.singleordefault().cid, @countryitems ) @html.validationmessagefor(x=>x.countries.singleordefault().cid) <input class="btn btn-info" type="submit" value="search" /> view-model public class storedto { public ienumerable<countrydto> countries { get; set;} } public class countrydto { [displayname("cid")] [uihint("dropdownlist")] [required(errormessage = "please select country")] public string cid { get; set; } [required] public stri...

css - list items vertical gap IE -

css - list items vertical gap IE - i've fixed 90% gap, still see 2 px margin between list items. .lines li { border-bottom: solid #000 1px; list-style: none; background-color: #cf0; height: 0px; } .lt-ie9 .lines li { display: inline-block !important; } .lt-ie9 .lines li { display: block !important; background-color: #cc0; font-size: 0px; line-height: 0px; } <ul class="lines"> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> this due inline-block display. have delete space between list items in html code. can replace commentary. <p>lorem elsass ipsum</p><!-- whitespace --><p>réchime amet sed bissame libero knackes choucroute…</p> see http://www.alsacreations.com/astuce/lire/1432-display-inline-block-espaces-indesirables.html if can read french. css list

javascript - Angular JS - ngRepeat in a Template -

javascript - Angular JS - ngRepeat in a Template - i'm trying utilize ngrepeat in directive - don't know how it. close? mowers array in controller directive used. .directive('slider', function() { homecoming function() { template: '<slider><film><frame ng-repeat="mower in mowers">{{mower.series}}</frame></film></slider>'; replace: true; scope: true; link: function postlink(scope, ielement, iattrs) { // jquery animate } } }); yes, you're close, syntax off. , need assign mowers on scope. .directive('slider', function() { homecoming { restrict: 'e', //to element. template: '<film><frame ng-repeat="mower in mowers">{{mower.series}}</frame></film>', replace: true, scope: true, // creates new kid scope prototypically inherits link: function postlink(scope, ielement, iattrs...

data structures - What are the disadvantages of linked lists? -

data structures - What are the disadvantages of linked lists? - what disadvantages of linked list? isn't little time consuming ? if yes,then how can cut down execution time/reaction time getting desired output? each info construction meant given set of purposes , in solving types of problems , bad in others. instance disadvantage of linked list can not efficiently minimum element in it. linked list is not meant used that. there numerous implementations of linked list , asking if it little time consuming pointless without specifying which implementation , operation. still no matter question reply if yes,then how can cut down execution time/reaction time getting desired output? is: either utilize implementation of linked list or utilize info structure. no construction improve in beingness linked list than... linked list. list data-structures

javascript - JS: Check if text is exceeding container width -

javascript - JS: Check if text is exceeding container width - is there js or jquery function observe if innerhtml or text within # of pixels beingness clipped container? i need few hundred elements on page, performance bit important. example - determine if text in <td> within 5px of exceeding width: <td class="cell"> 12,3423 </td> .cell { width: 20px; } try $.fn.textwidth = function(){ var html_org = $(this).html(); var html_calc = '<span>' + html_org + '</span>'; $(this).html(html_calc); var width = $(this).find('span:first').width(); $(this).html(html_org); homecoming width; }; $(function(){ alert($('.cell').textwidth()); }); fiddle http://jsfiddle.net/hpyay/ it can possible duplicate (and above code copied from) of calculating text width jquery javascript jquery html css dom

java - Why is PDFBox deleting a rectangle line when converting to Image file -

java - Why is PDFBox deleting a rectangle line when converting to Image file - broken converted image i seek convert pdf image file.... works fine, deletes line in 1 of rectangles.... can't figure out why..... public static void main(string[] args) throws filenotfoundexception, ioexception { pddocument doc = pddocument.load(new fileinputstream(new file(".....pdf"))); pddocumentcatalog doccatalog = doc.getdocumentcatalog(); list pages = doccatalog.getallpages(); (object pageobj : pages) { pdpage page = (pdpage) pageobj; bufferedimage pdfimage = page.converttoimage(); imageio.write(pdfimage, "png", new file("/......png")); } doc.close(); } before deleted text of pdf.... it still hassling 1 of text width, overwrites rectangles line ? plse see pdf here... when trying reproduce problem, turned out current pdfbox 1.7.1 renders image. problem occurred when using old version 0.7...

Two Buttons in Rails -

Two Buttons in Rails - i'm trying 2 buttons work in rails same form. have login form both add together user , signup button. have 2 methods in controller handle these 2 different requests. however, read suggestions using additional parameter parse determine button called. solution wouldn't need level of indirection controller method parsing? read having controller phone call controller isn't mvc practice. in case calling method within mvc controller class bad practice? my form: <%= form_tag("users/delegate", :method=>"post") %> <%= label_tag(:user, "username:") %> <%= text_field_tag(:user) %> <br/><br/> <%= label_tag(:password, "password:") %> <%= password_field_tag(:password) %> <br/><br/> <%= submit_tag "login", :name=>'login' %> <%= submit_tag "add user" %> <% end %> also, how pa...

Implement CRC algorithm from equation -

Implement CRC algorithm from equation - i'm dealing device utilize 16 bit cyclic redundancy check: ccitt crc-16 polynomial x^16 + x^12 + x^5 + x^1 i looked implementation of such algorithm, did find ones lastly term of equation equal 1 (i.e. x^0 ) instead of x^1 , this one or this. i going implement algorithm myself, when realized don't know how start. how supposed develop crc calculation starting equation? this pdf file explains subject: hackersdelight.org/crc.pdf. i recommend computer networks andrew tanenbaum, has chapter on crc algorithm. finally, double-check see device in fact implement form of crc opposed standard one. might typo. equation crc crc16

c# - How do I configure one menu per area in .Net MVC and other area-specific variables for the layout -

c# - How do I configure one menu per area in .Net MVC and other area-specific variables for the layout - i'm working on rather big application in .net mvc 4, have 1 master menu navigate through areas , 1 submenu navigate through components of 1 area. obviously submenu different per area, , i've "solved" using viewbag. i have 1 master controller abstract methods: public abstract class basecontroller: controller { protected abstract string getmenu(); protected override sealed void onresultexecuting(resultexecutingcontext filtercontext) { viewbag.menu = getmenu(); base.onresultexecuting(filtercontext); } } and every area has basecontroller next declaration public abstract class area1controller: basecontroller { protected string getmenu() { homecoming "menunameforarea1"; } } and in _layout, access menu this: @{ var menu = viewbag.menu string; if (menu != null) { ...

regex - How to exclude text between boundaries? -

regex - How to exclude text between boundaries? - i'm trying understand why illustration regex not work way i'd to: test-text: filename: test myfile 123 .txt pattern: (?<=filename:.*?myfile)(.*?)(?=.txt) expected result: 123 i know lookahead/behind not ideal here, it's learning purpose trying understand. so why .*?myfile not work? if remove it, pattern matches test myfile 123 . want filename: , exclude myfile , , take after , bewteen lastly .txt statement. missing here? due complexities of regex matching, variable-length lookbehind pattern not supported. should error message effect. limitation of perl's regex engine. there similar feature allows this: \k discards left final match. pattern work expect to: /filename:.*?myfile\k(.*?)(?=.txt)/ it not same true lookbehind, however, in doesn't allow overlapping matches. incidentally, 3rd similar question have posted. based on info have given, right reply still "don't ...

c++ - Simple program, no callstack, "inpossible" to find error -

c++ - Simple program, no callstack, "inpossible" to find error - when run on working machine (win7 vs2010 ultimate sp1) int main() { unsigned = 5; %= 0; homecoming 0; } or int main() { int * ip = 0; *ip = 4; homecoming 0; } and integer partition 0 unhandled exception. when nail break button, see problem, phone call stack contains msvcrt100d , ntdll , visual studio breaks me within file mlock.c on leavecriticalsection( _locktable[locknum].lock ); line. when run code on machine(win7 vs2010 proff sp1), vs breaks on problematic line i %= 0; od *ip = 4 . this error hidden somewhere within project , wasn't able find till run on machine. how can prepare behavior? need see on working machine. i have clean installation of windows 7, clean installation visual studio 2010 , vs-sp1. project should not ruined. generate using cmake , same project working fine on non-working machine. any advice appreciated. ok, have fo...

objective c - How can I make a nsdictionary out of it with string objects as the key and array of postion as the object for the key -

objective c - How can I make a nsdictionary out of it with string objects as the key and array of postion as the object for the key - basically have array of nsstring objects 'a',l,l,a,h,a,b,a,d. output should nsdictionary 0,3,5,7 key a, 1,2 key l 4 key h 6 key b 8 key d. it's simple for-in loop little this: - (nsdictionary*)dictionaryfromarrayofstrings:(nsarray*)array { int idx = 1; nsmutabledictionary *retval = @{}.mutablecopy; (nsstring *char in array) { //reverse them dictionary of nsnumbers set of nsstring keys [retval setobject:char forkey:@(idx)]; idx++; } homecoming retval; } objective-c nsarray nsdictionary nsrange

fluid layout - Bootstrap affix nav wraps on small screen -

fluid layout - Bootstrap affix nav wraps on small screen - i have affixed nav in bootstrap works great, until view on iphone. wide vertical orientation. nav "nowrap" , "overflow-x: scroll". utilizing of bootstrap's fluid layout bootstrap responsive features 'affix'ed navigation i thought had white-space:nowrap; overflow-x:scroll; part of nav, not work. working great on wider media: not great on narrow media, trying horizontal scroll on nav (not whole page): here's fiddle. resize result pane until narrow (like vertical orientation iphone screen): http://jsfiddle.net/dirkraft/hqjfb/2/ well issue having can resolved using media queries iphone resolution next : js fiddle illustration http://jsfiddle.net/shail/hqjfb/6/ @media (max-width: 480px) { .row-fluid:after, .row-fluid:before { margin-bottom:10px; } .navbar .nav { margin: 0px; } .navbar .nav > li > { padding:10px 8px; } } twitter-bootstrap flui...

json - Reploting a JQplot chart using ajax -

json - Reploting a JQplot chart using ajax - i have been trying solve in different ways, haven't create work expected, sense isn't big deal (i hope so) experience , skills ajax , jquery kind of limited that's why appealing expertise! i working on chart similar 1 here http://www.jqplot.com/tests/data-renderers.php. in case json file generated depending on value user choses select box. using 2 files , ajax calls accomplish this: -annualb.html file select box located , chart should displayed. -index.php file query database made (using value obtained selectbox in annualb.html) , json array generated. in annualb.html utilize method retrieve value selectbox , send index.php, generates json data. based on json info chart has created in annualb... here problem comes. function generate chart working fine , phone call send select value , homecoming json working (have checked firebug), know missing (but don't know yet) because don't manage pass json info ...

c# - Usercontrol .ascx variable access -

c# - Usercontrol .ascx variable access - what should done solve problem of access? markup: <%@ command language="c#" autoeventwireup="true" codebehind="header.ascx.cs" inherits="version_2.themes.anatema.header" %> <%= deneme %> code: namespace version_2.themes.anatema { public partial class header : usercontrol { public string deneme = "asd"; } } error: the name 'deneme' not exist in current context try this, should work. <%@ command language="c#" autoeventwireup="true" codefile="user.ascx.cs" inherits="user" %> <asp:label id="label1" runat="server"> <%=test%> </asp:label> code behind using system; public partial class user : system.web.ui.usercontrol{ public string test = "this test"; protected void page_load(object sender, eventargs e){ this.databind(...

RegEx - JavaScript - Validate a known domain with any protocol, subdomains and folders -

RegEx - JavaScript - Validate a known domain with any protocol, subdomains and folders - i need validate known domain, domain.com javascript, need validate subdomain or sub-subdomains , so, , protocol , folder, sub-folder, , so, have regular expression: regex: /http:\/\/([\.|a-z]+).domain([\.|a-z]+)\// the problem not gets https/ftp/ftps... , domain.com/domain.org... need validate, this: to validate: *://*.domain.com/* example: http://example.domain.com/subfolder2/folder24/ example: https://subdomain.domain.com/folder/ example: ftp://www.example.domain.com/folder2/folder/ example: http://www.domain.com/folder/sub-folder/ i mean, protocol, subdomain, , folder, , of course, of them too: example: https://example.domain.com/folder/folder/ any idea? try regex: /^(https?|ftp):\/\/[.a-z]+\.domain\.com[.a-z0-9/-]+/ this match domains lisited: class="lang-none prettyprint-override"> http://example.domain.com/subfolder2/folder24/ https://subdo...

css - vertical align pseudo element in list navigation -

css - vertical align pseudo element in list navigation - i've created list style navigation , each hyperlink can multiple lines, after each hyperlink element added pseudo element 'arrow' after, possible align pseudo element vertically regardless of hyperlink height? the requirement work in ie8 & above. the mark-up: <ul> <li> <a href="#"> <h3 class="title">cover</h3> <p class="subtitle">lorem ipsum dolor sit</p> </a> </li> <li class="current"> <a href="#"> <h3 class="title">lorem ipsum dolor sit down amet</h3> <p class="subtitle">lorem ipsum dolor sit down amet, consectetur adipisicing elit. maiores cum!</p> </a> </li> <li> <a href="#"> <h3 class="title">lorem ipsum dolor sit down amet, consectetur</h3...

gcc - Error compiling Matlab MEX files (Piotr's Matlab Toolbox) -

gcc - Error compiling Matlab MEX files (Piotr's Matlab Toolbox) - i trying install piotr's matlab toolbox (http://vision.ucsd.edu/~pdollar/toolbox/doc/) compile script mex files complains: >> toolboxcompile compiling....................................... warning: using gcc version "4.6.3-1ubuntu5)". version supported mex "4.2.3". list of supported compilers see: http://www.mathworks.com/support/compilers/current_release/ /usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status mex: link of ' "/home/josh/desktop/project/code/toolbox/images/private/assigntobins1.mexglx"' failed. ??? error using ==> mex @ 222 unable finish successfully. error in ==> toolboxcompile @ 36 i=1:length(fs), mex([fs{i} '.c'],opts{:},[fs{i} '.' mexext]); end how go resolving issue? before compile mexfiles in matlab need configure mex compiler. in matlab, type: >> mex -setup ...

Python: Transformation Matrix -

Python: Transformation Matrix - is right way co-compute translation , rotation, or there improve way? @ moment code translates , rotates, pose problem? code from math import cos, sin, radians def trig(angle): r = radians(angle) homecoming cos(r), sin(r) def matrix(rotation=(0,0,0), translation=(0,0,0)): xc, xs = trig(rotation[0]) yc, ys = trig(rotation[1]) zc, zs = trig(rotation[2]) dx = translation[0] dy = translation[1] dz = translation[2] homecoming [[yc*xc, -zc*xs+zs*ys*xc, zs*xs+zc*ys*xc, dx], [yc*xs, zc*xc+zs*ys*xs, -zs*xc+zc*ys*xs, dy], [-ys, zs*yc, zc*yc, dz], [0, 0, 0, 1]] def transform(point=(0,0,0), vector=(0,0,0)): p = [0,0,0] r in range(3): p[r] += vector[r][3] c in range(3): p[r] += point[c] * vector[r][c] homecoming p if __name__ == '__main__': point = (7, 12, 8) rotation = (0, -45, 0) translation = (0, 0, 5) matrix = matrix(rotation, translation) print (transform(point, matrix)) ou...

odbc apps script -

odbc apps script - we have core application allows odbc connections. utilize ms excel or access create reports. many times per week print them .pdfs , email them managers (not managers have access our core application). have google apps , wondering if had experience connecting odbc gas. think process improve automated. i have databases have made available users through excel dynamic reporting. wondering if migrate gas environment, also. any help or guidance appreciated. you utilize jdbc connect underlying database , create reports , other info manipulation in gas. see link documentation\examples: https://developers.google.com/apps-script/jdbc odbc google-apps-script

java - Not able to get values of checkboxes populated through JSP -

java - Not able to get values of checkboxes populated through JSP - i associating checkbox each row in table. want selected checkboxes in servlet. have populated checkboxes this: <%int i=0; %> <c:foreach items="${booklist}" var="book" varstatus="bookcount"> <tr> <td><input type="checkbox" name="bookselected" id="bookselected<%=i%>" value="<%=i%>"><c:out value="${book.title}"></c:out></td> <%i=i+1%> </c:foreach> servlet code is string[] chks = request.getparametervalues("bookselected"); the checkboxes displayed on screen though select checkboxes, servlets variable chks gets null value. you need check few things here. are check boxes within form beingness submitted ?. you generating row each check box. so, table should within form tag beingness submitted. now days, can check parameters submitted ...

php - How to provide selected rows to cgridview to display and at same time provide search for columns -

php - How to provide selected rows to cgridview to display and at same time provide search for columns - here using cactivedataprovider pass selected rows giving status , in view displaying in cgridview columns working fine @ same time should provide search columns unable provide search can 1 help. here sample code controller code public function actionshow($id) { $model=new studentresult('search'); $model->unsetattributes(); // clear default values if(isset($_get['studentresult'])) $model->attributes=$_get['studentresult']; $dataprovider=new cactivedataprovider('studentresult', array( 'criteria'=>array( 'condition'=>"profileid=$id", ), 'pagination'=>array( 'pagesize'=>20, ), )); $this->render('show',array( 'model'=>$model, 'dataprovider' => ...

Understanding storage requirement for amazon s3 using fuse-s3fs -

Understanding storage requirement for amazon s3 using fuse-s3fs - i got question understand mount process of amazon s3 service suing fuse-s3fs, when mount amazon s3 service bucket, copies whole info local scheme or deed view of amazon s3 bucket? the reason why want know is, allow got scheme 500 mb storage space, can mount bucket info around 200 gb? if deed view should, if whole info copied locally not. i need guidance in regard. thanks. by default (i.e. without using caching option), s3fs nil more provide mount point s3 bucket. there no local info copies retained. s3fs provide alternative utilize local drive cache, can provide i/o performance improvements in cases needed (as direct read/write s3 bucket via mount not quickest process). amazon-web-services amazon-ec2 fuse s3fs

c# - Convert List into Comma-Separated String -

c# - Convert List into Comma-Separated String - my code below: public void readlistitem() { list<uint> lst = new list<uint>() { 1, 2, 3, 4, 5 }; string str = string.empty; foreach (var item in lst) str = str + item + ","; str = str.remove(str.length - 1); console.writeline(str); } output: 1,2,3,4,5 what simple way convert list<uint> comma-separated string? enjoy! console.writeline(string.join(",", new list<uint> { 1, 2, 3, 4, 5 })); string.join take list sec parameter , bring together of elements using string passed first parameter 1 single string. c# .net

php - vbulletin 5 DataManager functions? -

php - vbulletin 5 DataManager functions? - i trying develop web service uses api vbulletin, i'm in version 5 beta 21, seeing in api documentation there's multitude of functions accessing has of import data, surprise these functions missing ! i managed object vb_datamanager_user , vb_datamanager_userpic other object not found within api, display fatal error: class 'vb_datamanager_thread' not found in /forum/path please can help ? there has had problem? or way utilize functionality of datamanager object ? php api vbulletin

Disabling the large file notification from google drive -

Disabling the large file notification from google drive - while downloading zip file(more 25mb assume) getting below notification, sorry, unable scan file viruses. file exceeds maximum size scan. download anyway in browser.is there alternative disable it,so can download big file straight without having receive such messages interruption. want know whether setting there in google drive, can disable broker message. i found next pattern allows disable big file notification: https://googledrive.com/host/file-id i think knows how find file-id google drive file. please maintain in mind method works if file shared "public on web" option. google-drive-sdk

c# - How do i build array of regions? -

c# - How do i build array of regions? - the array should contain 3 regions. each part should include 2 numbers : region 1 illustration contain 3,4 part 2 5,5 part 3 23,100 // three-dimensional array. int[, ,] array3d = new int[,,] { { { 1, 2, 3 }, { 4, 5, 6 } }, { { 7, 8, 9 }, { 10, 11, 12 } } }; which taken here, found using google , searching string, "multidimensional arrays in c#". c# arrays multidimensional-array

Django: Is it a security risk to send request to templates? -

Django: Is it a security risk to send request to templates? - sometimes wish utilize multiple variables request, , other times utilize none. what, if any, security risks may arise having request variable available every template? it risk if allow untrusted people create templates. templates don't change. if don't trust creating templates, have bigger problems (it easier them sneaky in python code). if template dynamically generated , accidentally gave users way add together info template, security risk. however, don't think proposing. django security django-sessions

MySQL: why is a index column marked as "BTREE?" -

MySQL: why is a index column marked as "BTREE?" - lets see 2 tables: create table `orders_products` ( `order_id` int(10) unsigned not null, `product_id` int(10) unsigned not null, `quantity` tinyint(3) unsigned not null, `user_id` int(10) unsigned not null, primary key (`order_id`,`product_id`,`user_id`) using btree, key `fk_orders_products_3` (`user_id`), key `fk_orders_products_2` (`product_id`) **using btree**, constraint `fk_orders_products_1` foreign key (`order_id`) references `orders` (`id`) on delete cascade, constraint `fk_orders_products_2` foreign key (`product_id`) references `products` (`id`) on delete cascade, constraint `fk_orders_products_3` foreign key (`user_id`) references `users` (`id`) on delete cascade ) engine=innodb default charset=utf8; another: create table `products_pictures_comments` ( `picture_id` int(10) unsigned not null, `user_id` int(10) unsigned not null, `comment` text not null, `dateat` dateti...

Header doesn't extend with page width -

Header doesn't extend with page width - no thought why happening. head standard div, nil special. when content extends page width, header won't extend it. see screenshot: http://dl.dropbox.com/u/7830551/screenshots/e5zxgw58gxm9.png how prepare this? thanks. type setting width 100% : <div style="width: 100%"> <!-- header html here --> </div> width page-layout

Android Multiple View switching, without Activity's -

Android Multiple View switching, without Activity's - i making game, , making levelselect class 3 different views, (jail, yard , sand), used have multiple intent's, if way, there no way shut downwards application, , doesn't homecoming quite well. i tried using setcontentview() method, turn's out isn't able load class competent view, tried combining class, class can't initialize objects outside of current view in process. question is: how can utilize multiple views without launching new activity? package com.muttgames.shadowpuzzle; import android.app.activity; import android.content.context; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.view.onclicklistener; import android.widget.linearlayout; public class levelselect extends activity implements onclicklistener{ protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.ja...