Skip to content

Instantly share code, notes, and snippets.

View bsnux's full-sized avatar
💭
👨‍💻

Arturo Fernandez bsnux

💭
👨‍💻
View GitHub Profile
launch "iTerm"
tell application "iTerm"
set dev_directory to "path/to/your/project"
set django_port to "8000"
tell the current terminal
activate current session
launch session "Default Session"
@bsnux
bsnux / fab_delete_pyc.py
Created February 26, 2014 20:23
Deleting *.pyc files
@task
def del_pyc():
"""
Delete *.pyc of your project
"""
local('find . -name \*.pyc | xargs rm')
#!/bin/zsh
cd templates
find . -type f -print0 | xargs -0 sed -i '' 's/ url \([^" >][^ >]*\)/ url "\1"/g'
#! /usr/bin/env python
#----------------------------------------------------------
# Create backups using snapshops
#----------------------------------------------------------
from datetime import datetime
import os
# Directory for backups
@bsnux
bsnux / log.py
Created August 26, 2014 19:13
Displaying all queries in shell
'handlers': {
'stream': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
}
}
'loggers': {
'': {
'handlers': ['stream'],
@bsnux
bsnux / createmysql.sql
Last active August 29, 2015 14:12
Creating a MySQL DB
CREATE DATABASE dbname DEFAULT CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON dbname.* TO 'db_user'@'localhost' IDENTIFIED BY 'passwd_user';
@bsnux
bsnux / humanize_time.py
Created May 15, 2015 23:32
Display number of seconds in human format
def humanize_seconds(seconds, granularity=2):
intervals = (
('weeks', 604800), # 60 * 60 * 24 * 7
('days', 86400), # 60 * 60 * 24
('hours', 3600), # 60 * 60
('minutes', 60),
('seconds', 1),
)
result = []
@bsnux
bsnux / create_postgresql.sql
Last active August 29, 2015 14:22
Creating PostgreSQL DB and user with UTF-8 encoding
CREATE ROLE username LOGIN ENCRYPTED PASSWORD 'password' NOINHERIT;
CREATE DATABASE db WITH ENCODING='UTF-8' OWNER=username;
@bsnux
bsnux / get_python_hacker_news.coffee
Created July 28, 2015 01:04
Getting recent Hacker News stories about Python and Django
https = require 'https'
url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
base_item_url = 'https://hacker-news.firebaseio.com/v0/item/'
pattern = /python|django/i
https.get url, (res) ->
res.on 'data', (codes) ->
for code in JSON.parse(codes)
#!/bin/zsh
git tag | xargs git show --pretty=oneline --name-only