Skip to content

Instantly share code, notes, and snippets.

View liuyigh's full-sized avatar

Yi Liu liuyigh

View GitHub Profile
#!/usr/bin/env python
"""Test functions from
http://stackoverflow.com/questions/28680896/how-can-i-get-the-3rd-friday-of-a-month-in-python
"""
import calendar
from datetime import date, datetime, time, timedelta
from itertools import islice
DAY = timedelta(1)
@seanmcn
seanmcn / gist:62a021a765ad4f8e593b
Last active February 21, 2024 11:57
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
@denvazh
denvazh / README.md
Last active March 17, 2023 16:38
Scheduled update for homebrew

Scheduled updates for homebrew

This two launchdaemon scripts provide scheduled updates and upgrade for homebrew packages.

It will run in the following way:

  • brew update every day at 12:10
  • brew upgrade every day at 12:20

How to install

@dougalcampbell
dougalcampbell / NeoPixelTest.ino
Created October 31, 2013 03:29
Example of driving an Adafruit NeoPixel Ring with the Digispark Arduino-compatible board
#include <Adafruit_NeoPixel.h>
#define PIN 1
#define STRIPSIZE 16
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
@johntyree
johntyree / history_vol.py
Last active February 26, 2020 04:24
Calculate annualized volatility from historical data.
#/usr/bin/env python
from pandas import np
from pandas.io.data import DataReader
def historical_volatility(sym, days):
"Return the annualized stddev of daily log returns of `sym`."
try:
quotes = DataReader(sym, 'yahoo')['Close'][-days:]
@ryin
ryin / tmux_local_install.sh
Last active April 23, 2024 01:06
bash script for installing tmux without root access
#!/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
TMUX_VERSION=1.8