Skip to content

Instantly share code, notes, and snippets.

View dbgarf's full-sized avatar

Daniel Garfield dbgarf

  • Boulder, CO
View GitHub Profile
@dbgarf
dbgarf / vowel.py
Last active August 29, 2015 13:57
# re is the python regular expression module. its very powerful and worth learning.
import re
# unittest is the built in testing module. good for simple use cases like this.
from unittest import TestCase, TestLoader, TestResult
# compiling the regex pattern ahead of time, which adds significant speed
vowel_pattern = re.compile(r'[AEIOUaeiou]')
def is_vowel(char):
# raising errors for invalid input is a good idea
from django.views.generic import View
import json
class userView(View):
def get(self, request, user_id):
response_content = json.dumps({'message': 'user not updated'})
return http.HttpResponse(response_content, status=200, mimetype='application/json')
def post(self, request, user_id):
user = User.objects.get(id=user_id)
[user]
name = Dan Garfield
email = dbgarf@gmail.com
[alias]
co = checkout
s = status
a = add
d = difftool
c = commit
@dbgarf
dbgarf / gist:f885ddbd5b9d6134f9ae318ae9158459
Created March 26, 2019 18:42
poe bleed dps calculator
import random
def bleed_multiplier(min_d, max_d, aps, chance, duration, trials=10000, ruthless=True, fossil=True, rys=True):
min_new = min_d
max_new = max_d
if rys:
min_new = int(0.7*min_d)
max_new = int(1.4*max_d)
totals = []
$total = 1440;
$totalW = 0 <# 52 #>;
$totalB = 0 <# 8 #>;
for ($i = 0; $i -lt 1440) {
if ($totalW -eq $totalB) {
$i += 52; $totalW += 1
}
else {
$i += 8; $totalB += 1 }
};
@dbgarf
dbgarf / gist:238f4d8aa4669808f2c10330443ff541
Created September 18, 2019 15:21
example homebrew cask script
#!/bin/bash
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew cask install google-chrome
brew cask install sublime-text
brew cask install hipchat
brew cask install 1password
brew cask install lastpass
brew cask install cyberduck