Posts

Showing posts from April, 2010

ruby - Chef update certain user's .bashrc -

i'm trying update users .bashrc java_home environment variable after installing jdk. strange error don't understand. here's block of code in question. node['etc']['passwd'].each |user, data| only_if {data['uid'] > 9000} jdk_dir_array = dir.entries('/usr/java/').select {|entry| file.directory? file.join('/usr/java/',entry) , !(entry =='.' || entry == '..') } jdk_dir_name = jdk_dir_array.shift file = chef::util::fileedit.new("#{data['dir']}/.bashrc") file.search_file_replace( /java_home=.*/,"java_home=/usr/java/#{jdk_dir_name}") file.write_file end the error i'm getting this: nomethoderror ------------- no resource or method named `only_if' `chef::recipe "install_jdk"' i don't understand why thinks "only_if" method of recipe when declare inside of node.each block. i should point out if put in ruby_block , hardcode path single u

string - Longest Common Substring non-DP solution with O(m*n) -

the definition of problem is: given 2 strings, find longest common substring. return length of it. i solving problem , think solved o(m*n) time complexity. don't know why when solution, it's talking optimal solution being dynamic programming - http://www.geeksforgeeks.org/longest-common-substring/ here's solution, can test here: http://www.lintcode.com/en/problem/longest-common-substring/ int longestcommonsubstring(string &a, string &b) { int ans = 0; (int i=0; i<a.length(); i++) { int counter = 0; int k = i; (int j=0; j<b.length() && k <a.length(); j++) { if (a[k]!=b[j]) { counter = 0; k = i; } else { k++; counter++; ans = max(ans, counter); } } } return ans; } my idea simple, start first position of string , see what's longest substring can mat

c - Invalid Argument error when using clone() -

i'm using function call clone() clone (fun, (char*)stack + 0x500000, sigchld | clone_files | clone_fs, arg); where fun function: int fun(void*), stack = malloc (0x500000), , arg of type void*. i'm wondering other possible causes invalid argument perror. i have checked stack not null. man clone: child_stack argument specifies location of stack used child process. since child , calling process may share mem‐ ory, not possible child process execute in same stack calling process. calling process must therefore set memory space child stack , pass pointer space clone(). stacks grow downward on processors run linux (except hp pa processors), child_stack points topmost address of memory space set child stack.

list - Iterating through a .txt file in an odd way -

