Posts

Showing posts from June, 2014

javascript - WYSIWYG without the HTML tags? -

is possible take text wysiwyg editor? example, if have following text: <a href="whatever"> sdadsa<>,.<> <p </a> is possible take text inside sdadsa<>,.<> ? some might don't use editor need make 2 copies 1 tags , other without html tags , html tags match. is possible take text without html tags? if want strip html tags out of output, have 2 methods: with php - use strip_tags($output) . with javascript - type var plaintext= editoroutput.replace(/(<([^>]+)>)/ig,""); or use php.js's equivalent php method.

Svn update paths from a file in command line. How? Is it possibly? -

i have lot of file paths in file should updated. not know, how can this. tried use < operator , not working. if update 1 one, takes long time. any idea? what can in such case use svn's changelist mechanism. you can create own list first: $> svn changelist mylist /src/cpp/foo $> svn changelist mylist /src/cpp/bar and can use during update this: $> svn update --changelist mylist this way, file in list mylist updated. note can use changelists commit files only.

python - Recursively delete folders below 3rd level in large structure of folders -

i have large structure of thousands of folders only, interested in keeping folders in top 3 levels, , deleting rest. looking recursive python script this. appreciated. untested, os.walk() : import os import shutil base = '.' root, dirs, files in os.walk(base): n = 0 head = root while head , head != base: head, _ = os.path.split(head) n += 1 if n == 3: dir in dirs: shutil.rmtree(os.path.join(root, dir)) del dirs[:] # clear dirs os.walk() doesn't subdirectories

mysql - CREATE table LIKE a JOIN -

select * t1 join t2 on t1.id1 = t2.id2 yields join of tables on mysql. how can store result in third table without having define column column. i tried create third table doesn't work. create table t3 ( select * t1 join t2 on t1.id1 = t2.id2 ) if want new table contain results of select : create table t3 select * t1 join t2 on t1.id1 = t2.id2 or if want based on schema of join: create table t3 select * t1 join t2 on t1.id1 = t2.id2 false

Creating vector of boost dynamic_bitset in C++ -

i want create array of dynamic_bitsets. created vector of dynamic_bitset using, vector<boost::dynamic_bitset<>> v; how can specify size of each of these dynamic_bitsets i.e. v[0], v[1] etc? in general case, specify size through constructor. boost::dynamic_bitset<> x(3); this line vector<boost::dynamic_bitset<>> v; create empty vector. instead have requested filled default entries have same value, 1 does vector<int> v(n, 1); to create vector n entries 1 vector<boost::dynamic_bitset<>> v( n, boost::dynamic_bitset<>(3) ) ; to have contain n boost::dynamic_bitset<> s 3 bits. if vector contains enough elements should able set v[i] different size v[i] = boost::dynamic_bitset<>( 100 ) ; alternative create empty vector , use v.push_back(boost::dynamic_bitset<>(42)) add correctly sized elements.

javascript - How do I make a jquery modal always centered on the page? -

i've see problem jquery modal popup boxes. i'm wondering, there jquery code keep jquery modal centered in page? know can achieved pure javascript code jquery? if want center element jquery, try this; var browserw = $(window).width(); var centerele = (browserw - 960) / 2; //if ur website design's width 960 $('.centeredele').css({'left':centerele + 'px'});//or margin-left, ur choise

php - Escaped value ('\s) in database -

i'm using codeigniter, , basically: $val = $this->db->call_function('real_escape_string', $this->input->post('name')); this on data before putting database. , when enters value o'hara, in database appear o\'hara so, guess can string slashes on output, usual way of escaping , storing data in database? solved active records escapes query, double escaping, 'real_escape_string' function so guess don't need use real_escape_string @ all, active records the '\' called escape character , must used next character after (in case ') won't interfere sql statement. however, if you're using ci, should take care of of you. there's 'html helper' believe can use format or take out slashes on outputted text. then, wrong, when outputting values db in ci, slashes automatically stripped.

How to install go and goisntall on ubuntu for doozer install -

