Skip to content

Instantly share code, notes, and snippets.

View eloyz's full-sized avatar
🎯
Focusing

Eloy Zuniga Jr. eloyz

🎯
Focusing
View GitHub Profile
function CheckTestForm (intTryNum) {
var strSessionTime;
if (blnSubmitClicked) {
return;
<!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>
<!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>
@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:
@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 / 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 / codeintel.sublime-mousemap
Created March 26, 2013 10:46
This is a mouse binding that lets you keep the column select feature in Sublime Text 2 If you're using the CodeIntel plugin it gets overwritten, this is a way of bring it back. Not sure how to keep both bindings. Sublime > Preferences > Package Settings > SublimeCodeIntel > Mouse Bindings - User
[
{
"button": "button1", "modifiers": ["alt"],
"press_command": "drag_select",
"press_args": {"by": "columns"}
}
]
@eloyz
eloyz / read_env.py
Created March 23, 2013 03:42
Function that reads environment variables from .env file and adds them to the os.environment dictionary.
# manage.py in Django project
import re
def read_env():
"""
Pulled from Honcho code with minor updates, reads local default
environment variables from a .env file located in the project root
directory.
"""
try:
v = 'True'
def bool2():
v[0].lower() in ('t','1','y')
@eloyz
eloyz / csv_to_list.py
Created January 17, 2013 08:17
Using Python to read CSV file into list.
import csv
def csv_to_list(file_path):
"""
Reads csv file into list.
"""
with open(file_path, 'rb') as f:
# load all data into memory, scary
dialect = csv.Sniffer().sniff(f.read(1024))
f.seek(0) # reset cursor