Skip to content

Instantly share code, notes, and snippets.

View dreki's full-sized avatar

Sean Gilbertson dreki

  • MN
View GitHub Profile
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 5, 2024 17:27
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@mystix
mystix / setup-php-dev.sh
Last active April 27, 2023 15:46
(OSX 10.7.x/10.8.x + Homebrew + nginx + mysql + php 5.4 + php-fpm + apc + xdebug) development environment
#!/bin/bash
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
# install homebrew-dupes (required to install zlib, php54's dependency)
brew tap homebrew/dupes
# install nginx + mysql + php 5.4 + php-fpm + apc + xdebug
brew install nginx mysql
@hgdeoro
hgdeoro / settings.py
Last active July 10, 2022 12:20
Automatically login 'admin' user in Django
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'utils.AutomaticLoginUserMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)
@glombard
glombard / new_obj.py
Created December 9, 2014 19:57
Python anonymous object
# Sometimes it's handy to create small anonymous objects instead of explicitly defining a class for it, especially while prototyping.
def new(name, data):
return type(name, (object,), data)
person = new('Person', { 'name': 'Joe', 'age': 30 })
print(person.name)
@butla
butla / wait_for_tcp_port.py
Last active December 8, 2022 19:52
Waiting for a TCP port to start accepting connections (Python >=3.6)
"""
MIT License
Copyright (c) 2017 Michał Bultrowicz
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
@nicolasdao
nicolasdao / js_regex_cheatsheet.md
Last active March 19, 2024 11:31
My most common JS RegEx. Just sick of restarting from scratch each time I need a freaking RegEx. Keywords: regex regexp regular expression rege reg
@Integralist
Integralist / Tornado AsyncHTTPClient POST JSON example.py
Last active February 3, 2021 08:38
[Tornado AsyncHTTPClient POST form params example] #python #tornado #post #httpclient #asynchttpclient
# synchronous api
# response = sg.client.mail.send.post(request_body=data)
# except urllib.error.HTTPError as exc:
# async implementation
api_endpoint = 'https://api.sendgrid.com/v3/mail/send'
headers = {'Authorization': f'Bearer {sendgrid_api_key}',
'Content-Type': 'application/json'}
@dreki
dreki / mbmbam.md
Last active October 20, 2023 21:45
MBMBaM Memorable Bits

MBMBaM Episodes

  • 424, “That family always had Gushers, and I made them mine because of my actions,”
  • 418, “Gotta get a vasectomy,”
  • 401, sex on the ISS
  • 395, “So sweet, so crisp, so bitter, so many.”
  • 392, “That’s another hour of Monster Hunter I can play before my body has to go to sleep,” “Let’s put the tiger on the table and yell at it,”
  • 390, Justin kicks a bag at Taekwondo 50 times and then throws up
  • 380, "Jesus please us," "That's a wild way of doing that," "We're getting British up in here!," “Got a penis that can cum and everything,”
  • 379, crossing guard, “it is pretty ‘punk rock’,” crane lifts up a car into the sky
  • 378, someone’s brother rips out the pockets of their jeans while they’re talking to them,
@Susensio
Susensio / property_inheritance.md
Last active April 19, 2024 00:42
Inherit property setter in python 3.7

Python @property inheritance the right way

Given a Parent class with value property, Child can inherit and overload the property while accessing Parent property getter and setter.

Although we could just reimplement the Child.value property logic completely without using Parent.value whatsover, this would violate the DRY principle and, more important, it wouldn't allow for proper multiple inheritance (as show in the example property_inheritance.py bellow).

Two options:

  • Child redefines value property completely, both getter and setter.