i using ubuntu 10.04 , 12.04. i tryig install doozer , doozed , having hard time dealing go isntall. need make chef recipe install. the directions installing doozer follows: goinstall github.com/ha/doozer how goinstall? edit: using go 1.0.2 , go install , following output: github.com/ha/doozer # github.com/ha/doozer /usr/local/go/src/pkg/github.com/ha/doozer/conn.go:184: cannot use &t.req (type *request) type proto.message in function argument: *request not implement proto.message (missing protomessage method) /usr/local/go/src/pkg/github.com/ha/doozer/conn.go:198: cannot use &r (type *response) type proto.message in function argument: *response not implement proto.message (missing protomessage method) /usr/local/go/src/pkg/github.com/ha/doozer/conn.go:294: undefined: proto.getint64 /usr/local/go/src/pkg/github.com/ha/doozer/conn.go:326: undefined: proto.getint64 /usr/local/go/src/pkg/github.com/ha/doozer/conn.go:412: undefined: proto.getint32 /usr/local/go/src/pkg/githu...

How to correctly handle a .Net windows service which changes frequently -

i've got windows service going be updated ~ fortnightly i've got useful code in dll, service couple of simple start , stop methods map identical methods in dll. i use console app develop/debug dll wondering; instead of service referencing dll directly , requiring uninstall/reinstall every time update, there downside using service wrap console application? which say, instead of... private myservice imyservice sub start() myservice = new myservice() myservice.startasync() end start doing like... const serviceexecutablepath string = "c:\blah\myservice.exe" private myservice process sub start() myservice = process.start(serviceexecutablepath) end start that way, if want publish, need stop service, replace executable (and relevant dlls) , start again. i haven't quite worked out how graceful shutdown yet. console app listens ctrl   c interrupt , calls myservice.shutdown(graceful:=true) (a blocking call). should try emulate same within service or there bette...

javascript - Using same code for chrome and firefox but get different results -

