Skip to content

Instantly share code, notes, and snippets.

@padenot
padenot / stream.js
Created October 29, 2011 16:33
How to serve media on node.js
var http = require('http');
var path = require('path');
var fs = require('fs');
var AUDIOFILE = "./audio.ogg";
function serveWithRanges(request, response, content) {
var range = request.headers.range;
var total = content.length;
var parts = range.replace(/bytes=/, "").split("-");
@btoone
btoone / curl.md
Last active June 29, 2024 16:01
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@lotem
lotem / default.custom.yaml
Last active January 25, 2024 08:47
在Rime輸入方案選單中添加五筆、雙拼、粵拼、注音,保留你需要的
# default.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
patch:
schema_list:
- schema: luna_pinyin # 朙月拼音
- schema: luna_pinyin_simp # 朙月拼音 简化字模式
@tiye
tiye / default.custom.yaml
Created September 23, 2012 06:04
尝试了下 Rime 输入法
# Rime setting
patch:
"menu/page_size": 9
schema_list:
- schema: luna_pinyin
- schema: cangjie5
- schema: luna_pinyin_fluency
- schema: luna_pinyin_simp
- schema: double_pinyin_flypy
@justinspradlin
justinspradlin / dropbox-chrome-setup.bat
Last active December 11, 2015 01:38
This script will setup DropBox syncing of your Chrome custom stylesheets. This is really useful if you have a custom dev tools stylesheet. More information for custom Dev Tool stylesheets can be found here: http://darcyclarke.me/design/skin-your-chrome-inspector/.
@echo off
:: This script will setup dropbox to sync Chrome's User Stylesheets.
:: It is a shim since Chromium probably won't add this file to Chrome-Sync in the future.
:: See http://code.google.com/p/chromium/issues/detail?id=136479 for more details.
::
:: The main purpose of this script is to sync the style sheet used for Dev Tools.
:: See http://darcyclarke.me/design/skin-your-chrome-inspector/ for more information
:: on stylying your Chrome Dev Tools.
::
@atenni
atenni / README.md
Last active June 20, 2024 22:30
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]

@kmaida
kmaida / convert-UNIX-timestamp.js
Last active March 16, 2023 09:31
Convert a UNIX timestamp to user's local time via JavaScript
function convertTimestamp(timestamp) {
var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ('0' + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2), // Add leading 0.
ampm = 'AM',
time;
@danharper
danharper / background.js
Last active June 29, 2024 19:32
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@nisaacson
nisaacson / .tern-project
Created February 26, 2014 17:23
Use tern with vim for node.js development.
{
"libs": [
"browser",
"underscore",
"jquery"
],
"plugins": {
"node": {}
}
}
@weblancaster
weblancaster / javascript-mobile-device-detection
Created May 15, 2014 20:38
Javascript Mobile device detection
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
}