Skip to content

Instantly share code, notes, and snippets.

View gatspy's full-sized avatar

CG.gatspy gatspy

View GitHub Profile
@gatspy
gatspy / iterator.py
Last active May 3, 2016 21:05
python -- iterator
class SkipIterator(object):
def __init__(self, wrapped):
self.wrapped = wrapped
self.offset = 0
def __next__(self):
if self.offset == len(self.wrapped):
raise StopIteration
else:
item = self.wrapped[self.offset]
@gatspy
gatspy / linux-shell-docker-cli.sh
Created July 13, 2016 09:57 — forked from rafaeltuelho/linux-shell-docker-cli.sh
Some useful shell aliases and function for Docker command line
# Docker aliases
alias di='sudo docker images'
alias dps='sudo docker ps -a'
# useful Docker functions
dock-run() { sudo docker run -i -t --privileged $@ ;}
dock-exec() { sudo docker exec -i -t $@ /bin/bash ;}
dock-log() { sudo docker logs --tail=all -f $@ ;}
dock-port() { sudo docker port $@ ;}
dock-vol() { sudo docker inspect --format '{{ .Volumes }}' $@ ;}
@gatspy
gatspy / yunfile_downloader
Created July 14, 2016 19:55
A python script
#!/usr/bin/env python
# encoding: utf-8
"""
@version: 0.3
@author: endoffiht
@file: yunfile_downloader.py
@time: 15/6/29 18:06
"""
@gatspy
gatspy / docker-machine-rename
Created July 15, 2016 19:08 — forked from alexproca/docker-machine-rename
Rename docker-machine
#!/usr/bin/env bash
#copy this in a folder from path ex: /usr/local/bin
#usage: docker-machine-rename default my-default
OLD_MACHINE_NAME=${1:-default};
NEW_MACHINE_NAME=${2:-my-default-2};
STORE_PATH=`docker-machine inspect $OLD_MACHINE_NAME | grep -m 1 StorePath | cut -d ':' -f 2 | cut -c 3- | rev | cut -c 3- | rev`;
mv "$STORE_PATH/machines/$OLD_MACHINE_NAME" "$STORE_PATH/machines/$NEW_MACHINE_NAME";
cp "$STORE_PATH/machines/$NEW_MACHINE_NAME/config.json" "$STORE_PATH/machines/$NEW_MACHINE_NAME/config.json.bak"
@gatspy
gatspy / .vimrc
Created July 26, 2016 21:53 — forked from Stewmath/.vimrc
YCM + Omnisharp test case
set nocompatible
execute pathogen#infect()
syntax on
@gatspy
gatspy / gist:7c59c66c309328965d929285c33f1baf
Created July 30, 2016 16:35 — forked from jagregory/gist:710671
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork [email protected]
@gatspy
gatspy / simple_app.py
Created August 20, 2016 10:16 — forked from kemitche/simple_app.py
reddit OAuth 2.0 Python Webserver Example
#!/usr/bin/env python
from flask import Flask, abort, request
from uuid import uuid4
import requests
import requests.auth
import urllib
CLIENT_ID = None # Fill this in with your client ID
CLIENT_SECRET = None # Fill this in with your client secret
REDIRECT_URI = "http://localhost:65010/reddit_callback"
@gatspy
gatspy / .zshrc
Created December 6, 2016 14:22 — forked from QinMing/.zshrc
.zshrc (ZSH lazy load)
# Copyright (c) 2016 Ming Qin (覃明) <https://github.com/QinMing>
# Open source under MIT LICENSE.
alias l="ls -alht"
alias upthis="ss u"
alias downthis="ss d"
alias g="git"
alias gs="git status"
@gatspy
gatspy / lazy-load-nvm.sh
Created December 6, 2016 18:13 — forked from rtfpessoa/lazy-load-nvm.sh
NVM lazy loading script
#!/bin/bash
#
# NVM lazy loading script
#
# NVM takes on average half of a second to load, which is more than whole prezto takes to load.
# This can be noticed when you open a new shell.
# To avoid this, we are creating placeholder function
# for nvm, node, and all the node packages previously installed in the system
# to only load nvm when it is needed.
@gatspy
gatspy / Mac Dev Setup.md
Created December 15, 2016 19:13 — forked from ogrrd/Mac Dev Setup.md
Installing nginx, PHP and MySQL on OS X Mavericks

Installing a Web Developer setup on OS X Mavericks

Install Command Line Tools

This is a requirement for brew in the next step. You can install XCode and then install Command Line Tools through the XCode preferences, or you can install just the Command Line Tools.

Install Command Line Tools

$ xcode-select --install