Skip to content

Instantly share code, notes, and snippets.

@neumino
neumino / gist:7903626
Created December 11, 2013 01:30
@bencevans - Twitter - 2013/12/10
r.db("ScrobbleGraph").table("scrobbles").groupedMapReduce(
function(doc) { return doc("date").date() },
function(doc) { return [doc] },
function(left, right) { return left.add(right)}
)
// It's better to use just an orderBy and group on the client because
// - The database won't have to keep everything in memory
// - It's faster because of the index
@rowanmanning
rowanmanning / README.md
Created January 19, 2014 10:57
Example README for talk: "UX For Your Node Modules"

Paddington

A small library for padding strings in JavaScript. Marmalade-free.

NOTE: PADDINGTON IS NO LONGER UNDER ACTIVE DEVELOPMENT.
If you're interested in maintaining Paddington, please get in touch via GitHub.

Current Version: 1.0.0

@andrewharvey
andrewharvey / log-active-x11-window.sh
Created November 1, 2012 11:32
shell script to log details of the current active X11 window
#!/bin/sh
# = About =
# This script when run will log details of the current active X11 window.
# Useful for logging/graphing how much time is spent in different apps.
# = Usage =
# If --datetime is present as the first argument, the log line will include the
# date and time.
#

ARCHITECTURE

cabal clients
  cabal-core

cabal-core
  discovery-swarm
    dat-swarm-defaults
  kappa-view-level
 kappa-core
@mpasternacki
mpasternacki / docker-compile.pl
Last active March 23, 2020 14:05
Perl script to build a Docker image from Dockerfile that creates the image in a single layer, without any intermediate images. Needs JSON CPAN module (available as `libjson-perl` Debian/Ubuntu package). Usage: run the script in the directory that contains a Dockerfile. More details in a blog post: http://3ofcoins.net/2013/09/22/flat-docker-images/
#!/usr/bin/env perl
use feature 'switch';
use strict;
use warnings;
use Data::Dumper;
use File::Basename;
use File::Copy;
use File::Path qw/make_path/;
@crofty
crofty / index.html
Last active October 22, 2021 08:24
A example of using Google Map tiles with the Leaflet mapping library - http://matchingnotes.com/using-google-map-tiles-with-leaflet
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script>
</head>
<body>
@max-mapper
max-mapper / readme.md
Last active May 21, 2022 11:02
ffmpeg youtube live event rtmp stream from raspberry pi with raspi camera (raspivid)
  1. compile ffmpeg for arm https://github.com/fiorix/ffmpeg-arm
  2. create youtube 'live event'. get rtmp url + session id
  3. run this:
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/<SESSION>

you can tweak -b and -fps to your liking. the settings above work well for 1080p. by not specifying width or height we get the full 1920x1080 resolution from the raspi camera

// to compile (using mingw-w64)
// g++ this_filename.c -lole32
// outputs current system volume (out of 0-100) to stdout, ex: output "23"
// mostly gleaned from examples here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd370839(v=vs.85).aspx
// download a compiled version here:
// https://sourceforge.net/projects/mplayer-edl/files/adjust_get_current_system_volume_vista_plus.exe.exe (updated, can set it too now!)
#include <windows.h>
#include <commctrl.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
@TooTallNate
TooTallNate / endianness.js
Created February 10, 2013 20:32
Get host machine endianness using JavaScript Typed Arrays (polyfill for `os.endianness()` in node.js)
function endianness () {
var b = new ArrayBuffer(4);
var a = new Uint32Array(b);
var c = new Uint8Array(b);
a[0] = 0xdeadbeef;
if (c[0] == 0xef) return 'LE';
if (c[0] == 0xde) return 'BE';
throw new Error('unknown endianness');
}
@estliberitas
estliberitas / reset.js
Created January 3, 2013 23:27
Node.js script which makes Tor change identity (i.e. IP address)
/**
* Created with IntelliJ IDEA.
* User: Alexander <estliberitas> Makarenko
* Date: 04.01.13
* Time: 3:25
*/
'use strict';
var fs = require('fs')
, net = require('net')