Skip to content

Instantly share code, notes, and snippets.

View dex4er's full-sized avatar

Piotr Roszatycki dex4er

View GitHub Profile
@dex4er
dex4er / NoCsrfForJSONGraphQLView.py
Last active April 17, 2019 20:20
NoCsrfForJSONGraphQLView.py
from graphene_django.views import GraphQLView
from django.conf import settings
from django.utils.decorators import classonlymethod
from django.views.decorators.csrf import csrf_protect, csrf_exempt
class NoCsrfForJSONGraphQLView(GraphQLView):
@classonlymethod
def as_view(cls, **kwargs):
@dex4er
dex4er / schoolPerson.js
Last active May 21, 2018 16:13
Example from https://reasonml.github.io/ as Typescript
class Teacher {
}
class Director {
}
class Student {
constructor(name) {
this.name = name;
}
}
function greeting(stranger) {
ab -n 10000 -c 100 -T text/json -p ping.json http://127.0.0.1:5000/ping/
declare module 'nodemailer/lib/shared' {
type LoggerLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'
interface Logger {
level (level: LoggerLevel): void
trace (...params: any[]): void
debug (...params: any[]): void
info (...params: any[]): void
warn (...params: any[]): void
error (...params: any[]): void
@dex4er
dex4er / smtp-server-as-promised.ls
Created August 28, 2016 08:44
Promisified version of smtp-server
require! {
'promise-once-events'
'smtp-server'
}
const SERVER_PORT = 25
module.exports = class smtp-server-as-promised extends promise-once-events
(@options = {}) ->
@dex4er
dex4er / csv2json.pl
Last active September 13, 2016 19:01
CVS to JSON converter
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use JSON::PP ();
use Getopt::Long qw(GetOptions);
our $VERSION = 0.01;
@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" %}" />