Skip to content

Instantly share code, notes, and snippets.

View dex4er's full-sized avatar

Piotr Roszatycki dex4er

  • Berlin, Germany
View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use Mail::Message;
use Mail::Message::Convert::HtmlFormatText;
my $af = Mail::Message::Convert::HtmlFormatText->new;
@dex4er
dex4er / alias.pl
Created May 17, 2014 10:50
mop traits
use mop;
use feature qw(postderef);
no warnings qw(experimental::postderef);
use Carp qw(confess);
use Package::Stash;
sub alias {
my $meta = shift;
#!/usr/bin/env starlight
use AnyEvent::DNS::EtcHosts;
use Plack::Builder;
use Plack::App::Proxy;
builder {
enable 'AccessLog';
enable 'Proxy::Connect';
enable 'Proxy::Requests';
@dex4er
dex4er / mojo+wx.pl
Last active August 29, 2015 14:03
wxPerl
#!/usr/bin/env perl
use v5.14;
package MyApp {
use Moo;
use Wx ':everything';
has url => is => 'ro';
@dex4er
dex4er / crontab
Created October 21, 2014 12:25
autossh
SHELL=/bin/bash
* * * * * . $HOME/.profile && { cd $HOME && run-parts --report $HOME/cron.minutely; }
ENABLED="true"
OPTIONS="
--log-level=warning
--log-file=/var/log/mysql-proxy.log
--admin-username=proxy
--admin-password=proxy
--admin-lua-script=/usr/share/mysql-proxy/admin.lua
--proxy-backend-addresses=10.0.0.1:3306
--proxy-backend-addresses=10.0.0.2:3306
@dex4er
dex4er / Mojo_Asset_Null.pm
Last active August 29, 2015 14:10
Mojo::Asset::Null
package Mojo::Asset::Null;
use Mojo::Base 'Mojo::Asset';
has size => 0;
sub add_chunk {
my ($self, $chunk) = @_;
$self->{size} += length($chunk);
return $self;
from django import http
from django.conf import settings
XS_SHARING_ALLOWED_ORIGINS = getattr(settings, 'XS_SHARING_ALLOWED_ORIGINS', '*')
XS_SHARING_ALLOWED_METHODS = getattr(settings, 'XS_SHARING_ALLOWED_METHODS', ['POST', 'GET', 'OPTIONS', 'PUT', 'DELETE'])
XS_SHARING_ALLOWED_HEADERS = getattr(settings, 'XS_SHARING_ALLOWED_HEADERS', ['Content-Type', '*'])
XS_SHARING_ALLOWED_CREDENTIALS = getattr(settings, 'XS_SHARING_ALLOWED_CREDENTIALS', 'true')
class XsSharing(object):
@dex4er
dex4er / bu.py
Last active August 29, 2015 14:13
Portable bytes and unicode for Python 2.x and 3.x
import sys
DEFAULT_CHARSET = 'utf-8'
if sys.version_info >= (3, 0):
def b(string, charset=DEFAULT_CHARSET):
if isbytes(string):
return bytes(string)
@dex4er
dex4er / Lazy.py
Created January 15, 2015 10:09
Lazy attribute for Python
class lazy(object):
def __init__(self, default=None, name=None):
self.default = default
self.name = name
def __get__(self, obj, objtype):
if obj is None:
return self
if callable(self.default):
default = self.default(obj if obj is not None else objtype)