Skip to content

Instantly share code, notes, and snippets.

View elgertam's full-sized avatar
💭
Me : ☕️ ⟼ Code

Andrew Elgert elgertam

💭
Me : ☕️ ⟼ Code
View GitHub Profile
@rozza
rozza / auth_backend.py
Created May 11, 2010 20:24
Custom auth backend with an extended AnonymousUser
from django.contrib.auth import SESSION_KEY, BACKEND_SESSION_KEY, load_backend
from users.models import AnonymousUser
def get_user(request):
try:
user_id = request.session[SESSION_KEY]
backend_path = request.session[BACKEND_SESSION_KEY]
backend = load_backend(backend_path)
user = backend.get_user(user_id) or AnonymousUser()
except KeyError:
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@rmyers
rmyers / mkappenginevenv.sh
Created June 7, 2011 18:01
Setup virtual env for appengine with python 2.5
#!/bin/bash
#
# Build a virtual environment suitable for running appengine.
# This uses virtualenvwrapper to make the virtual environment.
# Which you can activate with 'workon appengine'
#
# Everyone loves one-liners!
# Mac one-liner:
# $ curl -s https://raw.github.com/gist/1012769 | bash
#
@chitchcock
chitchcock / 20111011_SteveYeggeGooglePlatformRant.md
Created October 12, 2011 15:53
Stevey's Google Platforms Rant

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@senko
senko / maybe.py
Last active May 2, 2024 18:35
A Pythonic implementation of the Maybe monad
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@binary1230
binary1230 / wells fargo website bulk statement downloader
Last active June 3, 2024 18:58
wells fargo ability to download all bank statements
3/18/2021: WE HAVE MOVED: For the latest instructions on how to use the bulk wells fargo PDF downloader,
please ignore this page and visit below:
https://github.com/binary1230/wellsfargo-bulk-PDF-statement-downloader/blob/main/README.md
@dhilip89
dhilip89 / duffs_device.js
Created May 2, 2018 01:47 — forked from JamieMason/duffs_device.js
JavaScript Duff's Device
/**
* 1. Original JS Implementation by Jeff Greenberg 2/2001 - http://home.earthlink.net/~kendrasg/info/js_opt/
* 2. (fast duff's device) from an anonymous donor to Jeff Greenberg's site
* 3. (faster duff's defice) by Andrew King 8/2002 for WebSiteOptimization.com
* 4. bug fix (for iterations<8) by Andrew B. King April 12, 2003
*/
function duffsDevice (iterations) {
var testVal = 0,
n = iterations % 8;
@mivade
mivade / aiowatch.py
Created October 26, 2018 17:00
Using watchdog with asyncio
import asyncio
from pathlib import Path
from typing import Optional
from watchdog.events import FileSystemEvent, FileSystemEventHandler
from watchdog.observers import Observer
class _EventHandler(FileSystemEventHandler):
def __init__(self, queue: asyncio.Queue, loop: asyncio.BaseEventLoop,
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 20, 2024 05:29
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@LakshyAAAgrawal
LakshyAAAgrawal / pytranslate.md
Last active February 20, 2024 12:36
Pytranslate - Maxima to Python Translator