Skip to content

Instantly share code, notes, and snippets.

View softprops's full-sized avatar
®️
Rustling

Doug Tangren softprops

®️
Rustling
View GitHub Profile
$(function() {
var el = $("#slide-9") // last slide
, stream = new WebSocket("ws://stream.meetup.com/2/photos")
, target_event = 156380082 // http://www.meetup.com/Application-Developers-Alliance-NYC-Meetup/events/156380082/
, target_member = 8157820; // me (doug)
stream.onmessage = function (msg) {
var item = msg.data ? JSON.parse(msg.data) : null;
if (item) {
var event_id = item.photo_album.event ? item.photo_album.event.id : null
, member_id = item.member.member_id
@softprops
softprops / Tailed.scala
Last active August 29, 2015 13:56
wanted: a way to collapse the longer part of a set of long tailed data
/** a shortener for things that may have `long tails` */
case class Tailed[A, B: Numeric](
population: Iterable[A], index: A => B, update: (A, B) => A) {
private val num = implicitly[Numeric[B]]
private lazy val indexed = population.groupBy(index)
def shorten(threshold: Double = .03) = {
val total = num.toDouble(indexed.keys.reduce(num.plus))
def accept(index: B) = (num.toDouble(index) / total) > threshold
val accepted = indexed.filterKeys(accept).values.flatten
var qparam = function(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
#!/bin/sh
# read a java java's manifest file
unzip -p "$@" META-INF/MANIFEST.MF
function createWebSocket () {
var connection = new WebSocket();
var attempts = 1;
connection.onopen = function () {
// reset the tries back to 1 since we have a new connection opened.
attempts = 1;
// ...Your app's logic...
}
@softprops
softprops / jvm_tools.md
Last active August 29, 2015 13:57
some ( not all ) helpful tools the jvm provides out of the box
  • hprof a builtin java agent which dumps profiling info at runtime
  • class sharing class file cache used for faster startup times
  • pack200 unpack200 uber packed jars
  • mission control a Profiling, Monitoring, and Diagnostics Tools Suite
  • jstat performance stats tool
  • jhat heap dump browser
  • jmap memory maps
  • jstack prints stack trace of running process

export pub key

gpg --armor --export <you@host.com>

export private key

gpg --armor --export-secret-key 
case class Url(
_host: String,
_path: Seq[String] = Seq.empty[String],
_query: Map[String, List[String]] = Map.empty[String, List[String]].withDefaultValue(Nil),
_fragment: Option[String] = None,
_scheme: Option[String] = None,
_port: Option[Int] = None) {
def host(host: String) = copy(_host = host)
def param(k: String, v: String) = copy(_query = _query + (k -> (v :: _query(k))))
def path(p: String) = copy(_path = p.split("/").filter(_.nonEmpty).toList)
@softprops
softprops / unix_permissions.txt
Created April 19, 2014 19:29
unix permission explaination in ascii format
( a = all )
+------------+------------+------------+
| u | g | o |
+------------+------------+------------+
| user | group | others |
+------------+------------+------------+
| r | w | x | r | w | x | r | w | x |
+------------+------------+------------+
| 4 | 2 | 1 | 4 | 2 | 1 | 4 | 2 | 1 |
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> def curryme(beep: Int)(boop: String*) = beep * boop.size
curryme: (beep: Int)(boop: String*)Int
scala> val c = curryme(1)_
c: Seq[String] => Int = <function1>