Skip to content

Instantly share code, notes, and snippets.

@elleryq
elleryq / import_vagrant_box_into_vbox.sh
Last active January 6, 2022 17:18
Import Vagrant box into VirtualBox
#!/bin/bash
BOX=$1
if [ -z $BOX ]; then
echo "Need argments."
exit -1
fi
if [ ! -e $BOX ]; then
@elleryq
elleryq / install_kwplayer.sh
Created May 29, 2015 02:23
安裝 kwplayer 用的 script,環境 14.04 https://github.com/LiuLang/kwplayer
#!/bin/bash
DEBS="https://github.com/LiuLang/kwplayer-packages/raw/master/python3-xlib_0.15-1_all.deb
https://github.com/LiuLang/kwplayer-packages/raw/master/python3-keybinder_1.1.2-1_all.deb
https://github.com/LiuLang/kwplayer-packages/raw/master/kwplayer_3.5.2-1_all.deb"
# install dependencies
sudo apt-get install python3-html2text python3-ply
# download and install
@elleryq
elleryq / sc_example.sh
Created May 7, 2015 14:15
SchemaCrawler 的指令用法
#!/bin/bash
./sc.sh -command graph -outputformat png -outputfile=graph.png -database=development.db -password= -user= -infolevel=standard
import os
import datetime
from threading import Thread
from Queue import Queue, Empty
import sys
class mseed2sac():
def __init__(self):
self.start_time = datetime.datetime.now()
@elleryq
elleryq / dump-gsettings.py
Created April 10, 2015 14:23
dump all gsettings. It is same as 'gsettings list-recursively'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""dump gsettings"""
from __future__ import print_function
from subprocess import check_output
def get_schemas():
output = check_output(['gsettings', 'list-schemas'])
schemas = output.split('\n')
#! /bin/bash
#
# backup_redmine.sh
# modified by [email protected]
# Inspiration: https://gist.github.com/gabrielkfr/6432185
#
# Distributed under terms of the MIT license.
# -- VARS
DAY=`date +"%Y%m%d"`
@elleryq
elleryq / insertionsort.cpp
Created March 31, 2015 01:56
Insertion Sort in C++
#include <cstdio>
#include <cstdlib>
void insertionSort(int arr[], int length) {
int i, j, tmp;
for (i = 1; i < length; i++) {
j = i;
while (j > 0 && arr[j - 1] > arr[j]) {
tmp = arr[j];
arr[j] = arr[j - 1];
@elleryq
elleryq / cocos2d_hello.py
Created March 30, 2015 07:07
Hello in cocos2d
from cocos.director import *
from cocos.scene import *
from cocos.layer import *
from cocos.sprite import *
from cocos.text import *
from cocos.actions import *
class TutorialLayer(ColorLayer):
def __init__(self):
super(TutorialLayer, self).__init__(0, 0, 100, 255)
@elleryq
elleryq / node-orm2-one-to-many.js
Created March 25, 2015 07:01
node-orm2 一對多的例子
// db 是用 orm.connect({protocol: "mysql", ....}, function(err, db) {}); 的 callback 所帶出的。
var Category = db.define('category', {
name: { type: 'text', required: true},
}, {}
});
var Food = db.define('food', {
name: { type: 'text', required: true},
price: { type: 'number', required: true},
}, {}
});
@elleryq
elleryq / SocketClient.java
Created March 23, 2015 09:51
Simple Socket example. Java client <-> Python server
package com.example;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class SocketClient {
private String address = "127.0.0.1";// 連線的ip