This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See http://www.reddit.com/r/programming/comments/as759/hey_reddit_out_of_these_4_programmers_who_would/ | |
using System; | |
class MainClass { | |
static int Main(string[] argv) { | |
foreach (string s in new string[] {"hello", "λ", Char.ConvertFromUtf32(0x1D161)}) { | |
Console.WriteLine(s); | |
Console.WriteLine(Reverse(s)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 100% code coverage, with an obvious type level bug that is not caught - Bar | |
# does not define method2 and do_it will fail for some values. | |
class Foo(object): | |
def method1(self, arg): | |
return arg + 1 | |
def method2(self, arg): | |
return arg + 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Quick and dirty script to convert ktimetracker.ics files | |
# into TimeCult files. | |
import os.path | |
import sys | |
import time | |
import uuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from django.utils.safestring import mark_safe | |
from django.utils.encoding import force_unicode | |
class BootstrapRadioFieldRenderer(forms.RadioSelect.renderer): | |
def render(self): | |
"""Outputs a <ul> for this set of radio fields.""" | |
return mark_safe('<span id="id_%s"></span>' | |
'<ul class="inputs-list">\n%s\n</ul>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list_detail.object_list replacement with all the things I need | |
def object_list(request, queryset, extra_context=None, | |
template_name='', paginate_by=None): | |
class ObjectList(ListView): | |
def post(self, request, *args, **kwargs): | |
return self.get(request, *args, **kwargs) | |
def get_context_data(self, **kwargs): | |
c = super(ObjectList, self).get_context_data(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if sys.argv[1] == "test": | |
import psutil | |
def mysqld_ram_running(): | |
return any('mysqld-ram.sh' in ' '.join(p.cmdline) for p in psutil.get_process_list()) | |
if mysqld_ram_running(): | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', | |
'NAME': 'djangotests', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('step3.txt') as f: | |
for l in f: | |
json_dict = json.loads(l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hints: | |
= Step 2 = | |
1) The first line of the table is different from the others | |
2) It should be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request: | |
----- | |
DELETE /v0/subscription HTTP/1.1 | |
Host: api.sign-up.to | |
Content-Length: 16 | |
accept-encoding: gzip, deflate | |
content-type: application/json | |
accept: application/json | |
authorization: SuTToken blahblahblah | |
user-agent: Python-httplib2/0.8 (gzip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using my client | |
from signupto import Client, TokenAuthorization | |
client = Client(auth=TokenAuthorization(username='[email protected]', | |
password='my_strong_password')) |
OlderNewer