Skip to content

Instantly share code, notes, and snippets.

View whitfin's full-sized avatar
🏠
Working from home

Isaac Whitfield whitfin

🏠
Working from home
View GitHub Profile
@bly2k
bly2k / gist:9843335
Created March 28, 2014 21:26
Elasticsearch value_count and cardinality
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test/doc/1 -d '{ "a": "1" }'
curl -XPUT localhost:9200/test/doc/2 -d '{ "a": "1" }'
curl -XPUT localhost:9200/test/doc/3 -d '{ "a": "1" }'
curl -XPOST "localhost:9200/test/_search?search_type=count&pretty" -d '{
"aggs": {
@indragiek
indragiek / RandomNumbers.swift
Last active November 26, 2015 16:26
Random number generator in Swift
public struct RandomNumberGenerator: SequenceType {
let range: Range<Int>
let count: Int
public init(range: Range<Int>, count: Int) {
self.range = range
self.count = count
}
public func generate() -> GeneratorOf<Int> {
@jashkenas
jashkenas / npm-publish-semver.coffee
Last active August 18, 2016 21:10
A little script to publish a "semantic" version of any npm package that uses real version numbers.
#!/usr/bin/env coffee
fs = require 'fs'
sh = require 'execSync'
config = JSON.parse fs.readFileSync 'package.json'
fs.renameSync 'package.json', 'package.json.real'
name = config.name = "#{config.name}-semver"
@opi
opi / Disqus Javascript Callback
Created March 29, 2012 08:12
Disqus Javascript Callback
// In a js file
disqus_config = function() {
this.callbacks.afterRender.push(function() { /* your code */ });
this.callbacks.onNewComment.push(function() { /* your code */ });
/* Available callbacks are afterRender, onInit, onNewComment, onPaginate, onReady, preData, preInit, preReset */
}
extern crate env_logger;
extern crate futures;
extern crate tokio_core;
extern crate net2;
extern crate num_cpus;
use std::env;
use std::io;
use std::net::SocketAddr;
use std::thread;
@ericeijkelenboom
ericeijkelenboom / emr_bootstrap_java_8.sh
Created April 3, 2014 09:39
Bootstrap script for installing Java 8 on an Amazon Elastic MapReduce instance (AMI 3.0.1)
# Check java version
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
if [ "$JAVA_VER" -lt 18 ]
then
# Download jdk 8
echo "Downloading and installing jdk 8"
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.rpm"
# Silent install
@Tasssadar
Tasssadar / flo.xml
Created October 11, 2013 11:43
Manifest for flo, for B2G build
<?xml version="1.0" ?><manifest>
<include name="base-jb.xml"/>
<remote fetch="git://github.com/Tasssadar/" name="tasssadar"/>
<default remote="caf" revision="refs/tags/android-4.3_r2.1" sync-j="4"/>
<!-- flo specific things -->
<project name="android_device_asus_flo" path="device/asus/flo" remote="tasssadar" revision="b2g-4.3_r2.1" />
<project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon"/>
@bitwalker
bitwalker / config.ex
Created July 19, 2016 23:00
Useful config wrapper for Elixir
defmodule Config do
@moduledoc """
This module handles fetching values from the config with some additional niceties
"""
@doc """
Fetches a value from the config, or from the environment if {:system, "VAR"}
is provided.
An optional default value can be provided if desired.
@tkh44
tkh44 / FileController.js
Last active March 10, 2020 09:04
Simple file upload for sails.js
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
@zedar
zedar / ApacheHadoop_NativeLibs.adoc
Last active August 13, 2020 00:59
Add native libraries to Apache Hadoop installation

Apache Hadoop - add native libraries

If native libraries are not available the following message is displayed with every hadoop command: hadoop checknative

WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  • Clone hadoop source code