Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Alejandro agaviria

:octocat:
View GitHub Profile
@NoraCodes
NoraCodes / work_queue.rs
Last active Jan 24, 2022
An example of a parallel work scheduling system using only the Rust standard library
View work_queue.rs
// Here is an extremely simple version of work scheduling for multiple
// processors.
//
// The Problem:
// We have a lot of numbers that need to be math'ed. Doing this on one
// CPU core is slow. We have 4 CPU cores. We would thus like to use those
// cores to do math, because it will be a little less slow (ideally
// 4 times faster actually).
//
// The Solution:
@BretFisher
BretFisher / pcat-install.sh
Last active Aug 11, 2021
On macOS: Install pygmentize and alias pcat for shell code syntax highlighting
View pcat-install.sh
# first install pygmentize to the mac OS X or macOS system with the built-in python
sudo easy_install Pygments
# then add alias to your ~/.bash_profile or ~/.bashrc or ~/.zshrc etc.
alias pcat='pygmentize -f terminal256 -O style=native -g'
@mschoebel
mschoebel / main.go
Created Mar 6, 2014
Snippet: login/logout (Golang)
View main.go
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
@cjyar
cjyar / memoize.go
Created Dec 1, 2013
Generic memoizer in Go.
View memoize.go
package memoize
import (
"fmt"
"reflect"
)
// fptr is a pointer to a function variable which will receive a
// memoized wrapper around function impl. Impl must have 1 or more
// arguments, all of which must be usable as map keys; and it must
@wsargent
wsargent / docker_cheat.md
Last active Nov 11, 2021
Docker cheat sheet
View docker_cheat.md
View Encbox.md

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
View tmux_local_static_install.sh
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
# create our directories
@StarpTech
StarpTech / getJSONVal.go
Last active Dec 14, 2015
Get nested JSON value dynamically by tail-recursion and type-assertions
View getJSONVal.go
package main
import (
"fmt"
)
func GetStructField(f interface{},path []string) interface{} {
rangeOver := f.( map[string]interface{})
counter := 0
maxLen := len(path)-1
@lifepillar
lifepillar / Rakefile
Created Nov 3, 2012
Rake tasks for simple personal reporting in Ledger
View Rakefile
# -*- coding: utf-8 -*-
# 2012-11-12
require 'rubygems' if RUBY_VERSION < "1.9"
require 'shellwords'
DEFAULT_CURRENCY = '$'
ASSETS = '^asset'
LIABILITIES = '^liab'
CREDIT_CARD = 'liabilities:credit card'
INCOME = '^income'