Skip to content

Instantly share code, notes, and snippets.

hezhao

Block or report user

Report or block hezhao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hezhao
hezhao / twitter_pin_auth.py
Created Feb 12, 2013
Twitter PIN-based authorization using tweepy
View twitter_pin_auth.py
### See PIN-based authorization for details at
### https://dev.twitter.com/docs/auth/pin-based-authorization
import tweepy
consumer_key=<your_app_consumer_key>
consumer_secret=<your_app_consumer_secret>
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@hezhao
hezhao / xbmc_get_title.py
Last active Dec 12, 2015
XBMC get current music info (artist and song title)
View xbmc_get_title.py
# WARNING: here getArtist() implicitly converts unicode into str...
self.tag = player.getMusicInfoTag()
artist = self.tag.getArtist()
title = self.tag.getTitle()
# skip weird cases when music stop (title == '') or is streaming (title == 'Streaming...')
if not title or title.lower() == 'streaming...':
print 'title = ' + title
return
@hezhao
hezhao / hangout.applescript
Last active Dec 14, 2015
Open Safari, start Google Hangout and stream it live to youtube. It also outputs and returns the iframe embed HTML containing the youtube link.
View hangout.applescript
tell application "Safari" to activate
tell application "Safari"
tell window 1
set current tab to (make new tab with properties {URL:"http://hangout.google.com"})
end tell
delay 5
tell application "System Events"
-- navigate to "Name this hangout"
repeat 10 times
keystroke tab
@hezhao
hezhao / switch_spray.ino
Created Apr 17, 2013
toggle servo movement (CCW and then CW) with momentary push button switch.
View switch_spray.ino
#include <Servo.h>
Servo myservo;
int servoPin = 9;
int switchPin = 2;
void setup()
{
myservo.attach(servoPin);
@hezhao
hezhao / supervisor.conf
Last active Sep 26, 2019
Example supervisor config file /etc/supervisor/conf.d/myapp.conf
View supervisor.conf
[program:myapp]
autostart = true
autorestart = true
command = python /home/pi/myapp.py
environment=SECRET_ID="secret_id",SECRET_KEY="secret_key_avoiding_%_chars"
stdout_logfile = /home/pi/stdout.log
stderr_logfile = /home/pi/stderr.log
startretries = 3
user = pi
View twcf.ino
// See http://bildr.org/2011/02/74hc595/
int SER_Pin = 11; //pin 14 (Data) on the 75HC595
int RCLK_Pin = 9; //pin 12 (Latch) on the 75HC595
int SRCLK_Pin = 8; //pin 11 (Clock) on the 75HC595
//How many of the shift registers - change this
#define number_of_74hc595s 8
@hezhao
hezhao / draw.m
Last active Dec 21, 2015
Draw random dots within black filled circle
View draw.m
%
% Draw random dots within black filled circle
% Dots number from 89 to 299
%
for n = 89:299
% Draw filled circle
f = figure;
filledCircle([0,0], 1,1000, 'k');
@hezhao
hezhao / oscillator.m
Last active Dec 22, 2015
Wave form function generator in Matlab, it also plays the wave sound.
View oscillator.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Example:
%%%
%%% Create a 3000Hz triangel wave data for 3 seconds, and
%%% play the wave data at 44100Hz (default) sample rate, also
%%% save to .wav file.
%%%
%%%
%%% wave = OSCILLATOR('Triangle', 3, 3000);
%%% soundsc(wave, 44100);
View latch.ino
void loop()
{
if ( connected )
{
int packetSize = Udp.parsePacket();
if ( packetSize != 0 ) {
Udp.read( data, numPins );
Serial.println( "Data received" );
@hezhao
hezhao / lcd_i2c.ino
Created Mar 24, 2014
YwRobot LCM1602 IIC V1 20x4 LCD Display with PCF8574T
View lcd_i2c.ino
// See http://forum.arduino.cc/index.php?topic=158312.0
// NewLiquidCrystal library
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // Define I2C Address for the PCF8574T
You can’t perform that action at this time.