Skip to content

Instantly share code, notes, and snippets.

View aguegu's full-sized avatar
🎯
Focusing

Weihong Guan aguegu

🎯
Focusing
View GitHub Profile
//============================================================================
// Name : socket_demo.cpp
// Author : aGuegu
// Version :
// Copyright : GPL v2.0
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <stdio.h>
#include <stdlib.h>
@aguegu
aguegu / ds18b20.sh
Created November 5, 2013 16:06
get temperature from ds18b20 on RPi in Bash
#!/bin/bash
modprobe w1-gpio
modprobe w1-therm
if [ -d /sys/bus/w1/devices ]; then
id=$(ls /sys/bus/w1/devices/ | head -n 1);
temperature=$(tail -n 1 /sys/bus/w1/devices/$id/driver/$id/w1_slave | grep -o "[-0-9]*$")
echo "scale=3;" $temperature "/ 1000.0" | bc
@aguegu
aguegu / centos.sh
Created November 11, 2013 00:18
startup my headless centos virtualbox.
#!/bin/bash
nohup VBoxHeadless -s centOS
@aguegu
aguegu / oracle.sh
Created November 11, 2013 02:04
/etc/init.d/oracle, init script for oracle, based on http://www.server-world.info/en/note?os=CentOS_6&p=oracle11g&f=5
#!/bin/bash
# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle
. /etc/rc.d/init.d/functions
import time
from threading import *
import wx
EVENT_TYPE_ID = wx.NewId()
class WorkerThread(Thread):
def __init__(self, notify_window):
Thread.__init__(self)
self._notify_window = notify_window
@aguegu
aguegu / chart_sample.html
Created April 30, 2014 09:53
canvasjs demo
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
window.onload = function () {
var temperature = '[{"y": 22.125, "x": 1398788844000}, {"y": 21.875, "x": 1398789023000}, {"y": 21.9375, "x": 1398789056000}, {"y": 21.875, "x": 1398789067000}, {"y": 21.9375, "x": 1398789089000}, {"y": 21.9375, "x": 1398789213000}, {"y": 22.0, "x": 1398789224000}, {"y": 22.0625, "x": 1398789365000}, {"y": 22.0, "x": 1398789376000}, {"y": 22.0625, "x": 1398789431000}, {"y": 22.0, "x": 1398789442000}, {"y": 22.0625, "x": 1398789583000}, {"y": 22.0, "x": 1398789594000}, {"y": 21.9375, "x": 1398789605000}, {"y": 21.875, "x": 1398789616000}, {"y": 21.8125, "x": 1398789638000}, {"y": 21.75, "x": 1398789649000}, {"y": 21.6875, "x": 1398789660000}, {"y": 21.625, "x": 1398789682000}, {"y": 21.5625, "x": 1398789736000}, {"y": 21.625, "x": 1398789758000}, {"y": 21.5625, "x": 1398789780000}, {"y": 21.625, "x": 1398789791000}, {"y": 21.5625, "x": 1398789802000}, {"y": 21.5, "x": 1398789824000}, {"y": 21.4375, "x": 139878
@aguegu
aguegu / sqlite_unicode.py
Created June 23, 2014 06:42
why python sqlite3 convert str to number by default?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sqlite3
import sys
con = None
try:
con = sqlite3.connect(':memory:')
in progress (#1046): re-focus this page on deployment of python on linux, esp. suse; perhaps move to PythonDeployment?. for developer set-up, see WritingQualityCode
virtualenv is a tool to create isolated Python environments:
The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo , but another application requires version 2. How can you use both these applications? Or what if you want to install an application and leave it be ? If an application works, any change in its libraries or the versions of those libraries can break the application. ... In all these cases, virtualenv can help you.
Machine Set-Up
If your development machine runs ubuntu (or debian) linux, install with apt-get:
@aguegu
aguegu / .editorconfig
Last active August 29, 2015 14:03
BendixCrawler
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@aguegu
aguegu / in_venv.sh
Last active August 29, 2015 14:05 — forked from parente/runinenv.sh
#!/bin/bash
. venv/bin/activate
echo "Executing $@ in venv"
exec "$@"
deactivate