Skip to content

Instantly share code, notes, and snippets.

View aguegu's full-sized avatar
🎯
Focusing

Weihong Guan aguegu

🎯
Focusing
View GitHub Profile
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);
}
@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;
#!/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 / 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];
@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
#!/bin/bash
tmpfile=/tmp/$$.txt
iconv -f cp936 -t utf-8 $1 > $tmpfile
mv $tmpfile $1
@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
@aguegu
aguegu / eclipse.ini
Created May 23, 2013 07:12
eclipse setting
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807
-product
org.eclipse.epp.package.cpp.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
@aguegu
aguegu / gist:5555194
Last active December 17, 2015 05:08
led switch based on brightness sensor and mic.
#include <Wire.h>
#include <math.h>
int BH1750address = 0x23;
byte buff[2];
int mic_pin = 2;
int switch_pin = 13;
bool is_on = false;
void setup()
#include "Lpd6803.h"
Lpd6803 lpd(12, 13, 1);
// DIN - #12
// SCK - #13
// 1 pcs of lpd6803 in serial
void setup()
{