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 pytumblr | |
import yaml | |
import os | |
import urllib | |
# stolen from interactive_console.py, because I'm too lazy to oauth | |
# you'll need to register an app with Tumblr and use interactive_console.py for initial oauth | |
def create_client(): | |
yaml_path = os.path.expanduser('~') + '/.tumblr' |
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
@function random-gray(){ | |
$col:random(5); | |
@return rgb($col * 51, $col * 51, $col * 51); | |
} | |
@function grid-dots(){ | |
$sh:(); | |
@for $j from 1 through 20 { | |
@for $i from 1 through 20 { | |
$sh: $sh, (($i*10px)-(10px)) (($j*10px)-(10px)) 0 random-gray(); |
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
template <typename Func, typename Arg> | |
struct curry_t | |
{ | |
template <typename ...Args> | |
auto operator()(Args&& ...args) | |
{ | |
return _func(_arg, std::forward<Args>(args)...); | |
} | |
Func _func; |
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 itertools import permutations, product, zip_longest | |
from sys import argv | |
args = sum([[1, 11] if arg in "aA" else [int(arg)] for arg in argv[1:5]], []) | |
for xs in permutations(args, 4): | |
if sum(n == 1 or n == 11 for n in xs) > len(args) - 4: | |
continue | |
for ops in product("+-*/", repeat=3): | |
for exp in ["(...).(...)", "((...)..)..", "(..(...)).."]: |
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 System; | |
using System.Collections.Generic; | |
using System.Dynamic; | |
using System.Xml.Linq; | |
/// <summary> | |
/// Provides extension method for XElement to deserialize to a dynamic object | |
/// | |
/// The element's attributes will be stored as properties on the dynamic object. | |
/// The child elements will also be stored as properties on the dynamic object with the |
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
components = [tuple(map(int, line.strip().split('/'))) for line in open("input.txt").readlines()] | |
def best_bridge(end, components): | |
result = 0 | |
for i, c in enumerate(components): | |
if end == c[0]: | |
new_end = c[1] | |
elif end == c[1]: | |
new_end = c[0] | |
else: |
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
class Graph: | |
def __init__(self, nodes=dict(), edges=[]): | |
self.nodes = nodes | |
self.edges = edges | |
self.colors = len(set(nodes.values())) | |
def connected(self, node): | |
for edge in self.edges: | |
if edge[0] == node: | |
yield edge[1] |
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
// Since generics in Java are removed at compile-time, we cannot overload methods | |
// based on generic types | |
// Below class does not compile: | |
// Erasure of method Foo(T1) is the same as another method in type Test<T1,T2> | |
// Erasure of method Foo(T2) is the same as another method in type Test<T1,T2> | |
class Generic<T1, T2> { | |
void Foo(T1 arg) { | |
} | |
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
#include <type_traits> | |
// Natural numbers | |
struct nat { }; | |
// Typed only if T is derived from nat | |
template <typename T> | |
using nat_only = std::enable_if_t<std::is_base_of<nat, T>::value>; | |
// Zero is a natural number |
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
#include <array> | |
#include <fstream> | |
#include <iostream> | |
using namespace std; | |
const size_t memory_size = 1024; | |
template <typename It> | |
It& skip(It&& it, char from, char to) { |
OlderNewer