Skip to content

Instantly share code, notes, and snippets.

@alexmullins
alexmullins / main.go
Last active March 17, 2024 07:26
Concurrent io.MultiWriter Implementation
package main
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"fmt"
"io"
@miku
miku / ff.go
Last active December 6, 2016 22:58
Fuzzy Finder
package main
import (
"fmt"
"regexp"
"sort"
"strings"
)
var Collection = []string{
model_G = nn.Sequential()
model_G:add(nn.JoinTable(2, 2))
model_G:add(cudnn.SpatialConvolutionUpsample(3+1, 64, 7, 7, 1, 1)):add(cudnn.ReLU(true))
model_G:add(nn.SpatialBatchNormalization(64, nil, nil, false))
model_G:add(cudnn.SpatialConvolutionUpsample(64, 368, 7, 7, 1, 4)):add(cudnn.ReLU(true))
model_G:add(nn.SpatialBatchNormalization(368, nil, nil, false))
model_G:add(nn.SpatialDropout(0.5))
model_G:add(cudnn.SpatialConvolutionUpsample(368, 128, 7, 7, 1, 4)):add(cudnn.ReLU(true))
model_G:add(nn.SpatialBatchNormalization(128, nil, nil, false))
model_G:add(nn.FeatureLPPooling(2,2,2,true))
@critiqjo
critiqjo / col_print.py
Created June 16, 2015 07:50
Python: Multi-column printing of a list of strings
def col_print(lines, term_width=80, indent=0, pad=2):
n_lines = len(lines)
if n_lines == 0:
return
col_width = max(len(line) for line in lines)
n_cols = int((term_width + pad - indent)/(col_width + pad))
n_cols = min(n_lines, max(1, n_cols))
col_len = int(n_lines/n_cols) + (0 if n_lines % n_cols == 0 else 1)
@miku
miku / filterfile
Last active December 23, 2015 10:29
filter file by line number
#!/bin/bash
#
# filterline keeps a subset of lines of a file.
#
# cf. http://unix.stackexchange.com/q/209404/376
#
set -eu -o pipefail
if [ "$#" -ne 2 ]; then
echo "Usage: filterline FILE1 FILE2"
@lestoni
lestoni / gist:8c74da455cce3d36eb68
Last active May 3, 2025 20:15
vim folding cheatsheet

via (https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun)

  • zf#j creates a fold from the cursor down # lines.
  • zf/string creates a fold from the cursor to string .
  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.
@alister
alister / DockerRedis_ExportImport_Dump.sh
Created January 27, 2015 21:46
Example of creating a Docker data volume, exporting it, and re-importing it to a completely fresh container
# Create the container - we run 'echo' in the container, and reuse the same as we will be running later
docker run -d -v /data --name redis.data dockerfile/redis echo Data-only container for Redis
# the data container doesn't show up - nothing is running
docker ps
# will show 'redis.data', but as stopped
docker ps -a
# start redis, attach to 'redis.data'
docker run -d -p 6379:6379 --volumes-from redis.data --name ca.redis.1 dockerfile/redis
@miku
miku / sft.md
Last active August 29, 2015 14:10
Simple File Transformations

Simple File Transformations

A simple file transformation describes the transformation of a file from one shape into another. Transformations are

  • expressed in JavaScript and
  • applied on each line of the input file.

The transformation script can use two global variables: in and out.

@eliangcs
eliangcs / pyenv+virtualenv.md
Last active August 15, 2024 15:17
Cheatsheet: pyenv, virtualenvwrapper, and pip

Cheatsheet: pyenv, virtualenvwrapper, and pip

Installation (for Mac OS)

Install pyenv with brew

brew update
brew install pyenv
@kevincennis
kevincennis / v8.md
Last active May 4, 2025 04:02
V8 Installation and d8 shell usage

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)
  • Install depot_tools
    • $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    • $ nano ~/.zshrc
    • Add path=('/path/to/depot_tools' $path)