Skip to content

Instantly share code, notes, and snippets.

View Visgean's full-sized avatar

martin Visgean

View GitHub Profile
import datetime
from collections import Counter
In [61]: days = [datetime.date(day=1, month=1, year = year).isoweekday() for year in range(1582,2014)]
In [62]: print days
[5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7, 1, 2, 3, 5, 6, 7, 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, 7, 1, 2, 4, 5, 6, 7, 2, 3, 4, 5, 7,
@Visgean
Visgean / switch_apple.py
Last active August 29, 2015 13:56
switches from and to apple keyboard (apple keyboard has ctrl,alt,meta layout and I want to have ctrl, meta, alt layout)
#!/usr/bin/env python
# This script switches from and to apple keyboard (apple keyboard has ctrl,alt,meta layout and I want to have ctrl, meta, alt layout)
import subprocess
from gi.repository import Gio
SWITCH_ALT_WIN = 'altwin:swap_lalt_lwin' # kxb option to switch left win and alt, have a look in /usr/share/X11/xkb/rules/base.lst
gsettings = Gio.Settings.new('org.gnome.desktop.input-sources')
current_settings = gsettings['xkb-options']
function make_groups(str){
// makes an array of strings, for example aabb -> [[2,'a'], [2,'b']]
var boundaries = [];
var groups = [];
var current_letter = null
for (var i = 0, len = str.length; i < len; i++) {
if (str[i] !== current_letter){
current_letter = str[i];
wget https://sslimgs.xkcd.com/comics/now/{00..23}h{00,15,30,45}m.png
convert -delay 20 -loop 0 *.png wheee.gif
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
matrix=[[1,2,3,4,5],
[6,7,8,9,10],
[11,12,13,14,15],
[16,17,18,19,20],
[21,22,23,24,25]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Visgean
Visgean / download_images.py
Created April 24, 2014 15:04
Download all the sweet debatovani.cz photos.
import facebook
import os
import sh
from slugify import slugify
oauth_access_token = ''
root = '/debatovani.cz/albums'
graph = facebook.GraphAPI(oauth_access_token)
import datetime
import json
import time
import requests
API_KEY = ''
from_date = datetime.datetime(2014, 4, 4, 0, 0)
end_date = datetime.datetime(2014, 4, 7, 0, 0)
def convert_dict_to_update(dictionary, roots=None, return_dict=None):
"""
Returns a new dict that can be used in Document.update(**dict),
this is used for updating MongoEngine documents with dictionary
serialized from json.
>>> data = {'email' : 'email@example.com'}
>>> convert_dict_to_update(data)
{'set__email': 'email@example.com'}
map.defineObject('bl_up', {
'type': 'dynamic',
'symbol': '.',
'color': 'yellow',
'interval': 100,
'projectile': true,
'behavior': function (me) {
me.move('up');
}
});