Skip to content

Instantly share code, notes, and snippets.

View GitHub30's full-sized avatar
🌴
On vacation

GitHub30

🌴
On vacation
  • Osaka, Japan
View GitHub Profile
@brettz9
brettz9 / HTMLSelectElement.prototype.selectedOptions.js
Last active July 25, 2019 16:04
selectedOptions shim (multiple select) with IE8 support
/**
* Polyfill for "fixing" IE's lack of support (IE < 9) for applying slice
* on host objects like NamedNodeMap, NodeList, and HTMLCollection
* (technically, since host objects are implementation-dependent,
* IE doesn't need to work this way). Also works on strings,
* fixes IE to allow an explicit undefined for the 2nd argument
* (as in Firefox), and prevents errors when called on other
* DOM objects.
* @license MIT, GPL, do whatever you want
-* @see https://gist.github.com/brettz9/6093105
@zenorocha
zenorocha / README.md
Last active February 10, 2025 07:42
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage

@72lions
72lions / concat.array.buffers.js
Created January 14, 2013 09:22
Concatenates two ArrayBuffers
/**
* Creates a new Uint8Array based on two different ArrayBuffers
*
* @private
* @param {ArrayBuffers} buffer1 The first buffer.
* @param {ArrayBuffers} buffer2 The second buffer.
* @return {ArrayBuffers} The new ArrayBuffer created out of the two.
*/
var _appendBuffer = function(buffer1, buffer2) {
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
@kekscom
kekscom / gist:5053306
Last active May 11, 2025 06:35
JavaScript toLocalISOString() function
function toLocalISOString(d) {
var off = d.getTimezoneOffset();
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes() - off, d.getSeconds(), d.getMilliseconds()).toISOString();
}
@kawanet
kawanet / hiragana-katakana.js
Last active October 15, 2024 03:22
γ‚«γ‚Ώγ‚«γƒŠγ‚’γ²γ‚‰γŒγͺに倉換する JavaScript 閒数、 γ²γ‚‰γŒγͺγ‚’γ‚«γ‚Ώγ‚«γƒŠγ«ε€‰ζ›γ™γ‚‹ JavaScript ι–’ζ•°
/** γ‚«γ‚Ώγ‚«γƒŠγ‚’γ²γ‚‰γŒγͺに倉換する閒数
* @param {String} src - γ‚«γ‚Ώγ‚«γƒŠ
* @returns {String} - γ²γ‚‰γŒγͺ
*/
function katakanaToHiragana(src) {
return src.replace(/[\u30a1-\u30f6]/g, function(match) {
var chr = match.charCodeAt(0) - 0x60;
return String.fromCharCode(chr);
});
@atenni
atenni / README.md
Last active May 5, 2025 08:06
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@christianroman
christianroman / training.sh
Last active November 22, 2024 21:52
Tesseract OCR training new font
#! /bin/bash
# build the environment
mkdir tessenv; cd tessenv
TROOT=`pwd`
mkdir $TROOT/stockfonts; mkdir $TROOT/build; mkdir $TROOT/build/eng
echo "Environment built"
# Get the stock english fonts from Google (old, but they work)
cd $TROOT/stockfonts
GET http://tesseract-ocr.googlecode.com/files/boxtiff-2.01.eng.tar.gz > boxtiff-2.01.eng.tar.gz
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active April 1, 2025 08:06
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
// ==UserScript==
// @version 1.4.1
// @name Hide watched videos on YouTube
// @icon https://www.youtube.com/favicon.ico
// @match https://www.youtube.com/*
// @exclude https://www.youtube.com/embed/*
// @exclude https://www.youtube.com/api/*
// @namespace https://gist.github.com/xPaw/6324624
// @updateURL https://gist.github.com/xPaw/6324624/raw/YoutubeHideWatched.user.js
// @downloadURL https://gist.github.com/xPaw/6324624/raw/YoutubeHideWatched.user.js
@fnielsen
fnielsen / brownzipf.py
Last active November 6, 2022 12:32
Zipf plot from word counts in the Brown corpus
from __future__ import division
from itertools import *
from pylab import *
from nltk.corpus import brown
from string import lower
from collections import Counter
# The data: token counts from the Brown corpus
tokens_with_count = Counter(imap(lower, brown.words()))