Skip to content

Instantly share code, notes, and snippets.

@eliangcs
eliangcs / vsql_commands.txt
Last active August 29, 2015 14:27
vsql info
See the Vertica Programmer's Guide for information on available commands.
General
\c[onnect] [DBNAME|- [USER]]
connect to new database (currently "localdev")
\cd [DIR] change the current working directory
\q quit vsql
\set [NAME [VALUE]]
set internal variable, or list all if no parameters
\timing toggle timing of commands (currently off)
@eliangcs
eliangcs / time_celery_task.py
Last active December 16, 2016 17:45
Log execution time for every Celery task, working on Celery 3.1.x.
import logging
import time
from celery import shared_task as orig_shared_task
def timeit(func):
"""A decorator used to log the function execution time."""
logger = logging.getLogger('tasks')
@eliangcs
eliangcs / export_import_vertica.sql
Last active August 29, 2015 14:17
Export/import data from Vertica
-- Export
\a -- Disable alignment
\t -- Disable column header
\o output.txt -- Set output filename
SELECT * FROM table; -- Select the data to export
-- Import
COPY table FROM '/path/to/output.txt' DELIMITER '|';
@eliangcs
eliangcs / arrow2.zsh-theme
Last active August 29, 2015 14:16
My oh-my-zsh theme
# Forked from https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/arrow.zsh-theme
git_describe() {
echo $(git describe --tag 2> /dev/null)
}
my_git_prompt_info() {
prompt=$(git_prompt_info)
if [ ! -z "$prompt" ]; then
echo "$(git_describe) ($(git_prompt_info))"
@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
@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 / 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
@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 / sleekxmpp_client.py
Created May 13, 2014 04:08
Sleekxmpp example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
SleekXMPP: The Sleek XMPP Library
Copyright (C) 2010 Nathanael C. Fritz
This file is part of SleekXMPP.
See the file LICENSE for copying permission.
"""
@eliangcs
eliangcs / install_scrapy_dep.sh
Last active August 29, 2015 14:01
Scrapy dependencies on Ubuntu
sudo apt-get install -y gcc python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev build-essential