Skip to content

Instantly share code, notes, and snippets.

View hiepph's full-sized avatar

Hiep Pham hiepph

View GitHub Profile
@haifengkao
haifengkao / open_finder_tab.sh
Last active October 24, 2023 19:04
A shell script function to open a Finder tab from terminal
# open the current folder in Finder's tab
function oft() {
local folder_name=$1
if ! [[ -d $1 ]]; then
# it is a file, get the enclosing folder
folder_name="$(dirname "$1")"
fi
# if no arguments are given, we use the current folder
@junzis
junzis / install_basemap_commands
Last active December 4, 2021 01:22
install basemap quickly on ubuntu
sudo apt-get install libgeos-3.X.X
sudo apt-get install libgeos-dev
pip install --user https://github.com/matplotlib/basemap/archive/master.zip
@madnight
madnight / hn-aeson.hs
Created September 30, 2016 15:23 — forked from Gonzih/hn-aeson.hs
Aeson HN example of nested JSON (unoptimized binary ~20 mb)
{-# LANGUAGE OverloadedStrings #-}
import Data.Aeson
import Control.Applicative ((<$>), (<*>))
import Control.Monad (mzero)
import Network.HTTP.Conduit
import Data.ByteString.Lazy.Internal (ByteString(..))
data Item = Item { title :: String
, url :: String
@ri-sh
ri-sh / ManualHough.py
Last active November 29, 2022 10:40
Hough Lines from scratch using opencv and numpy
# imports
import numpy as np
import cv2
import matplotlib.pyplot as plt
# The Hough Transform is a popular algorithm for detecting any shape that can
# be represented in a parametric mathmatical form in binary images. This
# usually means that images need to be thresholded or filtered prior to running
@mattiaslundberg
mattiaslundberg / Ansible Let's Encrypt Nginx setup
Last active May 14, 2025 21:35
Let's Encrypt Nginx setup with Ansible
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@fchollet
fchollet / classifier_from_little_data_script_3.py
Last active February 26, 2025 01:37
Fine-tuning a Keras model. Updated to the Keras 2.0 API.
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
@fchollet
fchollet / classifier_from_little_data_script_1.py
Last active February 26, 2025 01:37
Updated to the Keras 2.0 API.
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@wingedsheep
wingedsheep / cartpole_runnner.py
Created May 21, 2016 14:29
Q learning cartpole with target network and experience replay
# import the gym stuff
import gym
# import other stuff
import random
import numpy as np
# import own classes
from deepq import DeepQ
env = gym.make('CartPole-v0')
@olih
olih / jq-cheetsheet.md
Last active July 14, 2025 03:46
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq