Skip to content

Instantly share code, notes, and snippets.

@eliangcs
eliangcs / vim_cheatsheet.md
Last active August 29, 2015 14:10
My Vim cheatsheet

Insert

  • a: after cursor
  • i: before cursor
  • A: after line
  • I: before line
  • o: add a new line below
  • O: add a new line above

Select

@eliangcs
eliangcs / ipython_startup.py
Created December 1, 2014 22:05
Common imports for IPython startup
# ~/.ipython/profile_default/startup/00_common.py
import base64
import codecs
import cPickle as pickle
import cStringIO as StringIO
import csv
import hashlib
import importlib
import json
import math
@return1
return1 / gist:5059418
Created February 28, 2013 19:36
S3/Cloudfront CORS (Cross-Origin Resource Sharing) Configuration for Webfonts in Firefox. make sure to redistribute Cloudfront after applying this config to the S3 bucket. Also you should restrict the origin to you domain, just to be safe.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Content-*</AllowedHeader>
<AllowedHeader>Host</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@eliangcs
eliangcs / shortcuts.sh
Last active January 18, 2016 06:29
Shell shortcuts
# Clear local merged branches
function clearbranches(){
cur_branch=`git rev-parse --abbrev-ref HEAD`
if [[ "$cur_branch" == "master" ]]; then
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
else
echo "Not on master branch!"
fi
}
@FZambia
FZambia / sub.py
Last active October 21, 2019 06:47
tornado's Subprocess class usage example. Minimal Tornado's version required - 3.1
from __future__ import print_function
from tornado.gen import Task, Return, coroutine
import tornado.process
from tornado.ioloop import IOLoop
import subprocess
import time
STREAM = tornado.process.Subprocess.STREAM
@eliangcs
eliangcs / secure-django-admin.rst
Last active June 8, 2021 16:10
Secure Django admin with self-signed SSL client certificate in Nginx.
@eliangcs
eliangcs / linode-security.md
Last active January 11, 2022 23:09
Basic security setup for a brand new Linode

Basic Security Setup for a Brand New Linode

Why

When you start a clean Linode, it isn't secured in the following aspects:

  • Allows root SSH login
  • Uses password authentication on SSH
  • Doesn't have a firewall
@eliangcs
eliangcs / pyenv+virtualenv.md
Last active June 8, 2023 07:46
Cheatsheet: pyenv, virtualenvwrapper, and pip

Cheatsheet: pyenv, virtualenvwrapper, and pip

Installation (for Mac OS)

Install pyenv with brew

brew update
brew install pyenv

Most downloaded projects

SELECT
  file.project,
  COUNT(*) as total_downloads,
FROM
  TABLE_DATE_RANGE(
    [the-psf:pypi.downloads],
    TIMESTAMP("20160114"),
@yegappan
yegappan / VimScriptForPythonDevelopers.MD
Last active January 12, 2024 10:51
Vim script for Python Developers

Vim Script for Python Developers

This is a guide to Vim Script development for Python developers. Sample code for the various expressions, statements, functions and programming constructs is shown in both Python and Vim Script. This is not intended to be a tutorial for developing Vim scripts. It is assumed that the reader is familiar with Python programming.

For an introduction to Vim Script development, refer to usr_41.txt, eval.txt and Learn Vimscript the Hard Way

For a guide similar to this one for JavaScript developers, refer to Vim Script for the JavaScripter

This guide only describes the programming constructs that are present in both Python and Vim. The constructs that are unique to Vim (e.g. autocommands, [key-mapping](https://vimhelp.org/map.txt.html#key-m