Skip to content

Instantly share code, notes, and snippets.

from cgroups import Cgroup
from cgroups.user import create_user_cgroups
import os
import subprocess
try:
# setup cgroup directory for this user
user = os.getlogin()
create_user_cgroups(user)
@thrbowl
thrbowl / autolog.py
Created August 1, 2018 10:38 — forked from brendano/autolog.py
python decorators to log all method calls, show call graphs in realtime too
# Written by Brendan O'Connor, brenocon@gmail.com, www.anyall.org
# * Originally written Aug. 2005
# * Posted to gist.github.com/16173 on Oct. 2008
# Copyright (c) 2003-2006 Open Source Applications Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@thrbowl
thrbowl / Mac SSH Autocomplete
Created September 21, 2017 02:30 — forked from aliang/Mac SSH Autocomplete
Add auto complete to your ssh, put into your .bash_profile
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
@thrbowl
thrbowl / foo.log
Created July 24, 2016 12:20 — forked from ibeex/foo.log
Flask logging example
A warning occurred (42 apples)
An error occurred
<?php
function CallAPI($method, $url, $username, $password, $data = false)
{
$curl = curl_init();
switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
var timer;
timer = setInterval(function () {
console.info("check exchange-submit-btn");
var exchangeBtn = document.getElementById("exchange-submit-btn");
if (exchangeBtn) {
clearInterval(timer);
exchangeBtn.click();
timer = setInterval(function () {
console.info("check ik-authcode-input");
var authcodeInput = document.getElementById("ik-authcode-input");
@thrbowl
thrbowl / gist:b7ce2633c5fc8546749c
Created August 29, 2014 06:43
Nginx config for rewirte /a/b.png?width=100&height=100 to /a/100x100/b.png
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@thrbowl
thrbowl / gist:03777b59fe25871759ec
Created July 29, 2014 06:40
12306.cn have no sound tip
$(document).ajaxSend(function(evt, request, settings) {
if (settings.url.indexOf("autoSubmitOrderRequest") >= 0) {
document.title = '有票了';
}
});
@thrbowl
thrbowl / merged.py
Created April 15, 2014 23:21
Diff the modify between dict and update the third
# -*- coding: utf-8 -*-
import copy
from pprint import pprint
old = {'hw':
{
'b1': 'a'
},
't1': 1,
'all boards':
@thrbowl
thrbowl / gist:5956250
Created July 9, 2013 10:13
A simple site maintenance page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 40px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>