Skip to content

Instantly share code, notes, and snippets.

View cb372's full-sized avatar

Chris Birchall cb372

View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@terrancesnyder
terrancesnyder / regex-japanese.txt
Created November 7, 2011 14:05
Regex for Japanese
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
@wadey
wadey / iterm2.zsh
Last active March 10, 2024 00:32
Change iTerm2 tab color when using SSH
# Usage:
# source iterm2.zsh
# iTerm2 tab color commands
# https://iterm2.com/documentation-escape-codes.html
if [[ -n "$ITERM_SESSION_ID" ]]; then
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"

Revisiting Tagless Final Interpreters

Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).

The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA

@obolton
obolton / elb-nodejs-ws.md
Last active November 12, 2023 11:49
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@chantastic
chantastic / gulpfile.js
Last active October 13, 2023 03:20
This a script for a Full Stack Talk, given 3/13/14. Feel free to follow along at your own pace.
var gulp = require('gulp');
var coffee = require('gulp-coffee');
gulp.task('scripts', function () {
gulp.src('src/*.coffee')
.pipe(coffee())
.pipe(gulp.dest('./'));
});
gulp.task('watch', function () {
@mjuric
mjuric / kafka-useful-commands.md
Last active September 6, 2023 03:59
Useful Kafka wrangling commands

Utilities you'll care about

All these are already installed on epyc.

  • kafkacat (conda install -c conda-forge kafkacat)

  • kt (grab it from https://github.com/fgeller/kt/releases)

  • kafka-* (come with kafka, if you yum install if from Confluent's repo, or via Docker if you're so inclined). Warning -- JVM based and dreadfully slow.

  • jq (conda install -c conda-forge jq or use your favorite package manager)

@rednaxelafx
rednaxelafx / JDK5u22_client.log
Created August 23, 2011 16:43
PrintCompilation samples running Groovy shell 1.7.7 on different versions of HotSpot VM
1 b java.lang.String::charAt (33 bytes)
2 b java.lang.Math::max (11 bytes)
3 b java.util.jar.Manifest$FastInputStream::readLine (167 bytes)
4 b sun.nio.cs.UTF_8$Decoder::decodeArrayLoop (553 bytes)
5 b java.util.Properties$LineReader::readLine (383 bytes)
6 b java.lang.String::hashCode (60 bytes)
7 b java.lang.String::indexOf (151 bytes)
8 b sun.nio.cs.ext.DoubleByteDecoder::decodeSingle (10 bytes)
9 b java.lang.String::lastIndexOf (156 bytes)
10 b java.lang.String::replace (142 bytes)
@xuwei-k
xuwei-k / build.sbt
Last active June 24, 2021 01:09
show message when sbt build files changed
val buildFiles = SettingKey[Map[File, Seq[Byte]]]("build-files")
buildFiles := getBuildFiles((baseDirectory in ThisBuild).value)
def getBuildFiles(base: File) =
((base * "*.sbt") +++ ((base / "project") ** ("*.scala" | "*.sbt"))).get.map{
f => f -> collection.mutable.WrappedArray.make[Byte](Hash(f))
}.toMap
def changed(base: File, files: Map[File, Seq[Byte]]): Boolean =
@jarosan
jarosan / elasticsearch.rake
Created July 16, 2012 20:37
Elasticsearch reindex task
# Run with: rake environment elasticsearch:reindex
namespace :elasticsearch do
desc "re-index elasticsearch"
task :reindex => :environment do
klass = Place
ENV['CLASS'] = klass.name
ENV['INDEX'] = new_index = klass.tire.index.name << '_' << Time.now.strftime('%Y%m%d%H%M%S')