Skip to content

Instantly share code, notes, and snippets.

View dex4er's full-sized avatar

Piotr Roszatycki dex4er

  • Berlin, Germany
View GitHub Profile
@dex4er
dex4er / t_webapp.t
Created June 3, 2016 13:12
Mojolicious test script
use v5.14;
use warnings;
use Test::More;
use Test::Mojo;
use FindBin;
require "$FindBin::Bin/../webapp.pl";
my $t = Test::Mojo->new;
@dex4er
dex4er / tcp_server_on_line.pl
Last active September 26, 2018 20:05
Mojo TCP server which emits signal for each line
use v5.14;
use Mojo::IOLoop;
use Data::Dump;
my %opts = (address => '0.0.0.0', port => 1514, map { split /=/, $_, 2 } @ARGV);
Mojo::IOLoop->server(%opts, sub {
my ($loop, $stream, $id) = @_;
@dex4er
dex4er / etc_ppp_peers_noauth
Created December 22, 2015 14:08
pppd over ssh -tt
noauth
@dex4er
dex4er / change_list.html
Last active February 23, 2020 19:24
result_list with support for aggregated QuerySet for Django 1.8.4
{# templates/admin/change_list.html #}
{% extends "admin/base_site.html" %}
{% load i18n admin_urls admin_static admin_list values_result_list %}
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" />
{% if cl.formset %}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
@dex4er
dex4er / coffeekebab.c
Last active September 16, 2015 09:14
Caffeekekab Facebook riddle
#include <stdio.h>
#include <string.h>
int count_stickers(char *word) {
int f = 0, a = 0, c = 0, e = 0, b = 0, o = 0, k = 0;
int max = 0;
int i = strlen(word);
while (i--) {
#### Contents of the preconfiguration file (for jessie)
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string pl_PL
# The values can also be preseeded individually for greater flexibility.
#d-i debian-installer/language string en
#d-i debian-installer/country string NL
#d-i debian-installer/locale string en_GB.UTF-8
# Optionally specify additional locales to be generated.
@dex4er
dex4er / README.md
Last active October 1, 2015 14:42
WebdriverIO - example how to click through webpage
@dex4er
dex4er / go.syntax
Created June 9, 2015 10:03
Go language syntax highlight for Midnight Commander (mcedit)
# ~/.local/share/mc/go.syntax
#
# requires ~/.config/mc/mcedit/Syntax with lines:
# file ..\*\\.(go)$ Go\sSource
# include go.syntax
context default
# keywords
keyword whole break brightblue
keyword whole case brightblue
@dex4er
dex4er / mojo-dns.pl
Created March 29, 2015 09:38
Mojo and UDP packages
#!/usr/bin/env perl
package My::Mojo::IOLoop;
use Mojo::Base 'Mojo::IOLoop';
use Scalar::Util 'weaken';
sub client {
my ($self, $cb) = (_instance(shift), pop);
@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)