Skip to content

Instantly share code, notes, and snippets.

View dongyuwei's full-sized avatar
💭
天天听儿歌

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@ogrrd
ogrrd / dnsmasq OS X.md
Last active April 3, 2025 16:56
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@adamwiggins
adamwiggins / adams-heroku-values.md
Last active November 27, 2024 17:06
My Heroku values

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@creationix
creationix / output.log
Created May 8, 2013 22:02
Working version of generator async code sample. Using node from https://github.com/andywingo/node/tree/v8-3.19
tim@touchsmart:~/Code$ nvm use v0.11.2-generators
Now using node v0.11.2-generators
tim@touchsmart:~/Code$ node --harmony testgen.js
<Buffer 76 61 72 20 66 73 20 3d 20 72 65 71 75 69 72 65 28 27 66 73 27 29 3b 0a 66 75 6e 63 74 69 6f 6e 20 72 65 61 64 46 69 6c 65 28 70 61 74 68 2c 20 65 6e 63 ...>
Sleeping for 2000ms...
Done
@mharsch
mharsch / gist:5188206
Last active March 13, 2025 04:28
serve HLS (HTTP Live Streaming) content from node.js

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on https://gist.github.com/bnerd/2011232

// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config keyboardLayout qwerty
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
@lefant
lefant / pretty_config.erl
Last active June 22, 2020 08:49
a little escript snippet to pretty print erlang config, using the erl_syntax module
#!/usr/bin/env escript
%% -*- erlang -*-
%% * slurp in terms using inlined version of kernels file:consult/1
%% * convert to abstract syntax tree
%% * annotate all tuples
%% * pretty print using a hook to prefix the annotated nodes with newline
main([]) ->
io:format("%% -*-erlang-*-~n"),
@rubenlozano
rubenlozano / gist:4521689
Last active July 26, 2021 13:39
Running JavaScript in OS X terminal
There is a javascript console, called JSC, in:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc
JSC is not in the shell PATH by default, to fix that:
$ sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /usr/local/bin
Note that you'll have to use debug() instead of the conventional console.log() in your script to see any output.
@mbostock
mbostock / .block
Last active February 20, 2025 10:51
Gradient Along Stroke
license: gpl-3.0
@torgeir
torgeir / pingpong.erl
Created October 30, 2012 07:27
Distributed erlang pingpong example
% networked ping
% --
% Open firewall ports 4369 (erlang port mapper) and 9100-9105 (communication ports)
%
% On node 1 start your shell with this command:
% erl -name [email protected] -setcookie cook -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9105
%
% On node 2 start your shell with this command:
% erl -name [email protected] -setcookie cook -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9105
%
@sheerun
sheerun / proxy
Last active December 30, 2024 06:16
Automatic SOCKS proxy setup through SSH connection on Mac OS X
# Script for automatic setup of SOCKS proxy through SSH connection.
# It automatically teardowns SOCKS configuration before stopping.
# It's supposed to work on Mac OS X 10.6+
#
# Author: Adam Stankiewicz (@sheerun)
#
[[ -n "$1" ]] || { echo "Usage: proxy [email protected]"; exit 1; }
# get service GUID and NAME (like Wi-Fi) to set SOCKS proxy