Skip to content

Instantly share code, notes, and snippets.

View TheBB's full-sized avatar
🏠
Working from home

Eivind Fonn TheBB

🏠
Working from home
View GitHub Profile
@TheBB
TheBB / diff.out
Last active December 16, 2015 22:09
Diff periods 82 -> 83
+------+------------+---------+------------------+
| id | tag | country | diff |
+------+------------+---------+------------------+
| 139 | ThorZaIN | SE | 134.838370657 |
| 2494 | hOpe | SE | 132.505908338 |
| 1394 | Center | KR | 126.412464939 |
| 33 | Puzzle | KR | 123.90734736 |
| 213 | Apocalypse | KR | 107.444816489 |
| 414 | Mini | SE | 105.1572460329 |
| 224 | SjoW | SE | 101.3095816449 |
@TheBB
TheBB / flags
Last active December 17, 2015 07:19
ACQUIRED QUALIFIED
National
China Austria
Denmark Brazil
France Bulgaria
Italy Czech Republic
Netherlands Great Britain
Norway Hungary
class Match(models.Model):
class Meta:
verbose_name_plural = 'matches'
db_table = 'match'
period = models.ForeignKey(Period, null=False)
date = models.DateField('Date played', null=False)
pla = models.ForeignKey(Player, related_name='match_pla', verbose_name='Player A', null=False)
plb = models.ForeignKey(Player, related_name='match_plb', verbose_name='Player B', null=False)
sca = models.SmallIntegerField('Score for player A', null=False, db_index=True)
@TheBB
TheBB / gist:6543965
Last active December 22, 2015 22:59
class MatchForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(MatchForm, self).__init__(*args, **kwargs)
q = Q(closed=False, lft=F('rgt')-1)
if self.instance.eventobj != None:
q = q | Q(id=self.instance.eventobj.id)
self.fields['eventobj'].queryset = Event.objects.filter(q).order_by('-id')
class MessagesInline(admin.StackedInline):
model = Message
class MyForm(form):
def __init__(user, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['character'] = forms.ChoiceField(
choices=[(c.id, c.name) for c in Character.objects.filter(...)]
)
# In view
def my_view(request):
form = MyForm(request.user, ...)
import Data.List (intercalate, transpose)
import Data.Maybe (fromJust)
import GHC.Exts (sortWith)
data Square = Empty | Mine | Click
newtype Minefield = Minefield [[Square]]
instance Show Square where
show Empty = "."
show Mine = "*"
@TheBB
TheBB / gist:be84c8061f5eed050963
Last active August 29, 2015 14:02 — forked from MB6/WC1
import requests
resp = requests.get('http://worldcup.sfg.io/matches')
for jogo in (j for j in requests.get('http://worldcup.sfg.io/matches').json() if j['status'] == 'completed'):
print jogo['home_team']['country'], jogo['home_team']['goals'], 'x', jogo['away_team']['country'], jogo['away_team']['goals']
@TheBB
TheBB / gist:a4f83caba9d4e23e6a28
Last active August 29, 2015 14:02
ReneFroger's vimrc
" Easymotion {
let g:EasyMotion_leader_key = '<Space>'
let g:StupidEasyMotion_leader_key = 'f'
let g:EasyMotion_use_upper = 1
let g:EasyMotion_keys = 'ASDFWIERUOGHJKL'
" }
" Vim Over {
let g:over_enable_auto_nohlsearch = 1
let g:over_enable_cmd_window = 1
@TheBB
TheBB / gist:26c3b38ac24333c16913
Created August 7, 2014 17:32
Ackermann function
#include <iostream>
#include <stack>
#include <cstdlib>
typedef unsigned long long ull;
ull ack(ull m, ull n)
{
std::stack<ull> st;
st.push(m);
@TheBB
TheBB / primes.py
Last active August 29, 2015 14:05
Primes in Python
import sys
def sieve(limit):
a = [True] * limit
a[0] = a[1] = False
for i, isprime in enumerate(a):
if isprime:
yield i