Skip to content

Instantly share code, notes, and snippets.

@Ilgrim
Ilgrim / test.py
Created March 15, 2018 19:00
Execute at flask initialization
"""
one way to excute something after app.run:
build another app!
From
http://librelist.com/browser/flask/2012/6/7/execute-at-flask-initialization/#a0b5c59832f372f69be6f6e2af4ae4f9
"""
from flask import Flask
import webbrowser
@Ilgrim
Ilgrim / client.py
Created May 29, 2018 05:11 — forked from berendiwema/client.py
python multiprocessing socket server example
import socket
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 9000))
data = "some data"
sock.sendall(data)
result = sock.recv(1024)
print result
sock.close()
@Ilgrim
Ilgrim / getWeek.js
Created May 29, 2018 10:09 — forked from dblock/getWeek.js
get week of the year in JavaScript
function( d ) {
// Create a copy of this date object
var target = new Date(d.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (d.getDay() + 6) % 7;
// Set the target to the thursday of this week so the
import os
import json
import datetime
from flask import Flask, url_for, redirect, \
render_template, session, request
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, login_required, login_user, \
logout_user, current_user, UserMixin
from requests_oauthlib import OAuth2Session
@Ilgrim
Ilgrim / metapoop.py
Created June 2, 2018 11:12 — forked from mikofski/metapoop.py
Another Python metaclass primer
#! /usr/bin/env python
"""
Python metaclasses
==================
A metaclass is a class factory; metaclasses serve two purposes:
1. replace ``type`` as the base class metatype for classes with the
``__metaclass__`` attribute
<?php
/*
* Google oAuth 2.0 PHP Curl boilerplate
* Google Tasks API example
*
*
* Settings
*
* scope Space-delimited set of permissions that the application requests.
* state Provides any state that might be useful to your application upon receipt of the response.
@Ilgrim
Ilgrim / instructions.md
Created July 6, 2018 20:33 — forked from johnko/instructions.md
Installing FreeBSD on a USB drive with ZFS using bsdinstall unattended

Installing FreeBSD on a USB drive with ZFS using bsdinstall unattended

I typically wrap all these commands into a shell script that I can reuse, but here they are in steps.

Please read through all the instructions before actually performing the commands, just to avoid any surprises

Requirements:

  • careful typing and copy/paste skills
  • USB drive (8 GB+ ?) Make sure you don't need anything on that drive
@Ilgrim
Ilgrim / kong-dns.md
Created July 14, 2018 01:42 — forked from montanaflynn/kong-dns.md
Example of using Kong with DNS

Kong

Kong is a powerful proxy built on nginx. By taking a request and passing it to an upstream server and then returning the result to the client Kong can perform his magic. To know which requests go to which service Kong looks for a Host header to match against. There's a few other ways Kong can match requests to services but for now that's the most basic route. Pun intended.

Start

Assuming everything has been installed and setup, such as dependencies and config files which can be found in the docs, it's time to turn Kong on. The first time Kong runs you'll see some Kong config values and initial migrations to the datastore.

kong start
@Ilgrim
Ilgrim / tmux.conf
Created August 10, 2018 17:57 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@Ilgrim
Ilgrim / curl_example.cpp
Created August 10, 2018 22:46 — forked from alghanmi/curl_example.cpp
cURL C++ Example
#include <iostream>
#include <string>
#include <curl/curl.h>
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}