Skip to content

Instantly share code, notes, and snippets.

@ctrngk
ctrngk / set-up-l2tp-ipsec-vpn-on-debian.md
Created January 28, 2016 05:03 — forked from mietek/set-up-l2tp-ipsec-vpn-on-debian.md
Set up L2TP/IPsec VPN on Debian

Set up L2TP/IPsec VPN on Debian

Set up IPsec

Set up networking

@ctrngk
ctrngk / openswan-l2tp-vpn-ubuntu.sh
Created July 27, 2016 17:31 — forked from jpillora/openswan-l2tp-vpn-ubuntu.sh
openswan-l2tp-vpn-ubuntu.sh
#!/bin/sh
# Setup Simple IPSec/L2TP VPN server for Ubuntu and Debian
#
# Copyright (C) 2014 Phil Plückthun <phil@plckthn.me>
# Based on the work of Lin Song (Copyright 2014)
# Based on the work of Viljo Viitanen (Setup Simple PPTP VPN server for Ubuntu and Debian)
# Based on the work of Thomas Sarlandie (Copyright 2012)
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
@ctrngk
ctrngk / timeout.py
Created July 27, 2016 18:05 — forked from devietti/timeout.py
Python script+module to run a command with a timeout. A signal (SIGKILL by default) is sent to the command if the timeout expires.
#!/usr/bin/env python
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ctrngk
ctrngk / bash.py
Created July 27, 2016 18:19 — forked from kirpit/bash.py
Enables to run subprocess commands in a different thread with TIMEOUT option!
#! /usr/bin/env python
import threading
import subprocess
import traceback
import shlex
class Command(object):
"""
Enables to run subprocess commands in a different thread with TIMEOUT option.
@ctrngk
ctrngk / stripe-checkout.html
Created September 8, 2016 16:54 — forked from ziadoz/stripe-checkout.html
Custom Stripe Checkout Button
<form action="." method="post">
<noscript>You must <a href="http://www.enable-javascript.com" target="_blank">enable JavaScript</a> in your web browser in order to pay via Stripe.</noscript>
<input
type="submit"
value="Pay with Card"
data-key="PUBLISHABLE STRIPE KEY"
data-amount="500"
data-currency="cad"
data-name="Example Company Inc"
@ctrngk
ctrngk / client.html
Created September 27, 2016 09:01 — forked from ericremoreynolds/client.html
Flask-socket.io emit to specific clients
<html>
<body>
<h1>I feel lonely</h1>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
<script type="text/javascript" charset="utf-8">
var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('connect', function() {
socket.emit('connected');
@ctrngk
ctrngk / Django + Ajax dynamic forms .py
Created January 3, 2017 03:51 — forked from goldhand/Django + Ajax dynamic forms .py
Django form with Ajax. A simple Task model that can be updated using a CBV with an AJAX mixin. The view sends post data with ajax then updates the view with a callback to a DetailView with a json mixin.There is an abstract CBV, AjaxableResponseMixin, based on the example form django docs, that is subclassed in the TaskUpdateView CBV. TaskUpdateV…
#models.py
class Task(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
def __unicode__(self):
return self.title
@ctrngk
ctrngk / dedict.c
Created January 3, 2017 10:28 — forked from josephg/0dedict.py
Apple dictionaries
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"
#define CHUNK 16384
/*
40 Length of the zlib stream
@ctrngk
ctrngk / daemon.py
Created February 24, 2017 14:04 — forked from josephernest/daemon.py
Daemon for Python
# From "A simple unix/linux daemon in Python" by Sander Marechal
# See http://stackoverflow.com/a/473702/1422096
#
# Modified to add quit() that allows to run some code before closing the daemon
# See http://stackoverflow.com/a/40423758/1422096
#
# Joseph Ernest, 2016/11/12
import sys, os, time, atexit
from signal import signal, SIGTERM
@ctrngk
ctrngk / daemon.md
Created February 24, 2017 14:52 — forked from andreif/daemon.md
A simple unix/linux daemon in Python

A simple unix/linux daemon in Python

Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

Access: http://web.archive.org/web/20131025230048/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

by Sander Marechal

I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.