Skip to content

Instantly share code, notes, and snippets.

Avatar

Piotr Roszatycki dex4er

View GitHub Profile
View mailbody.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Mail::Message;
use Mail::Message::Convert::HtmlFormatText;
my $af = Mail::Message::Convert::HtmlFormatText->new;
View proxy.psgi
#!/usr/bin/env starlight
use AnyEvent::DNS::EtcHosts;
use Plack::Builder;
use Plack::App::Proxy;
builder {
enable 'AccessLog';
enable 'Proxy::Connect';
enable 'Proxy::Requests';
View alias.pl
use mop;
use feature qw(postderef);
no warnings qw(experimental::postderef);
use Carp qw(confess);
use Package::Stash;
sub alias {
my $meta = shift;
View mojo+wx.pl
#!/usr/bin/env perl
use v5.14;
package MyApp {
use Moo;
use Wx ':everything';
has url => is => 'ro';
View crontab
SHELL=/bin/bash
* * * * * . $HOME/.profile && { cd $HOME && run-parts --report $HOME/cron.minutely; }
View etc_default_mysql-proxy.txt
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 Aug 29, 2015
Mojo::Asset::Null
View Mojo_Asset_Null.pm
package Mojo::Asset::Null;
use Mojo::Base 'Mojo::Asset';
has size => 0;
sub add_chunk {
my ($self, $chunk) = @_;
$self->{size} += length($chunk);
return $self;
View middleware.py
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 Aug 29, 2015
Portable bytes and unicode for Python 2.x and 3.x
View bu.py
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 Jan 15, 2015
Lazy attribute for Python
View Lazy.py
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)