Skip to content

Instantly share code, notes, and snippets.

View alukach's full-sized avatar
🍊

Anthony Lukach alukach

🍊
View GitHub Profile
@thiagophx
thiagophx / pp
Created March 17, 2015 18:42
JSON Pretty Print Stream
#!/usr/bin/python -u
import sys, json
from pygments import highlight
from pygments.lexers import JsonLexer
from pygments.formatters import Terminal256Formatter
while True:
line = sys.stdin.readline()
if line.strip():
@mapmeld
mapmeld / mapboxgl.md
Last active March 4, 2019 15:12
Getting Started with MapBoxGL

Getting Started

I recently made my first map with MapBox's new WebGL+JavaScript API. There aren't many examples of how to do this yet, even on MapBox's API page, so I'll document my own experience here.

The Van Gogh Map

My map is made of several textures taken from Van Gogh paintings. The long-term goal is to allow a user to select which artworks they want to take textures from, but for now there is just one setting.

Why are we changing maps?

@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 19, 2024 17:40
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@wizpig64
wizpig64 / secure_storage.py
Created November 27, 2013 04:58
Makes Django storage URLs expire after a set amount of time. Built to be used with nginx's secure_link module, essentially emulating Amazon's S3's similar functionality. Because it's a mixin, you can theoretically use it with any Django storage method, but it will only limit access if there's a properly configured nginx server actually serving t…
from base64 import urlsafe_b64encode
from urlparse import parse_qs, urlsplit, urlunsplit
from urllib import unquote, urlencode
from django.conf import settings
from django.core.files.storage import Storage
from django.core.files.storage import FileSystemStorage
from secret_hash import SecretHash
@wizpig64
wizpig64 / secret_hash.py
Last active December 27, 2015 10:49
Hash a privately known SECRET_KEY with a public expiration time. Meant to be used in places where sensitive commands must be sent over GET requests, which are inherently publicly accessible.
from base64 import b64encode
from datetime import datetime
import hashlib
from time import time
class SecretHash:
r"""Hash a privately known SECRET_KEY with a public expiration time.
Meant to be used in places where sensitive commands must be sent
over GET requests, which are inherently publicly accessible.
@techniq
techniq / audit_mixin.py
Created March 16, 2013 01:05
Useful SQLAlchemy Mixins
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@EyePulp
EyePulp / gist:4962327
Last active December 13, 2015 19:28
django templated e-mail using markdown/html -- supports attaching files or streaming file attachments
from django.conf import settings
def email_template(
template_name = None,
template_context = None,
subject = '',
recipients = None,
sender = settings.DEFAULT_FROM_EMAIL,
fail_silently = False,
use_markdown = False,
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@beala
beala / picking-colors.py
Created October 7, 2012 17:19
The companion code to my picking colors blog post.
import math
import random
def getSuccessors(color):
def perm(l, n, str_a, perm_a):
"""Generate every permutation of length `n`, selecting from the
possible values in `l`.
"""
if len(str_a) == n:
return (str_a,) + perm_a
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: