Skip to content

Instantly share code, notes, and snippets.

@bradfitz
bradfitz / gist:1080626
Created July 13, 2011 16:05
Optional parameters in Go hack
// A cute hack demonstrating one (weird?) way of doing optional
// parameters in Go.
//
// Please don't write code like this. It is fun code, though.
//
// Output: (see it live at golang.org)
//
// I like cheese.
// Do you like cheese too?
// I DO!
@jvcleave
jvcleave / gist:1813851
Created February 13, 2012 05:10
beaglebone write image
DON'T JUST COPY AND PASTE
YOUR USB DRIVE MAY NOT BE /dev/sdd AND THIS WILL ERASE IT
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda7 7.4G 3.9G 3.2G 56% /
none 3.9G 720K 3.9G 1% /dev
none 3.9G 704K 3.9G 1% /dev/shm
none 3.9G 96K 3.9G 1% /var/run
none 3.9G 0 3.9G 0% /var/lock
start = Time.now
loop {
elapsed = Time.now - start
puts "#{(elapsed/60).round}m:#{(elapsed%60).round}s"
sleep 1
}
@crisward
crisward / mess.cr
Last active October 21, 2016 13:54
kemal mysql
require "./mess/*"
require "kemal"
require "json"
require "mysql"
require "pool/connection"
db = ConnectionPool.new(capacity: 25, timeout: 0.01) do
DB.open(ENV["DATABASE_URL"])
end
@tim-peterson
tim-peterson / Go Revel nginx.conf
Last active March 10, 2018 04:10
Revel Framework nginx.conf to make Revel app work outside of localhost, i.e., on my live, personal-website.com
http{
index index.html;
server {
listen 80;
root /gocode/src/personalwebsiteapp;
server_name personal-website.com;
@dannycoates
dannycoates / broken.js
Created September 15, 2011 19:27
ssl test
var http = require('http'), // intentionally using http to connect to https
options = {
host: 'localhost',
port: 4443,
path: '/ping',
};
function pingLoop() {
http.get(options, function (res) {
console.assert(false, "server should never accept http over https");
@jgaskins
jgaskins / server.cr
Last active December 4, 2019 05:30
Serve a sample JSON payload in Crystal
require "http"
require "uuid"
require "uuid/json"
class App
include HTTP::Handler
def call(context)
Fiber.yield # Simulate getting data from the DB
response_payload.to_json context.response
@maxinspace
maxinspace / readme.txt
Created October 20, 2015 11:03
Google Authenticator from Terminal
This instruction will allow you to get keys from Google Authenticator via terminal.
1) Download oathtool
brew install oathtool
http://www.nongnu.org/oath-toolkit/oathtool.1.html
2) Get your 2-Factor authentication secret key.
For example, instead of capturing barcode, ask Google 2-factor auth to enter code manually.
And google 2-factor auth will provide you your secret key.
@dannyid
dannyid / seek.js
Last active March 6, 2021 22:47
Netflix Seek
// The player
var player = netflix.cadmium.objects.videoPlayer();
// Metadata about current episode -- ID and url to get frame at a specific time
var episodeId = netflix.cadmium.metadata.getActiveVideo().episodeId;
var imgRoot = netflix.cadmium.metadata.getActiveVideo().progressImageRoot;
// Generates URL of preview image for given timestamp
function getFrame(timestamp) {
var t = Math.floor(timestamp/10000).toString(10);
@therealmarv
therealmarv / checkopenssl.md
Last active October 12, 2021 19:14
Check OpenSSL version from Python

Open python

python

and type

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.1g 7 Apr 2014'