Skip to content

Instantly share code, notes, and snippets.

@sp3c73r2038
sp3c73r2038 / syslogging.py
Last active August 29, 2015 14:04
logging with syslog
# -*- coding: utf-8 -*-
# using logging module
#
# see https://docs.python.org/3.3/library/logging.handlers.html#sysloghandler
#
import logging
from logging.handlers import SysLogHandler
from logging import StreamHandler, Formatter
@sp3c73r2038
sp3c73r2038 / gitlab7.0_show_all_groups.patch
Created July 11, 2014 06:58
patch that addes a /groups page to show all groups, for GitLab 7.0.0
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index a2629c5..020220e 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -4,7 +4,7 @@ class GroupsController < ApplicationController
before_filter :group, except: [:new, :create]
# Authorize
- before_filter :authorize_read_group!, except: [:new, :create]
+ before_filter :authorize_read_group!, except: [:new, :create, :index]
@sp3c73r2038
sp3c73r2038 / gui.py
Created May 23, 2014 08:30
responsible GUI with multiprocessing.
# -*- coding: utf-8 -*-
from datetime import datetime
from multiprocessing import Process
from time import sleep
import tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
@sp3c73r2038
sp3c73r2038 / refind.conf
Last active August 29, 2015 14:01
refind.conf for multi-boot on Macbook Pro
# /EFI/refind/refind.conf
# gives you chance to change choice, manually
timeout 5
# tools for debuging, reboot without pushing damn button
showtools shell,reboot,exit
# scan internal disks, extenal(USB?) disks,
# optical drivers, and specify by following
@sp3c73r2038
sp3c73r2038 / multilingualism.rb
Last active August 29, 2015 14:01
multilingualism support for jekyll
# example
# .
# |-- about.md
# |-- _config.yml
# |-- css
# | `-- main.css
# |-- feed.xml
# |-- .gitignore
# |-- _includes
# | |-- footer.html
@sp3c73r2038
sp3c73r2038 / test.rb
Created April 5, 2014 14:42
sequel example usage
# -*- encoding: binary -*-
require 'sequel'
require 'sqlite3'
Bundler.require(:default, :development)
DB = Sequel.connect("sqlite:///tmp/test.db")
# DB.create_table(:users) do
@sp3c73r2038
sp3c73r2038 / server.py
Created February 10, 2014 09:03
forking worker process server, handling signals with a queue. idea stolen from unicorn.
#!/usr/bin/env python
from datetime import datetime
import errno
from fcntl import fcntl, F_SETFL
import logging
import os
from select import select
from signal import signal, SIGQUIT, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, SIGHUP
from signal import SIGCHLD, SIG_DFL, SIGKILL
import sys
@sp3c73r2038
sp3c73r2038 / sig_queue.py
Created January 23, 2014 04:25
handle signal using a queue, stolen from unicorn :)
#!/usr/bin/env python
import errno
from fcntl import fcntl, F_SETFL
import os
from select import select
from signal import signal, SIGQUIT, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, SIGHUP
from time import sleep
class Server(object):
@sp3c73r2038
sp3c73r2038 / fork.py
Created January 20, 2014 08:24
master/worker prefork process model.
#!/usr/bin/env python
from __future__ import unicode_literals, print_function
import os
from time import sleep
WORKERS = 3
_cnt = 0
while _cnt < WORKERS: