Skip to content

Instantly share code, notes, and snippets.

@skyzyx
skyzyx / homebrew-gnubin.md
Last active July 17, 2025 13:00
Using GNU command line tools in macOS instead of FreeBSD tools

macOS is a Unix, and not built on Linux.

I think most of us realize that macOS isn't a Linux OS, but what that also means is that instead of shipping with the GNU flavor of command line tools, it ships with the FreeBSD flavor. As such, writing shell scripts which can work across both platforms can sometimes be challenging.

Homebrew

Homebrew can be used to install the GNU versions of tools onto your Mac, but they are all prefixed with "g" by default.

All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""
a response to https://gist.github.com/TomAugspurger/f96d41ae7a40d41fe9053d0adbceb4f1
"""
from collections import deque
import datetime
import itertools
import random
import string
from typing import NamedTuple, Tuple, Iterable, List
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import tensorflow as tf
tf.reset_default_graph()
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
### model ###
# input
with tf.name_scope('input') as scope:
@tomokishii
tomokishii / README.md
Last active December 19, 2017 00:46
TensorFlow 1.3 "canned estimators" demo
  1. mnist_cnn.py - baseline code (till TF 1.2)
  2. mnist_estimator.py - using TF 1.3 tf.estimator API
@jnothman
jnothman / pandasvectorizer.py
Last active August 21, 2017 03:00
vectorize a pandas dataframe with scikit-learn <= 0.19
from sklearn.feature_extraction import DictVectorizer
class PandasVectorizer(DictVectorizer):
def fit(self, x, y=None):
return super(PandasVectorizer, self).fit(x.to_dict('records'))
def fit_transform(self, x, y=None):
return super(PandasVectorizer, self).fit_transform(x.to_dict('records'))
def transform(self, x):
@dgrtwo
dgrtwo / mnist_pairs.R
Created May 31, 2017 18:56
Comparing pairs of MNIST digits based on one pixel
library(tidyverse)
# Data is downloaded from here:
# https://www.kaggle.com/c/digit-recognizer
kaggle_data <- read_csv("~/Downloads/train.csv")
pixels_gathered <- kaggle_data %>%
mutate(instance = row_number()) %>%
gather(pixel, value, -label, -instance) %>%
extract(pixel, "pixel", "(\\d+)", convert = TRUE)
@mahermalaeb
mahermalaeb / surprise_tutorial.py
Last active November 21, 2019 02:03
The easy guide for building python collaborative filtering recommendation system in 2017
import zipfile
from surprise import Reader, Dataset, SVD, evaluate
# Unzip ml-100k.zip
zipfile = zipfile.ZipFile('ml-100k.zip', 'r')
zipfile.extractall()
zipfile.close()
# Read data into an array of strings
with open('./ml-100k/u.data') as f: