Skip to content

Instantly share code, notes, and snippets.

@aleiphoenix
aleiphoenix / server.py
Created Feb 10, 2014
forking worker process server, handling signals with a queue. idea stolen from unicorn.
View server.py
#!/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
@aleiphoenix
aleiphoenix / test.rb
Created Apr 5, 2014
sequel example usage
View test.rb
# -*- encoding: binary -*-
require 'sequel'
require 'sqlite3'
Bundler.require(:default, :development)
DB = Sequel.connect("sqlite:///tmp/test.db")
# DB.create_table(:users) do
@aleiphoenix
aleiphoenix / multilingualism.rb
Last active Aug 29, 2015
multilingualism support for jekyll
View multilingualism.rb
# example
# .
# |-- about.md
# |-- _config.yml
# |-- css
# | `-- main.css
# |-- feed.xml
# |-- .gitignore
# |-- _includes
# | |-- footer.html
@aleiphoenix
aleiphoenix / refind.conf
Last active Aug 29, 2015
refind.conf for multi-boot on Macbook Pro
View refind.conf
# /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
@aleiphoenix
aleiphoenix / gui.py
Created May 23, 2014
responsible GUI with multiprocessing.
View gui.py
# -*- 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)
@aleiphoenix
aleiphoenix / gitlab7.0_show_all_groups.patch
Created Jul 11, 2014
patch that addes a /groups page to show all groups, for GitLab 7.0.0
View gitlab7.0_show_all_groups.patch
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]
@aleiphoenix
aleiphoenix / syslogging.py
Last active Aug 29, 2015
logging with syslog
View syslogging.py
# -*- 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
@aleiphoenix
aleiphoenix / ical_dump.py
Last active Aug 29, 2015
a simple python script dump ical basic info to stdout.
View ical_dump.py
# -*- coding: utf-8 -*-
import sys
## It seems that locale will always be C(ascii) when
## mutt call this script via mailcap
reload(sys)
sys.setdefaultencoding('utf-8')
from icalendar import Calendar
import pytz
@aleiphoenix
aleiphoenix / mozconfig
Created Nov 11, 2014
mozilla build config for Hardened Gentoo x86_64
View mozconfig
export LDFLAGS="-Wl,-z,relro,-z,now"
mk_add_options PYTHON=/usr/bin/python2
mk_add_options AUTOCONF=autoconf-2.13
mk_add_options MOZ_MAKE_FLAGS="-j8"
export MOZ_JEMALLOC=1
ac_add_options --host=x86_64-pc-linux-gnu
ac_add_options --target=x86_64-pc-linux-gnu
@aleiphoenix
aleiphoenix / App.java
Last active Aug 29, 2015
jackson-databind ObjectMapper demo
View App.java
package net.momoka;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
You can’t perform that action at this time.