Skip to content

Instantly share code, notes, and snippets.

@karpathy
karpathy / min-char-rnn.py
Last active April 25, 2024 06:24
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@westc
westc / getParamNames.js
Last active February 9, 2022 03:08
Takes a function and returns the names of the parameters for that function.
/**
* Takes a function and returns the names of its parameters.
* @see https://gist.github.com/westc/b9c62d86efc015d1a444#file-getparamnames-js
* @param {Function} fn
* The function for which to get the parameter names.
* @returns {string[] | undefined}
* If `fn` is really a function and when using its `toString()` the parameters
* could be seen as a string then this will be an array of all of the
* parameters in this function. Otherwise `undefined` will be returned.
*/
@pointergr
pointergr / gist:d4cb1609ff03469af011
Created May 26, 2015 07:15
downloading google web fonts
#!/usr/bin/env bash
# vim:noet:sts=4:ts=4:sw=4:tw=120
#=======================================================================================================================
# (c) 2014 Clemens Lang, neverpanic.de
# See https://neverpanic.de/blog/2014/03/19/downloading-google-web-fonts-for-local-hosting/ for details.
#
# With modifications by
# - Chris Jung, campino2k.de, and
# - Robert, github.com/rotx.
@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active April 4, 2024 02:00
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@rmkane
rmkane / README.md
Last active August 29, 2015 14:13
A URL parser written in JavaScript

URL Parser

The following module handles parsing a URL in JavaScript. If this script is run outside of a browser, where the DOM is inaccessible, a regular expression will be executed to parse the provided URL.

Demo

[@JSFiddle][1]

Examples

@westc
westc / param-with-defaults.js
Created December 26, 2014 22:37
Parameterization of an object with the ability to set defaults.
function param(arrFields, callback) {
for (var t, o = {}, defaults = [], len = arrFields.length, i = len; i--;) {
t = o.toString.call(t = arrFields[i]) == '[object Array]' ? t : [t];
defaults[i] = t[1];
arrFields[i] = t[0];
}
return function(fields) {
for (var t, args = arrFields.slice.call(arguments, 0), i = len; i--;) {
args.unshift(fields && (o.hasOwnProperty.call(fields, t=arrFields[i]) ? fields[t] : defaults[i]));
@jcasabona
jcasabona / wordpress-ignore
Last active November 18, 2015 14:56
WordPress Complete .gitignore
## Start .gitignore
*.log
.htaccess
/index.php
license.txt
readme.html
sitemap.xml
sitemap.xml.gz
wp-activate.php
@jarrodirwin
jarrodirwin / storagePolyfill.js
Last active June 21, 2022 14:27 — forked from remy/gist:350433
LocalStorage/SessionStorage Polyfill with Safari Private Browsing support.
// Refer to https://gist.github.com/remy/350433
try {
// Test webstorage existence.
if (!window.localStorage || !window.sessionStorage) throw "exception";
// Test webstorage accessibility - Needed for Safari private browsing.
localStorage.setItem('storage_test', 1);
localStorage.removeItem('storage_test');
} catch(e) {
(function () {
var Storage = function (type) {
@SteveBenner
SteveBenner / html5bp-lean.slim
Created September 25, 2014 11:12
Slim template - Lean version of HTML5 Boilerplate
ruby:
google_analytics_key = 'UA-XXXXXXXX-X' # your key may have more or less characters
page_title = ''
page_description = ''
doctype html
== conditional_html_tags_for_ie_versions 7..8, lang: 'en'
head
meta charset="utf-8"
meta http-equiv="X-UA-Compatible" content="IE=edge; chrome=1"
@SteveBenner
SteveBenner / conditional-html-tags.rb
Last active October 18, 2019 02:58
Helper [tag] for generating one or more HTML tags inside IE conditional comments, in the style of HTML5 Boilerplate
# This is a special tag helper that generates multiple HTML tags in the style of HTML5 Boilerplate,
# meaning each is placed within an IE conditional comment and has special classes applied to it.
# One tag is created for each version of Internet Explorer specified in the first argument.
#
# @see https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/doc/html.md#conditional-html-classes
#
# @note This helper requires a Slim block!
# @note The output of this helper must be HTML escaped!
#
# @param [Range] ie_versions A range of IE versions to generate code for, in which the