Skip to content

Instantly share code, notes, and snippets.

@eayoungs
eayoungs / postgres-cheatsheet.md
Created July 18, 2018 16:45 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
## Bash one-liners
# find . -name "*.t1" -exec rename 's/\.t1$/.t2/' '{}' \;
# Git aware prompt
# https://github.com/jimeh/git-aware-prompt
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\[\033[0;32m\] \u@\h \[\033[0;33m\] \w$ \[\033[0m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
Attaching to web_web_1
web_1 | First run - Provisioning the local development environment...
web_1 | /usr/local/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
web_1 | """)
web_1 | Cache table 'my_cache_table' already exists.
web_1 | /usr/local/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
web_1 | """)
web_1 | /usr/local/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 w
from itertools import permutations
a = ["aba", "bbb", "bab"]
b = ["ab", "bb", "aa"]
c = ["ab", "bb", "aa", "ab", "bb", "aa", "ab", "bb", "aa", "ab", "bb", "aa"]
def string_diff(x, y):
stuff = sum(1 for x, y in zip(x, y) if x != y)
return stuff
@eayoungs
eayoungs / setup.md
Created December 21, 2017 22:45 — forked from FMCorz/setup.md
Sublime Text, Django and Pylint

Pre-requisites

  • Install SublimeLinter
  • Install SublineLinter-pylint

Global pylint

Install pylint globally.

# Define a method that returns the sum of all the non-negative integers up to and including its argument.
# sum_to(3) => 6
def sum_to(int)
return (0..int).sum
end
# Define a method, #e_words(str), that accepts a string as an argument. Your method return the number of words in the string that end with the letter "e".
# e_words("tree") => 1
# e_words("Let be be finale of seem.") => 3
def e_words(str)
@eayoungs
eayoungs / tweet_dumper.py
Created November 27, 2017 20:16 — forked from yanofsky/LICENSE
A script to download all of a user's tweets into a csv
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
#Twitter API credentials
consumer_key = ""
consumer_secret = ""
access_key = ""
#!/bin/bash
TODAY=`date +'%b %e'`
WINNERS=`sudo lastb -a -10000 | grep "$TODAY" | awk '{print $10}' | sort | uniq -c| sort -n | tail -10`
echo WINNERS for $TODAY
OLDIFS="$IFS"
IFS=$'\n'
for i in $WINNERS
do
echo $i
i2=$(echo -e "${i}" | sed -e 's/^[[:space:]]*//')
@eayoungs
eayoungs / global-gitignore.md
Created October 13, 2017 04:59 — forked from subfuzion/global-gitignore.md
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.

Mac

git config --global core.excludesfile ~/.gitignore

Windows

git config --global core.excludesfile %USERPROFILE%\.gitignore
@eayoungs
eayoungs / README-Template.md
Created October 11, 2017 17:44 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites