Skip to content

Instantly share code, notes, and snippets.

@syshack
syshack / localrc
Created November 6, 2013 09:59
localrc
# Sample ``localrc`` for user-configurable variables in ``stack.sh``
# NOTE: Copy this file to the root ``devstack`` directory for it to
# work properly.
# ``localrc`` is a user-maintained setings file that is sourced from ``stackrc``.
# This gives it the ability to override any variables set in ``stackrc``.
# Also, most of the settings in ``stack.sh`` are written to only be set if no
# value has already been set; this lets ``localrc`` effectively override the
# default values.
#!/usr/bin/env python
#coding:utf-8
# Author: --<>
# Purpose:
# Created: 2013/7/3
import sys
import httplib
import json
import urllib
@syshack
syshack / ddns.py
Created April 28, 2013 07:35
使用dnspod做ddns
#!/usr/bin/env python
#coding:utf-8
# Author: syshack --<[email protected]>
# Purpose: yet another pyddns
# Created: 2013/3/19
import socket
import httplib, urllib
try: import json
except: import simplejson as json
@syshack
syshack / cron_sync_time.sh
Created April 10, 2013 08:01
sync time every 5 minutes
#!/bin/bash -e
#Purpose:sync time every 5 minutes
rpm -qi ntpdate >/dev/null 2>&1
if [ $?!=0 ];
then yum install ntpdate >/dev/null 2>&1
if [ $?=0 ];
path=`whereis -b ntpdate|awk -F": " '{print $2}'`
then echo "*/5 * * * * root $path 10.28.167.2 >/dev/null 2>&1" >>/etc/crontab
echo "Sucess!"
fi
@syshack
syshack / libvirt_event_reg.py
Created April 8, 2013 11:47
There is a nice example of event handling shipped with the libvirt source (file is called event-test.py). I'm attaching an example based on that code;
import libvirt
import time
import threading
def callback(conn, dom, event, detail, opaque):
print "EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(), event, detail)
eventLoopThread = None
@syshack
syshack / jbox_upload.java
Created March 29, 2013 03:47
jbox_upload
public static void main(String[] args) throws UnsupportedEncodingException, ClientProtocolException, IOException {
JboxClientLoginService jboxClientLogin = new JboxClientLoginService("***", "***");
JboxMessage loginMsg = jboxClientLogin.login();
if(!loginMsg.isSuccessful()){return;};
JboxClientMainService jboxClientUploadFile = new JboxClientMainService(false);
@syshack
syshack / tailf.c
Created October 13, 2012 03:12
tailf sourcecode
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
#include <sys/stat.h>
#include <signal.h>
//#include "mongo.h"
#define _(s) s
static size_t filesize(const char *filename)
@syshack
syshack / MultipartPostHandler.py
Created September 22, 2012 09:08
多媒体上传handler
#!/usr/bin/python
####
# 02/2006 Will Holcomb <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
@syshack
syshack / BigInteger.js
Created September 22, 2012 06:16
BigInteger
BigInteger.prototype.Clamp = bnpClamp;
function bnpClamp() {
var c = this.s&this.DM;
while(this.t > 0 && this[this.t-1] == c) --this.t;
}
BigInteger.prototype.fromString = bnpFromString;
var this.DB = 28
var dbits = 28;
BigInteger.prototype.DB = dbits;
BigInteger.prototype.DM = ((1<<dbits)-1);
@syshack
syshack / link.c
Created September 19, 2012 08:54
Link with Head