Skip to content

Instantly share code, notes, and snippets.

View Leask's full-sized avatar
🏠
Working from home

Sixia "Leask" Huang Leask

🏠
Working from home
View GitHub Profile
@gruber
gruber / Liberal Regex Pattern for All URLs
Last active May 29, 2024 00:03
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:foo@example.com", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
@liangzan
liangzan / recursiveRemoveFiles.js
Created February 2, 2011 14:12
A Node.js script to remove all files in a directory recursively
var fs = require('fs')
, path = require('path')
, _ = require('underscore');
var rootPath = "/path/to/remove";
removeDirForce(rootPath);
// path should have trailing slash
function removeDirForce(dirPath) {
fs.readdir(dirPath, function(err, files) {
@demonbane
demonbane / makeapp.sh
Created July 5, 2011 20:05
Create a Fluid-style app launcher for single-window Chrome instances on OSX
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name="$inputline"
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url="$inputline"
@forresty
forresty / download_all_tasks.rb
Created October 11, 2011 03:25
A browser script to automatically parse all lixian.vip.xunlei.com file names and URLs
#!/usr/bin/env ruby
require "yaml"
# make sure you have dump cookies to xunlei-cookies.txt
YAML.load_file("all_files.yml").each do |file|
cmd = "wget --load-cookies=xunlei-cookies.txt '#{file[:url]}' -c -O '#{file[:name]}'"
system(cmd)
end
@forresty
forresty / video-list.txt
Created October 16, 2011 14:35
Stanford ML Class Video Links
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.1-Introduction-Welcome.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.b-Introduction-WhatIsMachineLearning.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.3-Introduction-SupervisedLearning.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/01.d-Introduction-UnsupervisedLearning.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.1-LinearRegressionWithOneVariable-ModelRepresentation.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.2-LinearRegressionWithOneVariable-CostFunction.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.3-LinearRegressionWithOneVariable-CostFunctionIntuitionI.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.4-LinearRegressionWithOneVariable-CostFunctionIntuitionII.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.5-LinearRegressionWithOneVariable-GradientDescent.mp4
http://s3.amazonaws.com/stanford_videos/cs229/videos/02.6-LinearRegressionWithOneVariabl
@aemkei
aemkei / LICENSE.txt
Last active April 12, 2024 21:27 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@hrldcpr
hrldcpr / tree.md
Last active May 1, 2024 00:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@DAddYE
DAddYE / hack.sh
Created March 19, 2012 11:31
OSX For Hackers
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://raw.github.com/gist/2108403/hack.sh)"
#
# or run it without prompt questions:
@collinschaafsma
collinschaafsma / gist:2308101
Created April 5, 2012 04:59
FFMPEG Setup
# Add speex, for Red5
brew edit ffmpeg
args << "--enable-libspeex" if Formula.factory('speex').installed?
brew install --use-gcc ffmpeg
# H.264 / ACC
ffmpeg -i video.flv -acodec libfaac -ab 19k -ar 16000 -vsync 1 -async 1 -r 25.0 -b 193k -vcodec libx264 -s 420x340 video.mp4
# VP8 / Vorbis
@fundon
fundon / formatjson.sh
Created April 9, 2012 15:55
use JSON.stringify to pretty-print JSON.
function formatjson() {
local json=""
if [ -p /dev/stdin ]; then
# piping, e.g. `echo '{"foo":42}' | formatjson`
while read -r line; do
json="$json$line"
done
else
# e.g. `formatjson '{"foo":42}'`
json="$*"