Skip to content

Instantly share code, notes, and snippets.

@Coconuthack
Coconuthack / gist:5245942
Created March 26, 2013 14:50
JavaScript: Inheritance John Resig
//Simple Javascript Inheritance - John Resig
//example code
var Person = Class.extend({
init: function(isDancing){
this.dancing = isDancing;
},
dance: function(){
return this.dancing;
}
});
@Coconuthack
Coconuthack / gist:5464200
Created April 26, 2013 00:02
eloquentjs ch 8 bind function
//Bind an inner function to this, same this as outer function
//EloquentJS Ch8
function bind(func, object) {
return function(){
return func.apply(object, arguments);
};
}
//Example
var testArray = [];
@Coconuthack
Coconuthack / gist:5476452
Created April 28, 2013 09:54
Eloquent JS Ch10 Regular Expressions
//EloquentJS CH10 Regex
var slash = /\//;
show("AC/DC".search(slash)); //-> 2
var asteriskOrBrace = /[\{\*]/;//finds any of the '{' or '*' chars
var story =
"We noticed the *giant sloth*, hanging from a giant branch.";
show(story.search(asteriskOrBrace)); //-> 15
@Coconuthack
Coconuthack / gist:5598837
Created May 17, 2013 12:54
Eloquent JS CH12 & 13 DOm and Browser Events
//Eloquent javascript - CH12
//Functions relating to the DOM
//Helper functions form other chapters
function escapeHTML(text) {
var replacements = [["&", "&"], ["\"", """],
["<", "&lt;"], [">", "&gt;"]];
forEach(replacements, function(replace) {
text = text.replace(replace[0], replace[1]);
});
@Coconuthack
Coconuthack / gist:5604388
Created May 18, 2013 13:27
Google Python Class
#Python Google CLass Gist
#hello.py program
#!/usr/bin/python
# import modules used here -- sys is a very standard one
import sys
# Gather our code in a main() function
def main():
@Coconuthack
Coconuthack / gist:5874891
Created June 27, 2013 08:30
JS Def Guide : 15.7 Example: Dynamically Generating a Table of Contents
/**
* TOC.js: create a table of contents for a document.
*
* This module registers an anonymous function that runs automatically
* when the document finishes loading. When it runs, the function first
* looks for a document element with an id of "TOC". If there is no
* such element it creates one at the start of the document.
*
* Next, the function finds all <h1> through <h6> tags, treats them as
* section titles, and creates a table of contents within the TOC
@Coconuthack
Coconuthack / index.html
Last active November 7, 2016 15:55
UD Creative Remix
<div class="def-panel" id="UDDIV_1">
<div id="UDDIV_2">
<div id="UDDIV_4">
Top Definition
</div>
<div class="share small-6 columns" id="UDDIV_5">
<a href="" target="_blank" id="UDA_6">
<i class="svgicon svgicon-ud_twitter" id="UDI_7">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" id="UDsvg_8"><path d="M7.3 8c5.4 2.8 9.9 2.6 9.9 2.6s-1.7-6.2 3.6-8.9 9 1.9 9 1.9.9-.3 1.6-.5c.7-.3 1.7-.7 1.7-.7l-1.6 3 2.5-.3s-.3.5-1.3 1.4l-1.4 1.4s.4 7.4-3.4 13.1c-3.8 5.7-8.7 9.1-15.9 9.9C4.9 31.6.2 28.6.2 28.6s3.1-.2 5.1-1 4.9-2.8 4.9-2.8-4.1-1.3-5.5-2.7c-1.5-1.4-1.8-2.3-1.8-2.3l4-.1s-4.2-2.3-5.4-4.1S0 12.1 0 12.1l3.1 1.3S.5 9.8.2 7s.5-4.3.5-4.3S1.9 5.2 7.3 8z" id="UDpath_9"></path></svg>
</i>

Keybase proof

I hereby claim:

  • I am coconuthack on github.
  • I am dijonkock (https://keybase.io/dijonkock) on keybase.
  • I have a public key ASDild67dSBn5_nsVLCOGG8v1N-JqOCNX1xRPjqmI8S40Ao

To claim this, I am signing this object:

@Coconuthack
Coconuthack / cloudSettings
Last active September 20, 2017 20:24 — forked from spencercarli/bd3d4befe38185704bf0fc875e9deed6|configuration.json
Visual Studio Code Settings Sync Gist from HandleBar Labs
{"lastUpload":"2017-09-07T00:38:49.350Z","extensionVersion":"v2.8.3"}
@Coconuthack
Coconuthack / download.py
Last active December 4, 2017 13:42
Download Data for Practicum 5
import tempfile
import urllib.request as urlreq
train_file = tempfile.NamedTemporaryFile()
test_file = tempfile.NamedTemporaryFile()
urlreq.urlretrieve("https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data", train_file.name)
urlreq.urlretrieve("https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.test", test_file.name)
import pandas as pd
CSV_COLUMNS = [
"age", "workclass", "fnlwgt", "education", "education_num",