Skip to content

Instantly share code, notes, and snippets.

View eloyz's full-sized avatar
🎯
Focusing

Eloy Zuniga Jr. eloyz

🎯
Focusing
View GitHub Profile
@eloyz
eloyz / pg_dump.py
Last active December 16, 2015 17:09
We store postgres connection strings and sometimes I need to dump the sql from a database. This python files prints out the dump command for me when I pass the postgres connection string. Example: `python pg_dump.py postgres://<the rest of the string>'
import os
import re
import sys
from functools import partial
def f(host=u'', x=None):
"""
Returns string
"""
@eloyz
eloyz / basic_search_algorithms.py
Last active September 16, 2017 02:12
Depth First Search and Breath First Search Algorithm http://youtu.be/zLZhSSXAwxI
def dfs(graph, start, result=[]):
"""
Depth First Search
Follow each path in depth until
there are no more unvisted nodes.
Then reverse until we find an unvisited
node and continue to the depth of that path.
Repeat until there are no more unvisted nodes.
"""
@eloyz
eloyz / make_locations.py
Created November 5, 2013 20:32
Make a CSV file with 100 random locations
"""
pip install fake-factory
"""
from faker import Faker
fake = Faker()
with open('location.csv', 'wb') as f:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com.s3.amazonaws.com/tags/v1.0.0/ember.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com.s3.amazonaws.com/tags/v1.0.0/ember.js"></script>
<meta charset=utf-8 />
<script src="https://bitbucket.org/cetir/catcher/raw/0199a325eb50128dbf68c4e6a90af87efd3cc8ae/static/catcher/js/data.utils.js"></script>
<title>JS Bin</title>
</head>
function CheckTestForm (intTryNum) {
var strSessionTime;
if (blnSubmitClicked) {
return;
var serializer = new XMLSerializer(),
html = serializer.serializeToString(document);
# https://warehouse.python.org/project/pypi-cli/
$ sudo pypi stat tendenci-case-studies
Fetching statistics for 'http://pypi.python.org/pypi/tendenci-case-studies'. . .
Download statistics for tendenci-case-studies
=============================================
Downloads by version
1.0.0 13/02/25 [ 1,000 ] *******************************************
@eloyz
eloyz / .gitconfig
Last active August 29, 2015 14:02 — forked from mitsuhiko/.gitconfig
# Alternatively don't use slog but something else. I just like that more.
[alias]
slog = log --pretty=format:"%C(auto,yellow)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%cn%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]"
addprx = "!f() { b=`git symbolic-ref -q --short HEAD` && \
git fetch origin pull/$1/head:pr/$1 && \
git fetch -f origin pull/$1/merge:PR_MERGE_HEAD && \
git rebase --onto $b PR_MERGE_HEAD^ pr/$1 && \
git branch -D PR_MERGE_HEAD && \
git checkout $b && echo && \
git diff --stat $b..pr/$1 && echo && \
@eloyz
eloyz / download_image.py
Last active August 29, 2015 14:05
A script that downloads images. Script was design with the intent of teaching basic Python programming skills
import os
import StringIO
# import the request module
import requests
from PIL import Image
# Storing the image URL in a constant variable
IMAGE_URL = 'http://www.distractify.netdna-cdn.com/wp-content/uploads/2014/08/slugsolos-1-620x.jpg'