Skip to content

Instantly share code, notes, and snippets.

@cghiban
cghiban / upload.pl
Last active August 29, 2015 14:17 — forked from jberger/upload.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojo::JSON 'j';
use Mojo::Asset::Memory;
use File::Spec;
helper send_ready_signal => sub {
my $self = shift;
my $payload = { ready => \1 };
@cghiban
cghiban / web-servers.md
Created November 4, 2015 19:58 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@cghiban
cghiban / microcache.conf
Created January 6, 2016 20:50 — forked from bylatt/microcache.conf
nginx confing for microcache
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:10m max_size=1024m inactive=15m;
map $http_cookie $cache_uid {
default nil; # hommage to Lisp :)
~SESS[[:alnum:]]+=(?<session_id>[[:alnum:]]+) $session_id;
}
map $request_method $no_cache {
default 1;
HEAD 0;
GET 0;
@cghiban
cghiban / gist:7887f85dc08b61826c78
Created January 6, 2016 20:51 — forked from fennb/gist:1283573
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
@cghiban
cghiban / audit_mixin.py
Created January 14, 2016 22:35 — forked from techniq/audit_mixin.py
Useful SQLAlchemy Mixins
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@cghiban
cghiban / grab-frame.sh
Created March 22, 2016 18:25
static-videos
#/bin/sh
input=$1
fname=$(echo $input|sed -e 's/\.\w*$//')
avconv -v quiet -i $input -vframes 1 -an -f image2 -y $fname.jpg
#!/usr/bin/env bash
perl_version='5.25.6'
perl_version='5.24.0'
verify_pkg() {
pkg="$1"
[[ $(which "${pkg}") ]] || {
echo "${pkg} not found. Exiting..."
exit 1
@cghiban
cghiban / introrx.md
Created April 18, 2017 14:28 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
#!/bin/sh
input=$1
size=$(ffmpeg $1 2>&1|grep -E "[0-9]x[0-9]"|sed -e 's/^.*\s\([0-9]*x[0-9]*\),.*/\1/')
echo "$1\t$size"