Skip to content

Instantly share code, notes, and snippets.

@makenova
makenova / InjectBigWiki.js
Last active December 25, 2015 08:28
A bookmarklet that hides all the sidebar and header crap on wikipedia, it puts the content front and center with the find bar in the top right corner so you can navigate to other articles.
javascript:(function(){
_my_script=document.createElement('script');
_my_script.type='text/javascript';
_my_script.src='https://gist.github.com/makenova/6946529/raw/46390be80f63d4269602231d79fe2e952559ccbd/bigwiki.js';
document.getElementsByTagName('head')[0].appendChild(_my_script);
})();
@makenova
makenova / Difference between debounce and throttle.md
Last active February 22, 2023 03:09
Javascript function debounce and throttle

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

This is the test

The quck brown fox jumped over the lazy dog.

This is a sub heading

This is a second test paragraph. I am writing words that will appear on a page.

@makenova
makenova / jsScope.md
Created April 15, 2014 20:44
Notes from JSconf video on JS scope

A Little This, a Little _that: Understanding Scope in JavaScript

These are notes I made while watching this video by David Aragon from jQuery conf 2014. He was kind enough to share his slides here.
I have copied some of his examples form the slides to provide context for my notes, some of them have been slightly modified. Any errors, are likely my own. Caveat Lector.

Scope

JS uses functional scope not block scope like C or Scala, e.g. the if(){} 'block' is not its own scope

@makenova
makenova / Question.md
Last active August 29, 2015 13:59
JS callback async confusion

What makes a JS function async?

Is it possible to write a custom asynchronous function without the use of JS's timer functions such as setTimeout and setInterval ?

I have two code examples below, one that succeeds(goodboy.js) and one that fails(goodboyfail.js). I originally thought, goodboy.js would fail because I assumed

  1. Simply defining get with a callback function would make it asyncronous
  2. praise would be undefined when it was executed.

However, the console.log messages seem to indicate that the get function executes syncronously. I got the expected behviour in goodboyfail.js by adding a delay.

@makenova
makenova / javascript-under-pressure.md
Created April 27, 2014 06:33
javascript under pressure solutions

These are my solutis that I came up with while doing the JS Challenge at usvsth3m. They were reached 'under pressure' as the title implies, hence there are no optimizations and it looks rough.
The problem description is stated before the solution.

Code as fast as you can! You need to double the integer and return it. To test your code, click Go or hit Ctrl-Enter/⌘-Enter.

function doubleInteger(i) {
@makenova
makenova / constructor_vs_prototype.md
Created May 9, 2014 00:00
Notes on the JavaScript prototype chain

Adding methods on the Constructor vs the prototype

Adding a method on the constructor will duplicate that method for every instance of the object that created, consuming memory but also granting the method access private variables on the object. Adding a method on the prototype will will not duplicate it for new instances, conserving memory while leaving it available to all instances.

// Constructor with greet method directly on it.
var Person = function (name, age) {
@makenova
makenova / okdemo.md
Created July 30, 2014 23:58
OKCoders talk about tooling and the dev experience

Keybase proof

I hereby claim:

  • I am makenova on github.
  • I am makenova (https://keybase.io/makenova) on keybase.
  • I have a public key whose fingerprint is ABA1 B0AE B622 C620 22A6 3014 60B0 E968 3FF9 37AA

To claim this, I am signing this object:

{"answers":["function(console) {\n\tvar names = [\"Ben\", \"Jafar\", \"Matt\", \"Priya\", \"Brian\"],\n\t\tcounter;\n\n\tfor(counter = 0; counter < names.length; counter++) {\n\t\tconsole.log(names[counter]);\n\t}\n}\n\t\t","function(console) {\n\tvar names = [\"Ben\", \"Jafar\", \"Matt\", \"Priya\", \"Brian\"];\n\n\tnames.forEach(function(name) {\n\t\tconsole.log(name);\n\t});\n}\n\t\t","function() {\n\tvar newReleases = [\n\t\t{\n\t\t\t\"id\": 70111470,\n\t\t\t\"title\": \"Die Hard\",\n\t\t\t\"boxart\": \"http://cdn-0.nflximg.com/images/2891/DieHard.jpg\",\n\t\t\t\"uri\": \"http://api.netflix.com/catalog/titles/movies/70111470\",\n\t\t\t\"rating\": [4.0],\n\t\t\t\"bookmark\": []\n\t\t},\n\t\t{\n\t\t\t\"id\": 654356453,\n\t\t\t\"title\": \"Bad Boys\",\n\t\t\t\"boxart\": \"http://cdn-0.nflximg.com/images/2891/BadBoys.jpg\",\n\t\t\t\"uri\": \"http://api.netflix.com/catalog/titles/movies/70111470\",\n\t\t\t\"rating\": [5.0],\n\t\t\t\"bookmark\": [{ id:432534, time:65876586 }]\n\t\t},\n\...he largest rating. Rem