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!
@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");
@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
@tototoshi
tototoshi / rownum.sql
Created December 26, 2012 01:14
Grouped LIMIT in PostgreSQL: show the first N rows for each group
-- http://stackoverflow.com/questions/1124603/grouped-limit-in-postgresql-show-the-first-n-rows-for-each-group
-- http://www.postgresql.jp/document/9.2/html/tutorial-window.html
CREATE TABLE empsalary (
depname varchar(10) not null
, empno integer not null
, salary integer not null
);
INSERT INTO empsalary (depname, empno, salary) VALUES ('develop', 11, 5200);
@bokmann
bokmann / JRuby Awesome Performance
Last active August 31, 2023 07:32
brief summary of massive performance improvements with JRuby
# Thee will be more information here when I share the entire problem space I'm working on, but
# in short, this is preview material for my second talk in a series called "What Computer Scientists Know".
# The first talk is on recursion, and goes through several examples., leading up to a problem based
# on a simple puzzle that initial estimates based on performance of a previous puzzle would take years
# to solve on modern computers with the techniques shown in Ruby. That sets the stage for improving the
# performance of that problem with threading, concurrency, and related tuning.
#
# The second talk is on threading and concurrency, touching on algorithmic performance as well.
# Using some knowledge of the problem (board symmetry, illegal moves, etc), we reduce the problem space
# to about .5% of what we initially thought it was. Still, the initial single threaded solution took more
@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;
start = Time.now
loop {
elapsed = Time.now - start
puts "#{(elapsed/60).round}m:#{(elapsed%60).round}s"
sleep 1
}
@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'
@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);

How do I do this thing?

I'm not aware of how to use Google, how do I do this basic thing in Language X?

tagged coding, question

edited by Grammar Nazi (2.5M), asked by 1337z0r (2)

Answer 1 (12)