Skip to content

Instantly share code, notes, and snippets.

View djfan's full-sized avatar

Dongjie Fan djfan

  • NY, NY
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@wolever
wolever / histogram.sql
Last active April 19, 2023 20:28
Functions to create and draw histograms with PostgreSQL.
-- Functions to create and draw histograms with PostgreSQL.
--
-- psql# WITH email_lengths AS (
-- -# SELECT length(email) AS length
-- -# FROM auth_user
-- -# LIMIT 100
-- -# )
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths))
-- bucket | range | count | bar | cumbar | cumsum | cumpct
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------
@hellpanderrr
hellpanderrr / Python concave hull ( alpha shape ) .md
Last active April 27, 2022 22:51
Concave hull in python using scipy and networkx
from scipy.spatial import Delaunay, ConvexHull
import networkx as nx
 
points = [ [0,0],[0,50],[50,50],[50,0],[0,400],[0,450],[50,400],[50,450],[700,300],[700,350],[750,300],[750,350],
          [900,600],[950,650],[950,600],[900,650]
]
def concave(points,alpha_x=150,alpha_y=250):
    points = [(i[0],i[1]) if type(i) <> tuple else i for i in points]
    de = Delaunay(points)
@chantastic
chantastic / on-jsx.markdown
Last active May 30, 2024 13:11
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@jsanz
jsanz / README.md
Last active November 16, 2017 16:41
CartoDB.js: create a map from a custom viz.json

On this example I pass a vizjson object that defines a leaflet map with a layer, legend, tooltip and infowindows.

@karpathy
karpathy / min-char-rnn.py
Last active July 22, 2024 04:44
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@CMCDragonkai
CMCDragonkai / typeofvar.sh
Last active May 19, 2023 01:00
Bash: Get the type of a variable
#!/usr/bin/env bash
typeofvar () {
local type_signature=$(declare -p "$1" 2>/dev/null)
if [[ "$type_signature" =~ "declare --" ]]; then
printf "string"
elif [[ "$type_signature" =~ "declare -a" ]]; then
printf "array"
@myme5261314
myme5261314 / rbm_MNIST_test.py
Last active April 10, 2020 06:59
RBM procedure using tensorflow
import tensorflow as tf
import numpy as np
import input_data
import Image
from util import tile_raster_images
def sample_prob(probs):
return tf.nn.relu(
tf.sign(
@ottokart
ottokart / nn.py
Last active August 27, 2021 05:52
3-layer neural network example with dropout in 2nd layer
# Tiny example of 3-layer nerual network with dropout in 2nd hidden layer
# Output layer is linear with L2 cost (regression model)
# Hidden layer activation is tanh
import numpy as np
n_epochs = 100
n_samples = 100
n_in = 10
n_hidden = 5
@Cospel
Cospel / rbm_MNIST_test.py
Last active October 27, 2017 11:13 — forked from myme5261314/rbm_MNIST_test.py
RBM procedure using tensorflow
#http://blog.echen.me/2011/07/18/introduction-to-restricted-boltzmann-machines/
#https://www.tensorflow.org/versions/r0.7/api_docs/python/constant_op.html#random_uniform
import tensorflow as tf
import numpy as np
import input_data
import Image
from util import tile_raster_images