Skip to content

Instantly share code, notes, and snippets.

@cbronazc
cbronazc / urlencode
Created May 28, 2019 20:50
URL encode/decode
#!/usr/bin/python
import urllib
import sys
text = sys.argv[1]
encoded = urllib.quote_plus(text)
print encoded
@cbronazc
cbronazc / dtc.md
Last active August 29, 2015 14:13
Django Twitter Clone

Django twitter clone - DTC

Build an app that:

  • Allows anyone to go to the home page
  • Has a login button on the home page
  • Allows a user to login with a username and password
    • This shouldn't be http basicauth, it should allow multiple users to login with different credentials.
    • Password should be encrypted in some way, no plain text
  • Has a form to create a post which displays to logged in users only, that has the following two fields:
@cbronazc
cbronazc / request_timer.sh
Created August 14, 2014 23:07
request_timer.sh
#!/usr/bin/python
activate_this_file = "/Users/my_username/.virtualenvs/virtual_env_name/bin/activate_this.py"
execfile(activate_this_file, dict(__file__=activate_this_file))
import requests
from time import sleep
while 1:
print requests.get("http://my_url.com").elapsed.total_seconds()
@cbronazc
cbronazc / foldEnc
Last active August 29, 2015 14:04
Encrypt/Decrypt a folder with gpg
#!/bin/sh
OPTIND=1
infile=
while getopts e:d: opt; do
case $opt in
e)
infile=$OPTARG
tar cvf - $infile | gpg --cipher-algo AES256 --symmetric > ./$infile.tbz
;;
@cbronazc
cbronazc / doit
Last active August 29, 2015 13:57 — forked from stantonk/doit
Install Python 2.7 on Centos 5.* without breaking yum
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
yum groupinstall "Development tools"
yum install zlib-devel
yum install bzip2-devel openssl-devel ncurses-devel xz
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
unxz Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar
@cbronazc
cbronazc / AZC-git-development-workflow.md
Last active August 29, 2015 13:56
The workflow for apps, pages, uscp, sam etc...

This workflow assumes upstream is the main repo, and origin is your fork.

Command Description
git checkout release get back to release
git pull upstream release pull down new code (or do a fetch and then checkout upstream/release)
git checkout -b 'feature-branch-name' Checkout a branch (it can be any name)
Make your changes (bang on your keyboard)
git status Shows you which files you changed, use this often
git diff shows you your actual changes. hit q to exit git diff.
@cbronazc
cbronazc / convert_xml_to_html.rb
Last active December 24, 2015 14:29
Convert xml to html with a ruby script. Basically just a cheap, badly done .html_safe
require 'tempfile'
require 'fileutils'
# To run: ruby ./convert_xml_to_html.rb thefile.xml
#
path = ARGV[0]
begin
orig = File.open(path, 'r')
file = File.open("converted_" + path, "w")
@cbronazc
cbronazc / InningsPitched.js
Created August 12, 2013 22:49
Calculate Innings Pitched with Javascript
base = Math.floor(total);
partial = Math.round((total - base) * 10);
total = (base + Math.floor(partial / 3) + (partial % 3) / 10).toFixed(1);
@cbronazc
cbronazc / gist:5767996
Created June 12, 2013 18:48
List top stories from subreddits within your console
#!/usr/bin/env python
import json
import urllib2
running = True
hdr = { 'User-Agent' : 'Someone is browsing reddit on their console' }
print "`exit` exits"
while running:
sub = str(raw_input("Enter a subreddit: "))