Posts

Showing posts from July, 2012

php - How to check if the mysqli_object has been freed? -

i need check if mysqli_result has been freed. with ext/mysql functions function is_resource i tried checking if $result istance of mysqli_result, after been freed $result still mysqli_result object $db = mysqli_connect("myhost", "myuser", "mypass", "mydb"); $result = $db->query("select * mytable"); $result->free(); var_dump(is_a($result, "mysqli_result")); // => true, if freed cant wrap in function or method? class result { private $result; public function __construct(mysqli_result $result) { $this->result = $result; } public function getresult() { return $this->result; } public function free() { $this->result->free(); $this->result = null; } public function __destruct() { $this->free(); } }

javascript - How to check if string contain the "url or link" and retrieve it -

this question has answer here: match urls in string , return in array in javascript 1 answer i have comment section of page user can post comments on uploaded content, want check if user has shared url links in comment. for example - var comment = "to search more on question can http://stackoverflow.com/ " now how find out url link , retrieve link?i great if can find way in jquery , java script php acceptable. thanks in advance. try use regex ((http:\/\/|https:\/\/)?(www.)?(([a-za-z0-9-]){2,}\.){1,4}([a-za-z]){2,6}(\/([a-za-z-_\/\.0-9#:?=&;,]*)?)?)

xml - CodeIgniter + NuSOAP - Input multidimensional array -

i looking several times didn't find answer me, i'm asking , hope can me. i have webservices in codeigniter application returns complex types , whatever, , need create service receive complex type this: array ("position1" => 'mambo jambo', "position2" => 'more mambo jambo', "position3" => array("0" => array(), "1" => array()), "position4" => array("0" => array(), "1" => array()); in resume, complex type have normal data , inside 2 arrays receive n positions of array. need because receive invoice , in invoice receive n products (every 4 positions) , n quotas of payment (every value, date, etc). i tryed create complex type 2 positions every of them other complex type array of complex type. yes, know, complex =p is use when create output services return data this, input doesn't works. when try test in soapui app generate xml:...

css - Float h4 right after image? -

i having problems floating h4 after image. works long there room in table cell start resize window text floating left under imag, want ti right after when window being resized. here code: <td> <img src="theme/stats.png"> <h4>we grow channel!</h3> <div style="clear:both"></div> <br /> network guarantees grow channel day one, small channels! our network <b>help minimum of 5 new subscribers per day join us!</b> </td> h4 { font-size: 30px; font-family: 'bitter', serif; color: black; float: left; margin: 0 auto; } td img { float: left; margin-right: 20px; } you can see live here, try resize window see happens title + icons: http://vizz.tv/ i guess should remove float property <h4> achieve this: h4 { /* float: left; */ margin: 0px 0px 0px 55px; ... } fiddle

ios - iPhone auto layout images arrangement issue -

Image
i want arrange 3 images on iphone & ipad using auto layout. 3 images should rezise preserving aspect ratio, , width of 3 images should same. same space left , right sides 3 images. see example figure (figure shows landscape , portrait mode) on link: portrait: http://i.imgur.com/9kvxate.png landscape: http://i.imgur.com/tdjj9k6.png it possible programatically getting width , height of screen/view want using auto-layouts programatically: //inside method //- (void) didrotatefrominterfaceorientation: (uiinterfaceorientation)frominterfaceorientation //main_view view in 3 images kept //imageview1, imageview2, imageview3 3 image views imageview1.frame = cgrectmake(main_view.frame.origin.x + 3, main_view.frame.origin.y + 30, ((main_view.frame.size.width / 3)-4), ((main_view.frame.size.width / 3) - 4) * (82.0/75.0)); imageview2.frame = cgrectmake(imageview1.frame.size.width + 6, main_view.frame.origin.y + 30, ((main_view.frame.size.width / 3)-4), ((main_view.frame.si...

rascal - margin characters in string with interpolation -

inside string literal, margin character (a single quote) indicates initial part of line, before margin character, should ignored. there complementary "right-margin" character, indicates after on same line should ignored? (i realized useful when writing lengthy code inside interpolated expressions in string. in order make code more readable, split on multiple lines, newlines introduced way should not part of string literal. , putting newlines inside <...> looks ugly.) rascal supports ignoring left-margin characters before single quote (') in interpolated strings. suggestion ignoring right-margin characters interesting not supported. since layout inside interpolations <...> ignored can (and have to) place additional layout there.

c# - How to receive calls using ATAPI JULMAR library on PC -

i searching on internet last 3 weeks how answer call using c# couldn't solve problem managed dial call using this http://mukarrammukhtar.wordpress.com/creation-of-phone-caller-application/ can body suggest simple solution given above. if have used turbopower tapi component delphi , write wrapper method delphi generated code. not bad looks. turbopower components free bonus. in addition there not of delphi coding involved either[quite similar c# both have been brain-child of anders hejlsberg] . few years ago stalk in similar situation of yours , followed exact advice recommending , happily ever after.

javascript - Call external js file function in Angular js controller -

i have external js file has more functions. i need call these functions angular controller. for example: external.js ... ... function fun() { ... ... } ... ... controller: acccountcontroller.js myapp.controller('addaccountcontroller',function ($scope,addaccountloginservices,$location,localstorageservice,$compile,toaster){ .... .... $scope.getloginform = function(siteid,name) { ... ... fun(); // function external.js file }); ... ... }); i have imported external.js before acccountcontroller.js. doesnt calling function. , have not console error this. how achieve this... in advance. edit : gave wrong answer, bad. following example works. your external file should this: var dosomething = (function () { "use strict"; return { test: (function () { return 'test'; }()), test2: (function () { return console.log('test 2'); }) ...

javascript - Animate.css on scroll bug chrome/firefox -

i use animate.css implant animations on element when scrolling. elements have class .fadeinright , hidden . when appear on scroll, add class visible refer {visibility:visible;}. i see fade animation on safari, on chrome firefox element appear, without fading, ideas? {edit} yep here element html <section class="informations tadam fadeinleft"> text </section> my js $(window).scroll(function() { $('.tadam').each(function(){ var imagepos = $(this).offset().top; var topofwindow = $(window).scrolltop(); if (imagepos < topofwindow+(window.innerheight * 0.9)) { $(this).addclass("animated visible"); } }); }); and css these 2 class .tadam{visibility:hidden;} .visible{visibility: visible;} thanks help this because make transition "hidden" "visible", property not an...

python - Retry on deadlock for MySQL / SQLAlchemy -

i have searched quite time , can't found solution problem. using sqlalchemy in conjunction mysql our project , encounter several time dreaded error: 1213, 'deadlock found when trying lock; try restarting transaction'. we try restart transaction @ 3 times in case. i have started write decorator don't know how save session state before fail , retry same transaction after ? (as sqlalchemy requires rollback whenever exception raised) my work far, def retry_on_deadlock_decorator(func): lock_messages_error = ['deadlock found', 'lock wait timeout exceeded'] @wraps(func) def wrapper(*args, **kwargs): attempt_count = 0 while attempt_count < settings.maximum_retry_on_deadlock: try: return func(*args, **kwargs) except operationalerror e: if any(msg in e.message msg in lock_messages_error) \ , attempt_count <= settings.maximum_retry_on...

twitter bootstrap - My grunt-recess task won't compile properly -

my gruntfile.coffee has: recess: dist: options: compile: true includepath: ['public/bower_components/bootstrap-less/less'] src: 'dist/assets/ln.css' dest: 'public/stylesheets/ln.less' and ln.less super simple: @import "../bower_components/bootstrap-less/less/bootstrap.less"; when grunt recess , get: running "recess:dist" (recess) task verifying property recess.dist exists in config...ok files: public/stylesheets/ln.less -> dist/assets/ln.css options: banner="", compress=false, footer="", compile, includepath=["public/bower_components/bootstrap-less/less"] >> parser error in public/bower_components/bootstrap-less/less/mixins.less >> 643. padding-right: (@grid-gutter-width / 2); >> 644. &:extend(.clearfix all); >> 645. } warning: use --force continue. aborted due warnings. what doing wrong? as per comment seven-ph...

java - store snapshots on server -

webdriver driver = new firefoxdriver(); driver.get("http://www.google.com/"); file scrfile = ((takesscreenshot)driver).getscreenshotas(outputtype.file); fileutils.copyfile(scrfile, new file("c:\\tmp\\screenshot.png")); using code take snapshots using selenium web-driver. code stores snaphots locally on pc. if want run automatically jenkins, there way store snapshots somewhere else if runs either though jenkins or locally pc, don't have change link(("c:\tmp\screenshot.png") every time. you make location of output file controlled setting - either command-line argument tool running code (if can modify that), or environment variable can read section of code above. have default location exists , should writable user's home directory, rather absolute path c:\tmp. in jenkins, have step (in ant script, shell script, or whatnot) create folder called "screenshots" below $workspace, , tell tool that's going run code location ...

Applescript update iTunes stream title without obstructing rest of script -

i using code below current itunes stream title. works great. need be, script updates every time when itunes stream title changes, variable title updates well. repeat tell application "itunes" set title current stream title end tell delay 2 end repeat however, because of ongoing "repeat" function, rest of script not execute. know of way still variable title updated when itunes changes title, not obstruct rest of script? if sort of runs in background? thank you! a solution, use handler (handlers known functions, subroutines, or methods). put rest of script in handler, call handler loop. like : set oldtitle "" repeat set t "" try tell application "itunes" set t current stream title end try if t not "" , t not oldtitle -- title changed set oldtitle t dosomething(t) -- call handler end if delay 3 end repeat on dosomething(title) -- put rest of script here e...

Table thead :display on tr:hover -

i want reproduce effect on website http://sires.crv4all.us/shop/us/catalog/holstein when hover <tr> displays thead information above <tr> line cursor is. i tried using jquery tooltip displays thead on top. want find out how make display tr line hovering. here jsfiddle made producing effect (i'm kinda new js/jquery please feel free critique code, know pretty inefficient). on page looks js driving it: var $div = $('<div class="floating-header" style="position:absolute;z-index:1;display:none"><table><thead></thead></table></div>'); $(document.body).prepend($div); var $source = $('#animals thead'); // lock widths $source.find('th').each(function(){ var $this = $(this); $this.css({width: + $this.width() + 'px'}); }) // position floater $div.find('thead').append($source.html()); var offset = $source.offset(); ...

visual studio 2013 - Converting TFS workspace from "Server" to "Local" fails with error "Not a valid Win32 FileTime" -

issue i trying convert tfs workspace "server" "local". when change workspace setting , click ok, dialog titled "set workspace location" appears. shows progress bar message "creating , populating local version table...". after few seconds, dialog replaces it, title "microsoft visual studio" , following message: "error: not valid win32 file time" after click ok, error dialog goes away. workspace location has not been changed. my configuration i using visual studio 2013 update 2. workspace type "private" , file time setting "checkin." question what causing this, , how around can convert workspace? here workaround allowed me proceed: first change workspace's file time setting "current", , click ok. once operation completes, change workspace location "local" desired, , click ok. afterward, can change file time setting "checkin" if desir...

c# - WebBrowser OpenDialog automation fails in .NET -

i press button after webpage loads webbrowser control. how know it's loaded? wait significant amount of time sure. here 1 version of button code : var elementsx = webbrowser1.document.getelementsbytagname("input"); foreach (htmlelement file in elementsx) { if (file.getattribute("type") == "file") { listbox1.items.add(file.style.tostring()); file.focus(); file.invokemember("click"); sendkeys.send(@"c:\users\john\desktop\test1\blue-book-motorcycle.jpg" + "{enter}"); } } here another: mshtml.htmldocument doc = (mshtml.htmldocument)webbrowser1.document.domdocument; // ################################################################################ //get title textbox ihtmlelementcollection inputer = (ihtmlelementcollection)doc.getelementsbytagname(@...

Google Apps Spreadsheet open specific sheet based on week number -

i know solution "move sheet left" make default when opening spreadsheet. thing got 1 spreadsheet per week, , it's quite messy move around that, plus more user friendly. something similar google apps spreadsheet open specific sheet based on current date (month) weeknum rather new function in google docs, haven't found else googling around.

ios - Find out which type of area you are in from MKMapView -

is there way determine type of area in mkmapview? i.e. if centre of map in ocean can tell user: centre of map above ocean, or if map centred above green area: centre of map above parkland... the way can think of create screenshot of visible screen , analyse colour of each bit using method such this: ios -- detect color of pixel? however interested know if there easier way can think of! edit to make more clear i'm looking for, i'm looking way turn section of map top down level game, different areas determined areas of map... a clplacemark has couple of properties: inlandwater , ocean tell when placemark in water. think can placemark geocoder. it has areasofinterest give parks , landmarks.

javascript - Jquery - Datatables - Capture Element -

i have question. javascript. i'm trying capture click in table. i did so: "fndrawcallback" : function() { $('#example tbody').on('click', 'tr', function () { var id_val = $('td', this).eq(0).text(); alert(id_val); } ); } this works well. problem is: in last column, have checkbox, when click, event occurs, how add not condition? tried this: $('#example tbody').on('click', ':not(.checkbox)', function () { but did not work. for checkbox have this: $('#example tbody td').on('click',':checkbox',function() { alert('message'); }); any suggestions? thanks. this work: $('td.readonly').on('click', function () { alert('not checkbox'); }); $('td.checkbox').unbind('click').on('click', function () { alert('checkbox'); }); jsfiddle example

architecture - What is the main architectural pattern used by StackOverflow? -

as website's "write/command" side down today (because of read-only announcement , because 1 not post here) , curiosity, stackoverflow apply full cqrs event sourcing , all? curiosity trying cqrs self , did not find real life projects web applyed cqrs , perform well.

ajax - jsf 2.2.x AjaxBehaviorEvent listener no refresh multipart/form-data -

i have <h:form prependid="true" enctype="multipart/form-data" > <h:inputtext value="#{mybean.somestringfield}" /> <h:inputfile id="myfile" value="#{mybean.somepartfield}" /> <h:selectonemenu value="#{mybean.somefield}" > <f:selectitems value="#{mybean.someselectitemlist}" > <f:ajax event="change" execute="@form" render="@form" immediate="true" listener="#{mybean.somelistenerajaxbehaviorevent}" /> </h:selectonemenu> </h:form> when change value on selectonemenu form no refresh form the method somelistenerajaxbehaviorevent consists of code following public void somelistenerajaxbehaviorevent(ajaxbehaviorevent ev) throws abortprocessingexception { try { string code = (string)((uioutput)ev.getsource()).getvalue(); ... // sql sentences update data list } catch(exception ex)...

spring - restTemplate java.lang.IllegalArgumentException: "None" does not contain '/' -

Image
ok first of code (its mega simple): @controller @requestmapping("/") public class hellocontroller { private final static logger logger = logger.getlogger(hellocontroller.class); @requestmapping(method = requestmethod.get) public string printwelcome(modelmap model) { logger.info("elo elo"); model.addattribute("message", "hello world!"); resttemplate resttemplate = new resttemplate(); string url = "http://192.168.0.200:8000/gpio/11/function/in"; //string url = "http://192.168.0.200:8000/gpio/11/function"; //resttemplate.getforobject(url, string.class); string test = ""; resttemplate.postforobject(url, null, string.class); logger.info(test); return "hello"; } next example i'm not crazy man here response postman (chrome): and @ end full error log: type exception report message request processing failed; nested exception java.lang.ille...

c# - how to make random loop for array -

i want make code simple: take word on english , make random array character of word. intense, word:"qweasdzxc" should represent that: "adwseqzcx" (random) . code is: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace randomloop { class program { static void main(string[] args) { string s = "qweasdzxc"; string[] q = newarray(s); (int = 1; < s.length - 1; i++) { console.write(q[i]); } } public static char[] getarrayofstring(string s) { char[] c = s.tochararray(); return c; } public static random rnd = new random(); public static string[] charandnumber(char c, int lengthoftheword)//0-char 1-integer { string[] array = new string[2]; array[0] = c.tostring(); array[1] = (rnd.next(lengthoftheword)).tostring(); return array; } pub...

ruby on rails - Using the same route resource to find objects in a polymorphic association -

i have rails 3 app user model has_one profile . i'm thinking of adding ability sign , create profile facebook , potentially other services. user still have 1 profile, created through app, facebook, etc. pretty common. in thinking through implementation, largely settled on polymorphism. way keep third-party service-specific logic in profile object still have associated user. like: class user < activerecord::base belongs_to :profile, polymorphic: true end class profile < activerecord::base has_one :user, as: :profile, dependent: :destroy end class facebookprofile < activerecord::base has_one :user, as: :profile, dependent: :destroy end my problem, however, when comes routing. @ moment have profiles routing through profiles#show . inside action typical find like: @profile = profile.find(params[:id]) if using sti, use find on 1 class because i'd subclassing other profile objects. polymorphism seems i'd have bit different. store profile_id on u...

xml - XQuery multiple outputs -

im trying output multiple things on xquery xml file. for $foo in doc("foo.xml")//foo/who return $foo $bar in doc("bar.xml")//bar/too $foo/name=$too/name return $too/title so can return $foo if remove other section. if remove $foo can return $too/title. i cant figure out way return multiple 1 return return $too/title $too/name $too/date does not work try this: return ($too/name, $too/title) etc. remember returning sequence, can 0 (), 1 ($var) or more ($one,$two) items. put them between () , separate , success

Having trouble with simple implementation of flatten in SML -

i'm trying implement flatten : 'a list list -> 'a list list in sml. thought should relatively straight forward higher order functions. implementation is val flatten = list.reduce (op @) [] however i'm getting bizarre error message: "append.sml:1.6-1.36 warning: type vars not generalized because of value restriction instantiated dummy types (x1,x2,...)". when try flatten int list list type error: :> flatten [[1,2],[3]]; stdin:2.1-2.20 error: operator , operand don't agree [literal] operator domain: ?.x1 list list operand: int list list in expression: flatten ((1 :: 2 :: nil) :: (3 :: nil) :: nil) as error message hints, ran value restriction -- see here explanation. solution simple: "eta-expand" definition, i.e., make parameter explicit instead of relying on partial application: fun flatten xs = list.reduce op@ [] xs

Removing characters from string in java -

removing characters between single quotes. trying this. if entered sa' or '1'='1 output should ' or ' '=' . working on sql injection project. require removing characters single quotes. by using prepared statement can prevent injection. before want remove characters between single quotes. how this. there easy way. stringbuilder strbuilder = new stringbuilder(); string [] ary = uname.split(""); int j = 1; (int = 0 ; < ary.length ; i++) { if (ary[i].equals("'")) { if (j == 1) { strbuilder = new stringbuilder(); strbuilder.append(ary[i]); j++; } else if (j % 2 == 0) { strbuilder.append(ary[i]); j++; } else if (j % 3 == 0) { strbuilder.append(ary[i]); } else if (j % 4 == 0) { strbuilder.append(ary[i]); break; } } else { strbuilder.append(ary[i])...

function - Excel cant change formula without error -

i using formula check value in cell b6 , check through sheet 1 occurrences of value. formula works expected. however, want copy formula , change functionality it. if change b6 $b6 breaks, if copy cell breaks, if click on cell , press enter without making changes ... breaks. don't understand this, bug don't know causing it. i'm not used excel don't know if it's me or program. =iferror(sum(len(sheet1!$c$4:$ad$38)-len(substitute(sheet1!$c$4:$ad$38,left(b6,len(b6)),"")))/len(b6),0) any suggestions appreciated. i noticed formula working surrounded curly braces {=iferror(sum(len(sheet1!$c$4:$ad$38)-len(substitute(sheet1!$c$4:$ad$38,left(b6,len(b6)),"")))/len(b6),0)} ok mistake reason function cant copied straight because array function , must entered ctrl+shift+return apologies

php - Verify Apache availability behind Azure Balancer for each VM -

status: 2xa2 azure vm wamp, behind load balancer endpoint monitoring set question: how check apache availability each vm (as port 80 balanced , cannot individually check machine)? need check response via php script able automatically deploy further custom actions. is there way manually check (via php, or online service) probe.html(or specific file each machine) reside on each machine, in way? if 2 vms exist on private azure vnet add third machine vnet perform monitoring , use private ip address of each machine test endpoint.

mysql - PersistenceException: No Persistence provider for EntityManager -

i have problem , need help javax.persistence.persistenceexception: no persistence provider entitymanager named jsfcrudpu my persistence.xml <?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="jsfcrudpu" transaction-type="resource_local"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/jsfcruddb?zerodatetimebehavior=converttonull"/> <property name="javax.persistence.jdbc.user" value="root...

hide - How to target a class sevreal descendants down in jQuery? -

i have several parent divs, each bunch of children. of parents contain child (several divs deep) called .nxt i want hide of .nxt divs in parent1 div, not other 2 parents. shouldn't $('#parent1 .nxt').hide(); do it? or need include elements lead down .nxt thanks help. never mind - working - had before i'd added parent1 div dom. guys.

jquery - First element not with class -

i want select first element not have class .disabled . i tried these without success: $('.selected:first:not(".disabled")').addclass('first'); and $('.selected:first').not(".disabled").addclass('first'); you have element class 'selected' without class 'disabled' first of them. $('.selected:not(.disabled)').first().addclass('disabled'); or $('.selected:not(.disabled):first').addclass('disabled'); fiddle: http://jsfiddle.net/5luxd/1/

html - css, body background image top on samsung tablet / Moodle -

problem occur on sambungs tables. have background image set on body. css html, body{ background: url('img/background.jpg') no-repeat; background-position: top; // tried cover, fixed etc } webpage quite high, on 2000px , background image takes first 600px, , fine me, when click hide box on bottom of page, background automatically appear @ visible part of screen , eareased top of page. page isn't realoading during hiding boxes on page, that's why don't know how solve problem. any suggestions ? problem solved. had input background div#wrapper. solved problem rendering of background image

android - why does excludeFromRecents remove all activities? -

my app has 2 entry points (mainactivity , fromnotificationactivity). i want mainactivity appear in recent tasks, not fromnotificationactivity) with nothing declared in manifest, if do... mainactivity back fromnotificationactivity back ... find fromnotificationactivity listed in recent tasks if add android:excludefromrecents="true" fromnotificationactivity in manifest , repeat same sequence, find nothing in recent lists. what incantations must invoke such after above sequence of steps, mainactivity in recent list. by default, activities of application have same affinity. activities same affinity conceptually belong same task. hence in case both mainactivity , fromnotificationactivity belong same task. android:excludefromrecents ensures task not listed in recent apps. reason, when android:excludefromrecents set true fromnotificationactivity , mainactivity disappers history. solution: use android:taskaffinity specify different tasks b...

php - $_FILES is always empty -

i uploading pdf server through web-service, $_files seems empty regardless of do. the program uploading pdf osx program (via afnetworking). have ruled out possibility of causing issue when attempt upload file through 'cocoarestclient' (similar postman on chrome) nothing. in cocoarestclient setting contenttype 'multipart/form-data'. the pdf attempting upload 478kb not think size issue. my php code below. @ moment trying see if in $_files array @ all. <?php header('content-type: multipart/form-data'); $filename = $_files['pdf']['name']; $tmpname = $_files['pdf']['tmp_name']; $filesize = $_files['pdf']['size']; $filetype = $_files['pdf']['type']; $response = array("filename" => $filename, "tmpname" => $tmpname, "filesize" => $filesize, "filetype" => $filetype, ...

oracle - Why is result from STANDARD_HASH('expr', 'MD5') always in uppercase? -

i need md5 hash in oracle, use standard_hash function, have little misunderstanding. in oracle: select standard_hash('word', 'md5') dual result is: c47d187067c6cf953245f128b5fde62a alphabetical characters in uppercase. but in other database, example in mysql, result from: select md5('word') is: c47d187067c6cf953245f128b5fde62a exactly same result (lowercase) example php's md5() function. question: why returns oracle's standard_hash('expr', 'md5') alphabetical characters in upper case? wrong here? there no such thing standardized case (uppercase or lowercase) hexadecimal encoding. according rfc 4648 encoding should in uppercase. there other standards out there use lower case. hash functions defined output bytes, without specifying hexadecimal encoding. if want compare hexadecimal strings instead of bytes which, in opinion, preferred method compare hashes, need case insensitive compare. comparing bytes...

python - Efficient ways to store multiple excel files in a database? -

we're working on big inner project enables users upload excel files, , perform searches on data gathered these excels. i'm trying homework before begin design, , come best solution. the requirements - user can upload excel file many columns wants, there's no predefined structure excel . in contrary first point, there few fields assume user have. example - first name, last name. these colums don't have exist. the search option work following - when user searches, can search specific columns - ones predefined , expected excel file have. (in our example - first , last name). can search other columns, under field "other". another word other search field - field go through columns in excel files don't fit predefined columns. i.e - 1 file has age column, has birthplace column, "other" field search through columns. what's best way this? dynamically create new django model each excel uploaded, columns excel has? dynamically cr...

regex - Blocking hostname if same as IP in .htaccess -

i've been noticing in log files hostname same ip. guessing it's because there no rdns set. being said, how can block in htaccess? 5/17/2014 01:44 pm | ua: mozilla/5.0 (windows nt 6.3; wow64; rv:29.0) gecko/20100101 firefox/29.0 | ip: 50.58.251.66 host: 50.58.251.66 | referrer: (empty) | tor: false | data: [] | post data: [] my htaccess line. rewritecond %{remote_host} ^%{remote_addr} [nc,or] i've tested , not seem work. seemed logical me. thoughts? you can use rule block these requests: rewriteengine on rewritecond %{remote_host}::%{remote_addr} ^(.+?)::\1$ rewriterule ^ - [f]

javascript - close button for jquery popup box -

i using code popup box , it's work well $(document).ready(function() { // here write function when link click under class popup $('a.popup').click(function() { // here describe variable popupid gets // rel attribute clicked link var popupid = $(this).attr('rel'); // need popup marked belongs rel attribute // suppose rel attribute of click link popuprel here in below code // #popuprel fadein $('#' + popupid).fadein(); // append div id fade bottom of body tag // , allready styled in our step 2 : css $('body').append('<div id="fade"></div>'); $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadein(); // here need have our popup box in center of // webpage when fadein. add 10px height , width var popuptopmargin = ($('#' + popupid).height() + 10) / 2; var popupleftmargin = ($('#' + ...

ios - UIView transitionWithView animating property change: slide in from right? -

i have readonly uitextview, , i'm updating text. when new text appears, want animate follows: new text slides in right, old text slides offscreen toward left side. is possible transitionwithview? if not, what's best way it? can make crossdissolve, that's not animation i'm looking for: [uiview transitionwithview:self.storytextview duration:0.5 options:uiviewanimationoptiontransitioncrossdissolve animations:^{ [self.storytextview settext:withstory.storytext]; } completion:nil]; the reason insisting on right left animation because want user able trigger swiping toward left on uitextview. catransition allow this, transition type of 'push' , subtype of 'from right'. it's straightforward use: catransition *transition = [catransition new]; transition.type = kcatransitionpush; transition.subtype = kcatransitionfromright; // make...

java - comparable used as structure in a binary tree -

i have binary tree in java works nicely. want enhance data content in node. can add values on doing such as: for( int = 1; <=10; i++ ) t.insert( new integer( ) ); which add item this: public void insert( comparable item ) { current = parent = grand = header; nullnode.element = item; ... } here format of tree: private static class redblacknode { // constructors redblacknode( comparable theelement ) { this( theelement, null, null ); } redblacknode( comparable theelement, redblacknode lt, redblacknode rt ) { element = theelement; left = lt; right = rt; color = redblacktree.black; } comparable element; // data in node redblacknode left; // left child redblacknode right; // right child int color; // color } for showing tree, that: private void printtree( redblacknode t ) { if( t != nullnode ) { printtree( t.left ); sy...

mysql - Getting complicated about foreign key -

i beginner in innodb , not in database. m getting confused foreign keys. want know is: if delete pk( fk on table) is fk on child table deleted? so how if delete fk on child table? record in parent table deleted? also, if add new record parent table child table added? how add child table? how if update data? please me, confused foreign key reference in innodb database . guide me easiest way. thanks. what your'e asking cascading update/deletion child element. the docs : http://dev.mysql.com/doc/refman/5.6/en/innodb-foreign-key-constraints.html example : constraint foreign key ( jobabbr ) references ffxi_jobtype ( jobabbr ) on delete cascade on update cascade the "on delete cascade" means when key deleted, fk's deleted aswell, useful data integrity. it's not automatic. deleting foreign key not delete key it's based upon either way.

asp.net - Cleaning up old shopping carts -

the project i'm working on asp.net 2.0 e-commerce site. shopping cart session based expires after 30 minutes or so. i've converted carts stored on database i'm left problem of cleaning old carts. best way clean cart table in database? going make page in admin section owner can click clean shopping carts older 1 week. there better way handle this? if people abandon cart, they're no longer interested. simple solution give user option "save cart" (to db). presuming have working membership system profiles set can view cart on next login. as makit said, if you're running sql server above express can use scheduled stored procedure. have other options clear-up of old entries such windows scheduled task or run stored procedure start method in global.asax file. this best suggestion i've come across: data should not deleted @ all. amazon person may return months later , purchase cart: http://brockallen.com/2012/04/07/think-twice-about-using-...

Borland C++Builder 6 MDI Application -

Image
i made ​​an mdi application in borland c++builder 6. i made 2 forms: the main form child form i set child form available forms . when want call child form. use following command: application->createform(__classid(tchildform), &childform); //calling child form why when call command again, child form 2 this? first, don't use application->createform() , use new instead: childform = new tchildform(this); second, describe normal. creating new instance of independent child form, , see. if don't want child, don't create new one, re-use 1 have, eg: if (!childform) { childform = new tchildform(this); } // use childform needed... tchildform *childform = null; __fastcall tchildform::~tchildform() { childform = null; } void __fastcall tchildform::formclose(tobject *sender, tcloseaction& action) { action = cafree; }

android - Passing integer between activities using shared preferences -

i'm trying pass score integer 1 activity another. i'm having difficulties shared preferences. in mainactivity don't receive warnings or errors in scoreactivity receive error saying the method getint(string, int) in type shared preferences not applicable arguments (long, int) . how fix this? mainactivity private int score = 0; @override protected void oncreate (bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); sharedpreferences sharedpref = getpreferences(context.mode_private); sharedpreferences.editor editor = sharedpref.edit(); editor.putint("score", score); editor.commit(); scoreactivity private int score = 0; @override protected void oncreate (bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_score); sharedpreferences sharedpref = getpreferences(context.mode_private); int defaultvalue = getresources()...

Multidimensional ArrayList in Java -

i'm simulating supermarket, various checkout lines, , each of them has own queue, customers added when finish shopping. both customers , checkouts clases, instantiated in main class using arraylists. arraylist<customer> customerlist=new arraylist<customer>(maxcustomers); (i=0;i<maxcustomers;i++){ customerlist.add(new customer(randomitems, randomarrival); } i create checkouts in simmilar way. arraylist<checkout>checkoutlist=new arraylist<checkout>(maxcheckoutlines); (i=0;i<maxcheckoutlines;i++){ checkoutlist.add(new checkout()); } the problem here want create arraylist simulate 1 queue in each checkout, add customers when finish shopping. don't know if should use multidimensional arraylist when creating checkouts, , know how operate when adding customers. regards the class checkout can contain field of arraylist<customer> should add customers to. public class checkout { public arraylist<customers> cus...

java - Removing consecutive duplicates words out of text using Regex and displaying the new text -

hy, i have following code: import java.io.*; import java.util.arraylist; import java.util.scanner; import java.util.regex.*; / public class regexsimple4 { public static void main(string[] args) { try { scanner myfis = new scanner(new file("d:\\myfis32.txt")); arraylist <string> foundaz = new arraylist<string>(); arraylist <string> noduplicates = new arraylist<string>(); while(myfis.hasnext()) { string line = myfis.nextline(); string delim = " "; string [] words = line.split(delim); (string s : words) { if (!s.isempty() && s != null) { pattern pi = pattern.compile("[aa-zz]*"); matcher ma = pi.matcher(s); if (ma.find()) { foundaz.add(s);...

r - Converting date column in data frame -

r version: 3.1.0 the following threads have been read: - format date column in data frame - convert data frame date column timeseries and several other information topic without luck. i need import data frame .csv file, , need index date column specified date column. df <- read.csv(sti, header=true) df$date <- as.date(df$date, format="%y%m%d") (i've tried several other dateformats) this should simple, result either column filled n/as, column wrong dates og error message. my csv file contains excel date formats, , i've tried changing language settings in windows. i know it's date format, not know what. dput() of head seems way off. here's shorted version: structure(list(date = c("30/12/2013", "27/12/2013", "23/12/2013", "20/12/2013", "19/12/2013", "18/12/2013"), maerska = c(11180, 11150, 10900, 10770, 10670, 10500), wdh = c(527, 522, 515.5, 515.5, 512, 504.5), vws = c(16...

jquery - OOP JavaScript: Call method from inside of Callback Function -

i'm building jquery app using oop principles , i'm trying implement externally added callback function invokes method inside of object. function testobject() { var self = this; var functions = new array(); this.updateobject = function() { console.log('updated') } this.addfunction = function(func) { functions.push(func) } this.callfunctions = function() { $.each(functions, function(key, value) { functions[key]() }) } } var myobject = new testobject(); myobject.addfunction( function() { $(':text').on('change', function() { return self.updateobject(); }) } ) this overly simplified version of plugin i'm building. callback works fine, cannot use self.updateobject(); inside of it, since outputs illegal invocation. how can call method inside callback properly? the problem self out of scope of callback...

php - Using Assetic on Twig embed -

im new symfony2 , twig, want adapt admin template twig , include in symfony2 project bundle. i create bundle assets , templates , partials. i solved many problems after working, don't understand why assetic not generating files. i have next folders inside src/name/bundle/resources: public admin css global images js views default default.html.twig layouts login.html.twig partials footer.html.twig head.html.twig header.html.twig javascripts.html.twig sidebar.html.twig the idea define default layout, partials can include in future layouts, , generate different layouts extending default.html.twig , embedding assets css or js specific type of pages. default.html.twig <!doctype html> <!--[if ie 8]> <html lang="en" class="ie8"> <![endif]--> <!--[if ie 9]> <html lang="en" class="ie9"> <![endif]--> <!--[if !ie]><!--> <html lang="en"> <!--...

csv - Multiple Over writes using FileWriter in Java -

im trying read n different csv files containing stock price data. want extract 1 particular column each file , showcase columns in single csv file. the issue combined file contains written data first file give input i.e. data not being overwritten in iteration of loop. can help? or suggest new method? public static void main(string[] args) throws ioexception { int filecount=0; system.out.println("enter number of files"); scanner stream =new scanner(new inputstreamreader(system.in)); filecount= integer.parseint(stream.next()); file file2 = new file("combined_sym.csv"); filewriter fwriter= new filewriter("combined_sym.csv",true); printwriter outputfile= new printwriter(fwriter); int i; for(i=0;i<filecount;i++) { system.out.println("enter file name "+i); string filename =stream.next(); file file = new file(filename); scanner inputstream = new scanner(file); ...