Skip to content

Instantly share code, notes, and snippets.

View Ravenstine's full-sized avatar

Ten Bitcomb Ravenstine

View GitHub Profile
@willurd
willurd / web-servers.md
Last active May 17, 2024 16:24
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active February 19, 2024 21:55
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');
# coding=UTF-8
from __future__ import division
import nltk
from collections import Counter
# This is a simple tool for adding automatic hashtags into an article title
# Created by Shlomi Babluki
# Sep, 2013
@atelierbram
atelierbram / sass-convert_from-sass-to-scss.sh
Created January 25, 2014 18:31
Convert .sass syntax to .scss in terminal
# http://blog.teamtreehouse.com/the-absolute-beginners-guide-to-sass
# Enter the folder you want to convert in your terminal and type in:
sass-convert --from sass --to scss -R .
# where -R means recursively and . means the current directory.
@joyrexus
joyrexus / README.md
Last active August 21, 2023 16:59
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@mcasperson
mcasperson / gist:11315910
Last active December 3, 2020 07:49
Pandoc Emscripten
Add this to Ghc-Options in pandoc.cabal
-fllvm -keep-llvm-files -fforce-recomp
./emcc <all *.ll files> -o pandoc.js
emcc ./src/Text/Pandoc.ll ./src/Text/Pandoc/Compat/TagSoupEntity.ll ./src/Text/Pandoc/Compat/Monoid.ll ./src/Text/Pandoc/XML.ll ./src/Text/Pandoc/Writers/ICML.ll ./src/Text/Pandoc/Writers/FB2.ll ./src/Text/Pandoc/Writers/Man.ll ./src/Text/Pandoc/Writers/EPUB.ll ./src/Text/Pandoc/Writers/RST.ll ./src/Text/Pandoc/Writers/Docbook.ll ./src/Text/Pandoc/Writers/Org.ll ./src/Text/Pandoc/Writers/Markdown.ll ./src/Text/Pandoc/Writers/HTML.ll ./src/Text/Pandoc/Writers/ConTeXt.ll ./src/Text/Pandoc/Writers/Docx.ll ./src/Text/Pandoc/Writers/Texinfo.ll ./src/Text/Pandoc/Writers/MediaWiki.ll ./src/Text/Pandoc/Writers/Native.ll ./src/Text/Pandoc/Writers/Shared.ll ./src/Text/Pandoc/Writers/OpenDocument.ll ./src/Text/Pandoc/Writers/ODT.ll ./src/Text/Pandoc/Writers/Custom.ll ./src/Text/Pandoc/Writers/OPML.ll ./src/Text/Pandoc/Writers/RTF.ll ./src/Text/Pandoc/Writers/AsciiDoc.ll ./src/Text/Pandoc/Writers/LaTeX.l
@torgeir
torgeir / method-missing-proxy.js
Last active May 17, 2024 03:40
es6 proxies method missing example
/*
What happens?
- `new Type().what` is looked up with a call to `get` on the proxy
- a function is returned that will look up `METHOD_NAME` when called
- `METHOD_NAME` is called because of the `()` behind `new Type().what`
- if `METHOD_NAME` exists on you object, your own function is called
- if not, because of prototypal inheritance, `get` is called again
- `name` is now `METHOD_NAME` and we can throw as we know `METHOD_NAME` is not implemented on the type
credits http://soft.vub.ac.be/~tvcutsem/proxies/
@nateware
nateware / make_favicon.sh
Last active April 8, 2024 05:48
Imagemagick to create favicon.ico with 16x16 and 32x32 sizes in it
# IE is still braindead so still use favicon.ico
convert -resize x16 -gravity center -crop 16x16+0+0 -flatten -colors 256 input.png output-16x16.ico
convert -resize x32 -gravity center -crop 32x32+0+0 -flatten -colors 256 input.png output-32x32.ico
convert output-16x16.ico output-32x32.ico favicon.ico
# Then, HTML needs to specify size="XxY" as largest size due to browser bugs
<link rel="shortcut icon" href="/favicon.ico" sizes="32x32">
@diafygi
diafygi / LICENSE.txt
Last active November 20, 2023 20:59 — forked from 140bytes/LICENSE.txt
Base58 Encoder/Decoder - slightly over 140 bytes, but still pretty useful
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
@TakahikoKawasaki
TakahikoKawasaki / sinatra+thin+ssl.rb
Last active October 19, 2023 14:38
Sinatra + Thin + SSL
#!/usr/bin/env ruby
#
# This code snippet shows how to enable SSL in Sinatra+Thin.
#
require 'sinatra'
require 'thin'
class MyThinBackend < ::Thin::Backends::TcpServer
def initialize(host, port, options)