Skip to content

Instantly share code, notes, and snippets.

Senko Rašić senko

Block or report user

Report or block senko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@senko
senko / backup-repo-issues.py
Created Jul 12, 2019
Backup GitHub issues from a single repository
View backup-repo-issues.py
#!/usr/bin/env python
#
# Backs up all issues (open and closed) from a specified repository, together with their comments
# Uses GitHub API v3 and requires a valid API token
#
# Installation:
# python3 -m venv /path/to/virtualenv
# source /path/to/virtualenv/bin/activate
# pip install requests
View Why node ecosystem sucks
To anyone who asks why we're rewriting AWW backend in anything other than nodejs, here's an example. This is an output log from an automated server provisioning script that in theory should automatically install AWW. In practice, I have to fudge it every few months because the node packages keep breaking. This is even though we've pinned all our dependencies to an exact version.
Damn them all to hell.
^
/home/aww/.node-gyp/0.12.15/include/node/node.h:273:1: note: in expansion of macro ‘NODE_DEPRECATED’
NODE_DEPRECATED("Use FatalException(isolate, ...)",
^
/home/aww/.node-gyp/0.12.15/include/node/node.h: In function ‘v8::Local<v8::Value> node::Encode(const void*, size_t, node::encoding)’:
/home/aww/.node-gyp/0.12.15/include/node/node.h:287:62: warning: ‘v8::Local<v8::Value> node::Encode(v8::Isolate*, const void*, size_t, node::encoding)’ is deprecated (declared at /home/aww/.node-gyp/0.12.15/include/node/node.h:278): Use FatalException(isolate, ...) [-Wdeprecated-declarations]
@senko
senko / maybe.py
Last active Jun 16, 2019
A Pythonic implementation of the Maybe monad
View maybe.py
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@senko
senko / updated.py
Created Jul 11, 2013
updated - create and return a new Python dictionary by merging multiple dictionaries
View updated.py
#!/usr/bin/env python
#
# Written in 2013. by Senko Rasic <senko.rasic@dobarkod.hr>
# This code is Public Domain. You may use it as you like.
__all__ = ['updated']
def updated(dct, *others):
@senko
senko / i18n.py
Created Mar 21, 2013
Compile translations for all languages in a single map, for Django.
View i18n.py
from gettext import translation
import os.path
from django.conf import settings
def get_all_translations(domain):
"""Return a language code => translations mapping for all defined
languages. This is useful if in a single view you need to use
different translation catalogs at the same time.
@senko
senko / create-new-lxc.sh
Created Mar 1, 2013
Set up a new LXC virtual machine
View create-new-lxc.sh
#!/bin/bash
#
# Initialize new virtual server using LXC and set up networking and HTTP proxy
#
# Written by: Deni Bertovic <deni.bertovic@dobarkod.hr>
#
# Released into Public Domain. You may use, modify and distribute it as you
# see fit.
#
# This script will:
@senko
senko / singleton.py
Created Feb 25, 2013
Singleton Django Model
View singleton.py
# Written by Senko Rasic <senko.rasic@goodcode.io>
# Released into Public Domain. Use it as you like.
from django.db import models
class SingletonModel(models.Model):
"""Singleton Django Model
Ensures there's always only one entry in the database, and can fix the
@senko
senko / trigger.py
Created Jan 9, 2013
When triggered via a HTTP request, execute a command.
View trigger.py
#!/usr/bin/env python
#
# When triggered via a HTTP request, execute a command.
#
# Written by Senko Rasic <senko.rasic@goodcode.io>
# Released into Public Domain. Use it as you like.
#
# Usage: python trigger.py <host> <port> <key> <command>...
#
# HTTP GET and POST requests are supported. If you need more verbs or need
@senko
senko / structsign.py
Created Nov 16, 2012
sign_structure - sign nested Python structures (including dicts) while ignoring dict ordering
View structsign.py
from hashlib import sha1
import unittest
__all__ = ['sign_structure']
def sign_structure(data):
"""Create a (non-cryptographic) signature of the data structure.
This function makes sure that dict item ordering doesn't matter.
@senko
senko / screen-paste.sh
Created Sep 26, 2012
Grab a screenshot and paste it to the Web using pixbin.us
View screen-paste.sh
#!/bin/bash
#
# screen-paste - Paste a screenshot to the Web (using pixbin.us service)
#
# Written by Senko Rasic <senko.rasic@goodcode.io>
# Released into Public Domain. Use it as you like.
#
# The tool allows the user to select a portion of the screen, then copies it
# to pixbin.us, and stores the resulting URL in clipboard.
#
You can’t perform that action at this time.