what trying write program opens .txt file movie reviews rating number 0-4 followed short review of movie. program prompts user open second text file words matched against reviews , given number value based on review. for example, these 2 sample reviews how appear in .txt file: 4 comedy-drama of epic proportions rooted in sincere performance title character undergoing midlife crisis . 2 massoud 's story epic , tragedy , record of tenacious , humane fighter prisoner -lrb- , victim -rrb- of history . so, if looking word "epic", increment count word 2 (which have figured out) since appears twice, , append values 4 , 2 list of ratings word. how append ints list or dictionary related word? keep in mind need create new list or dicitonary key every word in list of words. please , thank you. , sorry if poorly worded, programming isn't forte. all of code: def menu_validate(prompt, min_val, max_val): """ produces prompt, gets input, validate

php - using str_replace before simple_html_dom -

i'm using simple html dom grab scapped data , it's been working well. however, 1 of source have doesn't have unique fields i'm trying str_replace , grab elements i've renamed , use simple_html_dom. however, doesn't work. code is: require('simple_html_dom.php'); // create dom url or file $html = file_get_html('http://www.url.com'); $html = str_replace('<strong>','',$html); $html = str_replace('</strong>','',$html); $html = str_replace('<span class="pound">&pound;</span>','',$html); $html = str_replace('<td>','<td class="myclass">',$html); foreach($html->find('td.myclass') $element) $price = $element->innertext; $price = preg_replace('/[^(\x20-\x7f)]*/','', $price); echo $price; try <?php require('simple_html_dom.php'); // create dom url or file

php - Count posts with meta value -

i'm trying show number of posts have meta key values current user. this code: $args = array( 'posts_per_page' => -1, 'post_type' => 'post', 'post_status' => 'publish', 'author' => $current_user_id, 'meta_query' => array( 'key' => 'color', 'value' => array('red', 'blue') ), ); $posts_array = get_posts( $args ); $the_count = count($posts_array); echo $the_count; thi counting all posts current user, ignoring meta key values . i need $the_count number of posts have meta key value 'red' or 'blue' current user. what doing wrong? thanks in advance! i not sure, try this: $args = array( 'posts_per_page' => -1, 'post_type' => 'post', 'post_status' => 'publi

android - webview fragment press back to return to -

hi have android app recycleview . when user click button on recycle viewholder . app launch webview (inside fragment ). want handle when user click button, webview goback if there history, , if there no history, app close webview fragment , come recycleview . i have successfull handle when there history (but webview can not come recycle view if there no history here webview code webview.setonkeylistener(new view.onkeylistener() { public boolean onkey(view v, int keycode, keyevent event) { if (keycode == keyevent.keycode_back) { if (webview.cangoback()) { webview.goback(); }else { getactivity().getsupportfragmentmanager().popbackstack(); } return true; } return false; } }); anything wrong these code? appreciate. thank

python 3.x - Python3 Unicode Decode Error -

i unicodedecodeerror: 'utf-8' codec can't decode byte 0xe8 in position 0: invalid continuation byte when try call codecs.decode(x, 'utf-8') x = b'\xe8\xd0\xca@\xee\xe4\xca\xc6\xd6@\xde\xcc@\xe8\xd0\xca@\xd0\xca\xe6\xe0\xca\xe4\xea\xe6\x14\xc4\xf2@\xd0\xca\xdc\xe4\xf2@\xee\xc2\xc8\xe6\xee\xde\xe4\xe8\xd0@\xd8\xde\xdc\xce\xcc\xca\xd8\xd8\xde\xee\x14\x14\xd2\xe8@\xee\xc2\xe6@\xe8\xd0\xca@\xe6\xc6\xd0\xde\xde\xdc\xca\xe4@\xd0\xca\xe6\xe0\xca\xe4\xea\xe6\x14@@@@@@\xe8\xd0\xc2\xe8@\xe6\xc2\xd2\xd8\xca\xc8@\xe8\xd0\xca@\xee\xd2\xdc\xe8\xe4\xf2@\xe6\xca\xc2\x14\xc2\xdc\xc8@\xe8\xd0\xca@\xe6\xd6\xd2\xe0\xe0\xca\xe4@\xd0\xc2\xc8@\xe8\xc2\xd6\xca\xdc@\xd0\xd2\xe6@\xd8\xd2\xe8\xe8\xd8\xca@\xc8\xc2\xea\xce\xd0\xe8\xca\xe4\x14@@@@@@\xe8\xde@\xc4\xca\xc2\xe4@\xd0\xd2\xda@\xc6\xde\xda\xe0\xc2\xdc\xf2\\\x14\x14\xc4\xd8\xea\xca@\xee\xca\xe4\xca@\xd0\xca\xe4@\xca\xf2\xca\xe6@\xc2\xe6@\xe8\xd0\xca@\xcc\xc2\xd2\xe4\xf2z\xcc\xd8\xc2\xf0\x14@@@@@@\xd0\xca\xe4@\xc6\xd0\xca\xca\x

c# - Generate list of dates of the following work week -

i'm trying generate list of dates based on following condition: if today wednesday , after 6:00pm or after wednesday, generate next work week. else generate current work week. work week being defined monday-friday. so far googling , pulling 2 answers here, have extension gives me next occurring specified day based on current day: public static datetime next(this datetime dt, dayofweek startoofweek) { var start = (int)dt.dayofweek; var target = (int)startoofweek; if (target <= start) { target += 7; } return dt.adddays(target - start); } pulled from: how date of next sunday? and have following work days as: var daysofweek = enum.getvalues(typeof(dayofweek)) .oftype<dayofweek>() .skip(1) .takewhile(day => day != dayofweek.saturday) .tolist(); i proceed test such: foreach (var day in daysofweek) { debug.writeline(datetime.now.next(day).date.tostring(cultureinfo.cur

sql - createQueryBuilder and setParameter with multiple parameters? -

i've been trying create sql query , keep on having error 2nd parameter. maybe missing here. here request : $pointstef = $this->getdoctrine()->getmanager(); $pointstefs = $pointstef->createquerybuilder('t') ->select('t.points') ->from('appbundle:tef', 't') ->where('t.epreuve = :epreuve') ->setparameter('epreuve',$valeur) ->andwhere('t.resultat = :resultat') ->setparameter('resultat',$valeurepreuve) ->getquery() ->getresult(); is proper way of using setparameter(); ? an exception occurred while executing 'select t0_.points points_0 tef t0_ t0_.epreuve = ? , t0_.resultat = ?' params ["ce", "b1"]: sqlstate[hy093]: invalid parameter number: columns/parameters 1-based do this ->se

cant write text file in c -

im trying learn c, i'm using tutorialspoint, , function give me doesn't on computer, function is: #include <stdio.h> int main (){ file *fp; fp = fopen("/tmp/test.txt", "w+"); fprintf(fp, "this testing fprintf...\n"); fputs("this testing fputs...\n", fp); fclose(fp); } am missing something? it introduce error checking file streams do fp = fopen("test.txt", "w+"); /* * try creating file in same folder start */ if(fp!=null) { fprintf(fp, "this testing fprintf...\n"); fputs("this testing fputs...\n", fp); } else { /* there multiple reasons can't open file : * don't have permission open * parent directory doesn't exist , on. */ printf("can't open file write\n"); } fclose(fp);

Get PHP Last Loop Counter and Apply to jQuery Initial Counter Value -

i new php & jquery , constructing repeater field wordpress site skip how build it. right now, trying figure out answer on how last loop counter in php foreach loop , apply last counter number initial counter value jquery variable. i'm not sure if possible because trying using server-side data client-side processing. that's intro, here example php code:- $x = -1; foreach ($something $some){ $x++; // let $some has total of 3, $x provide counter such 0, 1 & 2 } and trying apply last php counter value jquery initial counter value continue count:- var x = *the last php counter 2*; var max = 20; if(x < max){ x++; // 'x' continue count 3, 4, 5,... } i've been trying many methods before , futile. right think thing need figure out first how retrieve php loop counter outside loop, guess... while figuring out, thankful guys if guys able me new stuff. edit:- it seems using '<?php echo $x; ?>'; displaying value in jquery makes

stata - How to overwrite a duplicate observation -

i conducted phone survey , here prototype of dataset: var1 var2 6666 1 6666 2 7676 2 7676 1 8876 1 8876 2 89898 1 89898 2 9999 1 9999 2 5656 1 5656 2 2323 1 2323 2 9876 1 7654 1 var1 unique identifier each case in survey (in case, phone numbers). var2 outcome of survey: 1 (successful), 2 (not successful). i want keep observations each var1 var2 == 1 , yet retaining observations each var1 whose var2 == 2 if there no case var2 == 1 . i have tried duplicates drop var1 if var2 == 2, force but not getting desired output the question wrongly titled: don't want overwrite anything. your syntax doesn't work wish because not want. asking whether there duplicates of var1 if var2 == 2 , command pays no attention whatsoever observations var2 == 1 . your example includes no observations var2 == 2 there no corresponding observation var2 == 1 . have added 1 such. here's 1 way of meeting goal. show in

pillow - Django. Download Image with requests - edit with PIL - save to model -

i'm having trouble process: want download image using requests , crop pil , save model imagefield . this have now: from django.core.files.base import contentfile import requests stringio import stringio pil import image def get_img_url(url_img): answer = requests.get(url_img) image = image.open(stringio(answer.content)) new_image = image.crop((22, 44, 221, 165)) return image class formnewcard(forms.modelform): .... def save(self, **kwargs): url_image = self.cleaned_data['imagen'] pil_img = get_img_url(url_img) stringio_obj = stringio() try: pil_img.save(stringio_obj, format="jpg") final_image = stringio_obj.getvalue() self.image = contentfile(final_image) finally: stringio_obj.close() i error: pil_img.save(stringio_obj, format="jpg") keyerror @ /hisoka/new_card/ 'jpg' i know error purely pil prob

microsoft cognitive - Transcribe MP3 audio file with Bing Speech API (speech to text) -

i have long recording (hour+) in format of mp3. following info managed ffmpeg audio file: [mp3 @ 000001fe666da320] skipping 0 bytes of junk @ 58650. [mjpeg @ 000001fe666effe0] changing bps 8 [mp3 @ 000001fe666da320] estimating duration bitrate, may inaccurate input #0, mp3, '1.mp3': duration: 00:57:18.52, start: 0.000000, bitrate: 192 kb/s stream #0:0: audio: mp3, 44100 hz, mono, s16p, 192 kb/s stream #0:1: video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1300x1370, 90k tbr, 90k tbn, 90k tbc i use bing speech api (microsoft oxford - cognitive services - speech api) transcribe file (speech text). i believe achievable using code below. option 1: before sending audio data, must first send speechaudioformat descriptor describe layout , format of raw audio data via datarecognitionclient's sendaudioformat() method. can provide code sample option? option 2: converting file target's acceptable format. have done ffmpeg , got: duration: 00:57:23.67

javascript - How to merge more than 2 DOM objects using jQuery? -

is possible merge 3 or more dom objects in jquery? found solution here in stackoverflow, merging 2 objects: merging jquery objects my example: var input1 = $('.input-1'), input2 = $('#parent-div input'), input3 = $('.input-3'), input4 = $('.input-4'), input5 = $('.input-5') merge([input1, input2, input3, input4]).val('my custom input text'); in case have several inputs want merge few of them. can use $.add() in following way: $(document).ready(function(){ var input1 = $('.input-1'); var input2 = $('#parent-div input'); var input3 = $('.input-3'); var input4 = $('.input-4'); var input5 = $('.input-5'); var collection = $( input1 ); // capture new collection collection = collection.add( input2).add(input3).add(input4); collection.val('my custom input text'); }); <script src="https://ajax.googleapis.co

playframework - Play.current is deprecated in play 2.5 -

i using play.current in following way. import play.api.{logger, play} object applicationconfig { val app = play.current def getconfint(key: string): option[int] = { val result = app.configuration.getint(key) result } } since migrating 2.5, have warning saying deprecated "this static reference application, use di instead" however, doc doesn't how supposed use di instead. thanks depending on use case should use environment , applicationlifecycle , configuration instead of application in case interested in configuration way in play 2.5.x this: class homecontroller @inject() (configuration: play.api.configuration) extends controller { def config = action { ok(configuration.underlying.getint("some.config.key")) } } the example provided controller can use approach on other places in application. didn't applicationconfig object provided - consider refactoring when migrating play 2.5.x - di way go

android - multiple intent's starting by onTouch event -

hey guys getting start intent if user clicks on specific location.at first touch opens menu , on second opens activity.the problem many copy's of same intent started import android.app.activity; import android.content.context; import android.content.intent; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.paint.align; import android.os.bundle; import android.text.textpaint; import android.view.motionevent; import android.view.view; import android.view.view.ontouchlistener; import android.widget.toast; public class gfx extends activity implements ontouchlistener{ bitmap a,b; gfx1 drw; string a1; boolean flag=false,flag1=false,flag2=false; canvas c1; float x=0,y=0,z=0,bitx=0,bity=0; protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); drw = n

codeigniter - I put the facebook api code in my view but it does not displaying the result -

<?php $fb = new facebook\facebook([ 'app_id' => '1784359588500732', // replace {app-id} app id 'app_secret' => '30138893272d147c8388759e4da8951a', 'default_graph_version' => 'v2.2', ]); $helper = $fb->getredirectloginhelper(); $permissions = ['sabat989@gmail.com']; // optional permissions $loginurl = $helper->getloginurl('http://dev.solidbrandworks.com/swatchmumbai/fb-callback.php', $permissions); echo '<a href="' . htmlspecialchars($loginurl) . '">log in facebook!</a>'; ?>

php - New Quote id generate on every time of getQuote() in magento -

Image
when try cart items using getquote() method like mage::getmodel('checkout/cart')->getquote(); it generates new quote id on every time of line call. sales_flat_quote table growing rapidly & make looping! , show below error! plz check screenshot! fatal error: maximum function nesting level of '6000' reached, aborting! this issue occurs times , customers only. if check in system, showing fine! rectify automatically after times. can't understand why happening. any advice or suggestions appreciated! tl;dr : disabled xdebug , fine. this error message comes xdebug extension. php not have function nesting limit. change the setting in php.ini: xdebug.max_nesting_level = 10000 or in php code: ini_set('xdebug.max_nesting_level', 10000); as if need change (i.e.: if there's alternative solution recursive function), can't tell without code.

android studio - IdeaVim : Navigate through project file -

Image
is possible plugin ideavim intellij navigate thourgh project file (in window below) using hjkl key ? ctrlp plugin vim. if you're looking ctrlp equivalent, webstorm has fuzzy finder that's more powerful ctrlp. try command+shift+o (the letter o) on mac or ctrl+shift+n on windows/linux. there more here: https://www.jetbrains.com/help/phpstorm/2016.1/navigating-to-class-file-or-symbol-by-name.html?origin=old_help#d937859e425

Getting rid of extra output in JAVA While Loop -

i have question program wrote class. functioning way need except 1 minor detail. while-loop adding "+" on end of print statement. public class fractions { public static void main (string[] args) { //-----declare variables----- int numoffractions = 0, numerator = 0; double total = 0; decimalformat df1 = new decimalformat("#0.##"); scanner stdin = new scanner(system.in); //----welcome msg------ system.out.println(""); system.out.println("\t* * * welcome fractions * * * "); system.out.println(""); //-----get numoffractions------ system.out.print("enter number of fractions: "); numoffractions = stdin.nextint(); //----begin loop------- numerator = 1; while(numerator <= numoffractions) { while(numoffractions > 0) { system.out

opengl - glReadPixels() not working with textures -

i've been struggling days piece of code in c++ , opengl supposed detect object selection. code worked till introduced textures , see no response. here's code: void mousefunc(int x, int y) { glutsetwindow(id) //i have several subwindows gldisable(gl_lighting); gldisable(gl_color_material); gldisable(gl_texture_2d); gldrawbuffer(gl_back); //code draws single colored figure unsigned char pixel[3]; glint viewport[4]; glgetintergv(gl_viewport, viewport); glreadbuffer(gl_back); glreadpixels(x, viewport[3] - y, 1, 1, gl_rgb, gl_unsigned_byte, pixel); //code comparison between read , stored colors glenable(gl_lighting); glenable(gl_color_material); glenable(gl_texture_2d); }

amazon web services - Creative ways of combing different AWS products -

i have started using ec2, dynamodb, lambda, sns, cognito port away parse , more research different aws products seems many people coming creative ways structure end efficient & cheap. there creative way you've seem people work aws products surprised you?

android - Best Place to Put "Auto Start" another activity code? -

my android application(application a) launches application (say application b) upon click of button . now want implement "auto start" functionality wherein application b launched application launched. this, created checkbox , used sharedpreferences store value of checkbox. then, in oncreate() method of activity a, checking value of checkbox sharedpreferences , launching application b in case value "true". the problem: the problem facing is, when user exits "application b" (and comes application a) oncreate() of application getting called again , application b opens again. sets off infinite loop , @ exit of application b, user returns application , goes application b again. i know oncreate() gets called multiple times (when change orientation, keyboard opened, activity goes background , killed system), there clean way of doing this? to reiterate, requirement launch application b application if "auto start" checkbox checked in a

oracle - PL/SQL "WHERE CURRENT OF" vs "ROWID" -

why oracle made "where current of" syntax when can use "rowid"? example: begin rec in (select t.column1, t.rowid rid test_table) loop update test_table tb set column1 = some_function(rec.column1) tb.rowid = rec.rid; end loop; commit; end; declare cursor cur select t.column1 test_table; param1 test_table.column1%type; begin loop fetch cur param1; update test_table tb set tb.column1 = some_function(param1) current of cur; exit when cur%notfound; end loop; commit; end; where current of used identify last fetched row in cursor. it's more safe, because have 100% confidence, f.e. updating last fetched row curosr. rowids there's danger, because it's easy mess something.

java - Microsoft][ODBC Driver Manager] Invalid string or buffer length -

package project; import java.awt.font; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jcombobox; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jtextfield; import java.sql.*; import javax.swing.joptionpane; public class newadmition implements actionlistener { private jframe f; private jlabel lb,lb1,lb2,lb3,lb4,lb5,lb6,lb7; private jbutton bt,bt2,bt3; private jtextfield tx1,tx3,tx4,tx5,tx6; private jcombobox cb,cb2; private connection con; string s[] ={"6","7","8","9","10","11","12"}; string g[]={"jalandhar","ludhiana","chandigarh","patiala"}; public newadmition() { f=new jframe("new admition"); lb=new jlabel("enter required information"); lb.setfont(new font("serif",font.plain, 1

algorithm - creating a spiral array in python? -

Image
me , mate trying create fun game in python elements entered in array accessed in spiral manner. have tried few methods 1 given below ( source ). def spiral(x, y): x = y = 0 dx = 0 dy = -1 in range(max(x, y)**2): if (-x/2 < x <= x/2) , (-y/2 < y <= y/2): print (x, y) # stuff... if x == y or (x < 0 , x == -y) or (x > 0 , x == 1-y): dx, dy = -dy, dx x, y = x+dx, y+dy the above statement accesses elements in spiral loop , prints them defined array ae. know how can transform given array ae spiral 1 you can build spiral starting near center of matrix , turning right unless element has been visited already: #!/usr/bin/env python north, s, w, e = (0, -1), (0, 1), (-1, 0), (1, 0) # directions turn_right = {north: e, e: s, s: w, w: north} # old -> new direction def spiral(width, height): if width < 1 or height < 1: raise valueerror x, y = width // 2, height // 2 # start near center d

javascript - Open inner page of other application by bypassing login -

i have situation in project rewriting existing application make adaptable tablet devices. i need point page of existing version of application, until new version created. existing application deployed on separate domain. i able launch existing application new 1 passing encoded url parameters , able reach home page. however want launch inner page directly without making user land on home page , navigate inner page. if fire inner page url directly, existing application not support , throws exception. i existing app developed vendor , client not have budget start development there support requirement out of box. url1: login application http://xxx/app2/?d=4olzhy03ap19r7ra3hynx0b&dealercode=e39deef760e709&u=cefe3539da6563&module=&ut=c96eb15332510b&accesslevel=none url2: open inner page http://xxx/app2/search.do?finalpage=leases&lm_categoryid=11&lm_subcategoryid=193 one way have achieved first open url1 in browser , after delay of 5 sec, o

c# - How to determine if a Property has changed through User Input -

i'm writing program gets person data database , let user modify data in view. public class person : basemodel { public int id { get; set; } #region required properties [required] public string firstname { get; set; } [required] public string lastname { get; set; } [required] public virtual department department { get; set; } #region not mapped [notmapped] public override bool isdirty { { return _isdirty || department.isdirty; } } #endregion public override string tostring() { return $"{firstname} {lastname} ({department.tostring()})"; } } - public class basemodel : inotifypropertychanged { public event propertychangedeventhandler propertychanged; [notmapped] internal bool _isdirty; public virtual bool isdirty { { return _isdirty; } } public void onpropertychanged(string propertyname) { _i

c# - Embed a control inside a Tooltip in WinForms -

Image
is possible add control tooltip? im trying achieve tooltip shows example data in datagridview inside tooltip. what have done far following: i have created table settings (datagridview name (text), type (text), example (image), , setting (combobox). i managed show tooltip example string onmouseover example image. i'd embed datagridview in tooltip because examples in table form. tooltips limited. the solution create custom tooltip. form , make tooltip , put on want. you can make tooltip can show , hide event handlers on datagrid.

How to use rss feeds as Blog post and its topic in umbraco -

i have blog post of rss feeds of particular url, whenever new topic added rss, new blog post should automatically created. i have in umbraco. does have workaround. since require scheduled service of kind there 1 option if use umbraco use umbraco scheduled tasks read more @ http://our.umbraco.org/wiki/install-and-setup/scheduled-tasks , there http://our.umbraco.org/projects/developer-tools/taskscheduler brings bit more power scheduled tasks in umbraco. depending on umbraco-version (which didn't state) page (blog) creation can vary, here pretty nice sample http://en.wikibooks.org/wiki/umbraco/samples_and_articles/creating_umbraco_pages_programmatically so process be create aspx page required logic work rss-feeds when new post in rss-feed detected invoke code creates new page/blog

javascript - ASP.NET prevent browser 'back' -

i'm trying find solution problem i'm facing asp.net application (c# / mysql backend). the application uses webforms in multi step wizard insert data sql database, various steps javascript driven no 'submit' done until 'last' step. in circumstances anyway if user click browser 'back' button after 'last' step form resubmitted , sql insert triggered again creating dupes of original record. i tought use ajax based mechanism track steps of form until wizard reach 'last' step. after trough same ajax function prevent resubmit of form preventing dupes. i don't want use javascript tricks disable button obvious reasons. the main problem of solution don't , quite difficult implement since wizards on application form quite articulated , may cause problem. is there 'best practice' prevent such issues without building complex infrastructures? i'm not posting code because think misleading , unnecessary. best regards