i have simple count down script. code works in chrome not firefox. in firefox displays nan chrome shows countdown ideas why happens? function countdowntimer(time, name) { var counter = setinterval(function(){ var today = new date(); var expire = new date(time); var timeremains = expire - today; var days = math.floor(timeremains / (1000 * 60 * 60 * 24)); var hours = math.floor(timeremains / (1000 * 60 * 60)); var mins = math.floor(timeremains / (1000 * 60)); var secs = math.floor(timeremains / 1000); var dd = days; var hh = hours - days * 24; var mm = mins - hours * 60; var ss = secs - mins * 60; if (expire < today) { clearinterval(counter); document.getelementbyid(name).innerhtml = '<span class="expire">expire!</span>'; return; } else { if (dd < 10) { dd = "0" + dd; } if (hh < 10) { hh = "0" + hh; } if (mm < 10) { mm = "0" + mm; } if (ss < 10) { ss = "0" + ss; } document.getelementbyid(name).innerhtm...

ASP.NET MVC - Typed ViewData proposal -

in project i'm working on, have lot of "read-only" pages don't have <form> s in; have lot of form pages have lot of readonly data pulled in controller. ordinarily you'd use viewmodels , have 1 viewmodel per view , viewmodel contains of data view. seems fair enough, except there's problem: in head, see viewmodel being representation , encapsulation of entire data sent view controller, viewmodel might contain data populated controller (such selectlistitem[] html.dropdownlistfor() data) cannot populated view , sent controller. sure, possible have data part of viewmodel , manually re-populate before returning view in controller's httppost-handling method, feel needlessly complicates controller's code (and you'd have use updatemodel() instead of automatic updates happen when specify model argument action method). my solution typed viewdata object. derive viewpage<tmodel> give viewpage2<tmodel,tdata> tdata : viewdatadictionary<...

sql - Can't call stored procedure without specifying supposedly optional parameter -

i'm trying call stored procedure several required , several optional parameters. before came along, beginning of procedure scripted out this: use [mydb] go set ansi_nulls on go set quoted_identifier on go alter procedure [dbo].[sp_getstudents] ( @sortorder varchar(50), @sortcolumn varchar(150), @sortletter varchar(10), @status varchar(250), @pageindex int, @pagesize int, @user_id int, @reference_no varchar(50) = null, @first_name varchar(50) = null, @middle_name varchar(50) = null, @last_name varchar(50) = null ) begin -- other stuff here everything seems work fine. added parameter end: use [mydb] go set ansi_nulls on go set quoted_identifier on go alter procedure [dbo].[sp_getstudents] ( @sortorder varchar(50), @sortcolumn varchar(150), @sortletter varchar(10), @status varchar(250), @pageindex int, @pagesize int, @user_id int, @reference_no varchar(50) = null, @first_name varchar(50) = null, @middle_name varchar(50) = null, @last_name varchar(50) = null, @contextid int = null ...

c# - Populating a UIPickerView with data from Sqlite DataBase in IPhone App -- -

i have sqlite database table 'bikeinfo' [bikeid, bikename] now want pickerview populated names of bikes database. in .net easy. being complete beginner in monotouch, have got no clue how approach problem. did googling , found out have create kind of custom class extending uipickerviewmodel class , override various methods. that's it. not find sample code, tutorial or anything. have been battling 3 days now. totally confused. far have written function fetching data table , returning list of class objects[that have written containing properties bikename , bikeid]. maybe looking in wrong places. need done ever way. any kind of tutorial, or sample code in c# dealing target-specific scenario helpful me. the next objective show alert message showing corresponding bike id when user touches 1 particular item. think have define selected event in custom class. have picked internet. thanks. this have done far. have created class containing properties bikeid , bikename . na...

Codeigniter: Not inserting data in table -

update: solved .. for reason, data not getting inserted table. being posted form see var dump, further that, won't do. so, here 3 modules. simple test scheme: form 2 fields, press submit , should inserted. (i can in ordinary php 1 page, but, mvc frameworks nightmare in regard, write 30 times more code need in procedural. <?php class inserting_controller extends ci_controller { public function __construct() { parent::__construct(); $this->load->model('inserting_model'); } public function index () { $this->load->view('inserting_view'); } // controller public function insert() { $data = array( 'username' => $this->input->post('username', true), 'password' => sha1($this->input->post('password', true) )); var_dump($data); // data posted exit; $this->inserting_model->insertdata($data); // should forward them model } } ?> ============== model <?php class inserting_model extends ci_model{ functi...

mysql - How to match part of a field with data in another field with query? -

i have 2 tables table1 , table2: table1 contains field named id value 1212 (example) in it. table2 has field named action data added 1212 or updated 1212 . now check query. select t1.*, t2.name table1 t1, table2 t2 t2.action 'added t1.id' i want add name field in second table, first 1 added ( updated not needed) data only. clause condition? how can query this? i did this. select t1.*, t2.name table1 t1, table2 t2 t1.id = (right(t2.action, 4)) , t2.action 'added %' thanks tried me.

viewdidunload - should I write [super viewDidLoad]? -

this question has answer here: do have call [super viewdidload] in -viewdidload method? 8 answers i'm writing navigation based app. (it has modal segues too) i'm not sure if should keep [super viewdidload]; call or not. should write code after line of code or before it? how [super viewdidunload]; , similars? you don't have to; according documentation, it's stub function, doesn't useful in non-subclasses. moral: read docs.

How to change a javascript variable to PHP -

i have javascript variable screenname twitter users. when connect site, want php script write name in txt file. how this. looked writing files ajax no luck. <script type="text/javascript"> twttr.anywhere(function (t) { var currentuser, screenname, profileimage, profileimagetag; if (t.isconnected()) { currentuser = t.currentuser; screenname = currentuser.data('screen_name'); $('#twitter-connect-placeholder').append("<p style='color:white;text-shadow:none;'>howdy " +" " + screenname + "!"); var screenname = "<?= $js ?>"; } }); </script> <?php $check = $_get['track']; if ($check == '1') { $fp = fopen('data.txt', 'a'); fwrite($fp, "{$js}"); fclose($fp); } ?> if view source screenname equals "" any ideas on this? in order approach problem, you'll need understand php executed on server side, before page sent user, , javascr...

jquery - One Page fadeIn & fadeOut Transition Logic -

i making one-page website client. there 3 different menu groups, in example simplified 1 menu , less content. i have navigation: <nav> <ul id="main" class="toggle"> <li><a id="design" href="#">design</a></li> <li><a id="contactus" href="#">contact us</a></li> <li><a id="aboutus" href="#">about us</a></li> <li><a id="news" href="#">news</a></li> </ul> </nav> and divs below: <div class="designcontent"> design content here </div> <div class="aboutuscontent"> content here </div> so if click on design show designcontent, , if click show aboutuscontent , on. i asking short-hand code of $("#design").click(function(){ $('.homecontent').fadeout(500); $('.designcontent').delay(500).fadein(1000); retur...

c# - How to specify the width of the datagrid column to occupy the remaining space? -

i developing silverlight 4 application. have following datagrid <data:datagrid x:name="studentdatagrid" autogeneratecolumns="false" height="200" horizontalalignment="left" margin="176,96,0,0" verticalalignment="top" width="200"> <data:datagrid.columns> <data:datagridtextcolumn header="first name" binding="{binding firstname}"></data:datagridtextcolumn> <data:datagridtextcolumn width="*" header="last name" binding="{binding lastname}" ></data:datagridtextcolumn> </data:datagrid.columns> </data:datagrid> i binding following list datagrid public list<student> getstudents() { list<student> studentlist = new list<student>(); student s1 = new student(); s1.firstname = "anil"; s1.lastname = "jadhav"; student s2 = new student(); s2.firstname = "shyam"; s2.lastname = "jodh...

php - How to detect spoiled or crashed images after upload -

how can detect spoiled images after upload? im using code this: $imagesize = getimagesize($tmp_name); if(!$imagesize || !in_array($imagesize['mime'], $allowmimetype)){ $this->error = 'bad image'; @unlink($tmp_name); return false; } $tn = imagecreatetruecolor(80, 80); switch ($imagesize['mime']){ case 'image/jpeg': $userphoto = imagecreatefromjpeg($tmp_name);// error 1 break; case 'image/png': $userphoto = imagecreatefrompng($tmp_name);// error 1 break; case 'image/gif': $userphoto = imagecreatefromgif($tmp_name);// error 1 break; case 'image/bmp': $userphoto = imagecreatefromwbmp($tmp_name);// error 1 break; default: $this->error = 'unknown image'; @unlink($tmp_name); return false; break; } imagecopyresampled($tn, $userphoto, 0, 0, 0, 0, 80, 80, $width, $height);// error 2 imagejpeg($tn,'images/userphoto/'.$this->username.'.jpg',100); chmod('images/userphoto/'.$this->username.'.jp...

programming languages - What is the meaning of the type "NONE" (like int,bool,string...) -

i have seen type none in book no explanation... understood type in languages wish understand in depth! void? or null? the book called "programming language concepts , paradigms" (writen david a.watt) , has "wide view" of many languages , differences between 1 another. in languages use none (except python)? more 1 purpose nonetype? thanks! amihay python has nonetype none value. none similar null in other languages. >>> type(none) <type 'nonetype'> other languages may use none mean else.

Objective-C method overriding/overloading confusion -

there seems debate/disagreement on whether possible 'overload' methods in objective-c. putting aside impossible define method overloading in objective-c terms equal of c++ (because of method signature syntax differences), ask in particular: of following allowed , not? 1) class declaring/implementing both these methods: - (void) dosomethingwithobject:(classa*) object; - (void) dosomethingwithobject:(classb*) object; 2) class declaring/implementing both these methods: - (void) dosomethingwithobject:(classa*) object; - (bool) dosomethingwithobject:(classa*) object; 3) class declaring/implementing method: - (void) dosomethingwithobject:(classb*) object; ...when superclass declares/implements method: - (void) dosomethingwithobject:(classa*) object; (and analogue conflicting return value), both when a) classb descends classa , , b) not. question 1: no can do: objective-c doesn't include types in method names; there no mangling. might work objective-c++ -- never use...

How do i hide the tables created in visual studio 2010 C#? -

how hide tables created in visual studio 2010 c#? trying hide table (somewhat timetable) , let appear when user click on 1 of calendar dates. tried using visibility: hidden; whole table disappeared when view on design view. need help! in advance. your question bit unclear, understood, how can achieve: in codebehind (c# .cs file) can set table hidden using style property, this: .aspx file <table id="table1" runat="server"> ......td's , tr's..... </table> .cs file in page_load table1.style.add("display", "none"); this allow see table in design mode, , when page rendered on client's browser table hidden. note : cannot use this.table1.visible = false; in codebehind hide table because in case table never reach client-side browser , wont able show table @ all, should use table1.style.add("display", "none"); if want send table client's browser in hidden mode. you can use jquery or javascrip...

concatenation - Mysql:Query for the table as below -

i have following table: |-------------------| | id | homephone | |-------------------| | 1 | 454454125 | | 2 | 47872154587 | | 3 | 128795423 | | 4 | 148784474 | |-------------------| i have around 40.000 rows in table. i want format homephone values following: 454-454-125 478-721-545-87 128-795-423 148-784-474 i.e. after every 3 numbers want - (hyphen). how achieve using mysql? you need wite udf this

eclipse - Google maps Activity view in existing Android application -

i'm in beginning phase of android application programming in eclipse. have made simple app main menu. one of options in main menu should "google maps" view. how possible do? have start beginning new project , new emulator, or there way implement map in stage? thanks in advance. see this mapview tutorial . i assume have single activity class in app now, can add class project, implement mapview in.

c# - Regular expression to retrieve text from a string -

i have string have values like {ctrl1} + {ctrl2} ({ctrl1} / {ctrl2}) * {ctrl3} if ({ctrl1} > {ctrl2}) {ctrl1} * 10 else {ctrl} + {ctrl2} endif there several formulas this. available in string variable. need extract {..} values. so, in example1, should extract {ctrl1} , {ctrl2} . in example2, should extract {ctrl1} , {ctrl2} , {ctrl3} . in example3, should extract {ctrl1} , {ctrl2} . can please me regex this? you want {[^}]+} . note that won't handle recursive stuff {hello{2}} . you'll need actual parser things that.

jQuery button same function with link -

the jquery is $(function() { // videothumb css class found in foreach list class="videothumb". ytvideo holder id set div id $(".videothumb4").on('click').ytplaylist({ holderid: 'ytvideo4', html5: true, playerwidth: '520', autoplay: false, sliding: false, listsliding: true, social: true, autohide: false, playfirst: 0, playonload: false, modestbranding: true, showinfo: false }); }); the main clickable link this <a class="videothumb4" href="http://www.youtube.com/watch?v=' . $yvalue['videoid'] . '"> ' . $yvalue['description'] . ' </a> then want link button below. same value , function. correct button is <input class="videothumb4" onclick="ytplaylist();" type="button" name="previewsel" value="preview" id="previewbut"> the sample link yt since jquery selector function written using css class name, need give s...

Append jQuery values not affected by javascript -

i'm appending values div through jquery, i've realized gets appended isn't affected javascript functions. $(".div").append("<input type='text' class='textform' placement='value' />"); what have setup in javascript code takes attribute placement of class "textform" , makes value. i've realized once value appended, isn't effected javascript. ideas on how fix issue? i guess have events bounded elements not working after append . this. $(function(){ $(".someclass").click(function(){ //dome thing }); }); if want same functionality work on newly injected( dynamically added via append /jquery ajax etc...) dom elements, should consider using jquery on . code should changed this $(function(){ $(document).on("click",".someclass",function(){ //dome thing }); }); on work current , future elements