Skip to content

Instantly share code, notes, and snippets.

View vladris's full-sized avatar
🤠

Vlad Riscutia vladris

🤠
View GitHub Profile
@vladris
vladris / XElementDynamicDeserializer.cs
Created December 3, 2017 16:59
Extension method for XElement to deserialize into a dynamic object
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
@vladris
vladris / 24.py
Last active August 5, 2017 20:01
24 solver
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 ["(...).(...)", "((...)..)..", "(..(...)).."]:
@vladris
vladris / curry.cpp
Created October 14, 2016 06:02
Simple curry recipe
template <typename Func, typename Arg>
struct curry_t
{
template <typename ...Args>
auto operator()(Args&& ...args)
{
return _func(_arg, std::forward<Args>(args)...);
}
Func _func;
@vladris
vladris / snow.scss
Created April 3, 2016 03:08
TV snow effect
@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();
@vladris
vladris / scribe.py
Created December 31, 2014 03:39
Tumblr migration script to move content from a blog to another
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'