Skip to content

Instantly share code, notes, and snippets.

View Leechael's full-sized avatar
🐹
Working from home

Leechael Leechael

🐹
Working from home
View GitHub Profile
@Leechael
Leechael / maybe.py
Last active December 29, 2016 04:34 — forked from zvyn/maybe.py
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Milan Oberkirch <milan.py@oberkirch.org>
# 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:
@Leechael
Leechael / result.py
Last active January 16, 2019 23:10
Thanks Rust!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import copy
PY2 = sys.version_info[0] == 2
class Result(object):
@Leechael
Leechael / fputils.py
Created November 30, 2016 10:32
Buggy: inspect.iscoroutinefunction and inspect.isfunction :(
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import inspect
def iscoroutinefunction(fn):
if inspect.iscoroutinefunction(fn):
return True
if inspect.iscoroutinefunction(getattr(fn, "__call__", None)):
return True
@Leechael
Leechael / timing.py
Created July 31, 2016 16:35
Poorman's mitmproxy based request timing
from time import time
def start(context):
context.log("Format: [send data timing] [waitting timing] [receive data timing] Request URL")
def request(context, flow):
context.started_at = time()
def response(context, flow):
sending = flow.request.timestamp_end - flow.request.timestamp_start
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import environ, path, makedirs
import imghdr
from datetime import datetime, timedelta
from concurrent.futures import ThreadPoolExecutor
from tornado import gen
from tornado.concurrent import run_on_executor
@Leechael
Leechael / ssl-cert-info.sh
Last active February 20, 2016 15:20
Added `-servername` option to get correct info for sub-domain. Original: http://giantdorks.org/alain/shell-script-to-check-ssl-certificate-info-like-expiration-date-and-subject/
#!/bin/bash
usage()
{
cat <<EOF
Usage: $(basename $0) [options]
This shell script is a simple wrapper around the openssl binary. It uses
s_client to get certificate information from remote hosts, or x509 for local
certificate files. It can parse out some of the openssl output or just dump all
@Leechael
Leechael / main.rs
Created September 23, 2015 09:41
Simple log parser in Rust-Lang
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::path::Path;
struct Hit {
ip: String,
datetime: String,
#!/bin/bash
# virtualenv-auto-activate.bash
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.bash
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
@Leechael
Leechael / gulpfile.js
Created July 14, 2014 09:31
gulpfile.js for browserify + backbone.js + ractive.js, with watchify
var path = require("path");
var gulp = require("gulp");
var less = require("gulp-less");
var notify = require("gulp-notify");
var rename = require("gulp-rename");
var minifyCSS = require("gulp-minify-css");
var uglify = require("gulp-uglifyjs");
var livereload = require("gulp-livereload");
var source = require("vinyl-source-stream");
@Leechael
Leechael / foo.swift
Created June 3, 2014 07:19
Property as method and overriding in Swift (impossible for method)
import Cocoa
class A {
var foo : () -> String
var baz : Int
init () {
func _foo () -> String {
return "halo"
}