Skip to content

Instantly share code, notes, and snippets.

Thorsten Ball mrnugget

Block or report user

Report or block mrnugget

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@maxim
maxim / rails_load_path_tips.md
Last active May 17, 2019
How to use rails load paths, app, and lib directories.
View rails_load_path_tips.md

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@tobstarr
tobstarr / Dockerfile
Last active Nov 2, 2018
Jenkins for go projects with docker
View Dockerfile
FROM ubuntu:12.04
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-6-jdk curl git-core build-essential bzr
RUN mkdir -p /tmp/downloads
# install go
RUN curl -sf -o /tmp/downloads/go1.1.1.linux-amd64.tar.gz -L https://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz
RUN mkdir -p /opt && cd /opt && tar xfz /tmp/downloads/go1.1.1.linux-amd64.tar.gz
# install jenkins
RUN curl -sf -o /opt/jenkins-1.523.war -L http://mirrors.jenkins-ci.org/war/1.523/jenkins.war
@pmarreck
pmarreck / teststack.rb
Last active Dec 19, 2015
TestStack, a cheap zeus-like bit of code to preload your stack for your iterative test running. Based on ideas from Jesse Storimer.
View teststack.rb
#!/usr/bin/env ruby
# Teststack: A way to preload your Rails app stack for your iterative test running
# Based on ideas from Jesse Storimer here:
# http://www.jstorimer.com/blogs/workingwithcode/8136295-screencast-faster-rails-test-runs-with-unix
# https://gist.github.com/jstorimer/5862436
# Usage: Run this file without args to run the server; run it with test file args to connect to the server and run tests
require 'socket'
@mislav
mislav / _readme.md
Last active Aug 3, 2019
tmux-vim integration to transparently switch between tmux panes and vim split windows
View _readme.md

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@mislav
mislav / OpenSSL fix.md
Last active May 9, 2019
Fix OpenSSL certificate errors on Ruby 2.0
View OpenSSL fix.md

The reason why you might get certificate errors in Ruby 2.0 when talking HTTPS is because there isn't a default certificate bundle that OpenSSL (which was used when building Ruby) trusts.

Update: this problem is solved in edge versions of rbenv and RVM.

$ ruby -rnet/https -e "Net::HTTP.get URI('https://github.com')"
net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3
  read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

You can work around the issue by installing a certificate bundle that you trust. I trust Mozilla and curl.

@mislav
mislav / fat-logfiles.sh
Last active Dec 22, 2018
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
View fat-logfiles.sh
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
@mislav
mislav / procs-vs-lambda.md
Last active Apr 24, 2019
Jim Weirich on the differences between procs and lambdas in Ruby
View procs-vs-lambda.md

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

@mike-zhang
mike-zhang / udpProxy.go
Created Oct 8, 2012
Implementation of a UDP proxy in Golang
View udpProxy.go
// Implementation of a UDP proxy
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
@jedy
jedy / go_scp.go
Last active May 9, 2019
an example of scp in golang
View go_scp.go
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"fmt"
"golang.org/x/crypto/ssh"
)
const privateKey = `content of id_rsa`
@janl
janl / gist:3110170
Created Jul 14, 2012
CoUp Coffee Chemex Guide
View gist:3110170

Chemex Quick Guide

Not this is rocket sience :)

Water

Fill the water heater with a finger more than 1 liter of water. Set it on its power-base, hit the button that’s all the way out on the handle. This starts the heating process. Now hit the “minus” (“-”) button so you see a red light on the 90° marker. Let it heat up. In the meantime:

Beans

You can’t perform that action at this time.