Skip to content

Instantly share code, notes, and snippets.

View aguegu's full-sized avatar
🎯
Focusing

Weihong Guan aguegu

🎯
Focusing
View GitHub Profile
@aguegu
aguegu / eclipse-sourcery.sh
Created May 23, 2013 07:22
import sourcery toolchain to $PATH for eclipse
#!/bin/bash
export PATH=/home/agu/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin:$PATH
/home/agu/tools/eclipse-cdt/eclipse
#!/bin/bash
tmpfile=/tmp/$$.txt
iconv -f cp936 -t utf-8 $1 > $tmpfile
mv $tmpfile $1
@aguegu
aguegu / octocats.sh
Last active December 23, 2015 11:07
A bash script to download all Octocats logos from http://octodex.github.com/
#!/bin/zsh
curl -s "https://octodex.github.com/" | grep "<img.*data-src" | grep -o "/image[^\"]*" | while read line; do
wget 'https://octodex.github.com'$line
done
@aguegu
aguegu / max.cpp
Created September 28, 2013 01:50
#include <cstdio>
#include <cstdlib>
int compare (const void * a, const void * b) {
return ( *(int*)b - *(int*)a );
}
void max(int *buff, int length, int * p1, int *p2) {
qsort(buff, length, sizeof(int), compare);
*p1 = buff[0];
#!/usr/bin/env python
import sys
import os
import cx_Oracle
reload(sys)
sys.setdefaultencoding('utf-8')
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.AL32UTF8'
@aguegu
aguegu / line_curve.java
Created September 30, 2013 07:24
replace sin curve with sections of lines
package demo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import processing.core.PApplet;
import processing.core.PVector;
import demo.DmPoint;
const int pingTrig = 9; // transmission pin
const int pingEcho = 8; //receiving pin
void setup() {
// initialize serial communication:
Serial.begin(9600);
pinMode(pingTrig, OUTPUT);
pinMode(pingEcho, INPUT);
}
//============================================================================
// 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