Skip to content

Instantly share code, notes, and snippets.

View jacyzon's full-sized avatar

Yizhang Chen jacyzon

View GitHub Profile
@jacyzon
jacyzon / convertUppercase.c
Created May 1, 2012 14:32
Convert string to uppercase
#include <stdio.h>
#include <stdlib.h>
int main() {
char input[100];
char *chkChar = input;
fgets(input, sizeof(input), stdin);
for(; *chkChar!='\0'; chkChar++)
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
using namespace std;
vector<string> split(const string& src, string separate_character)
{
vector<string> strs;
@jacyzon
jacyzon / exam_2.c
Created November 19, 2012 14:43
8051 exam2
/*
* exam_2.c
*
* Created: 2012/11/16 下午 16:10:10
* Author: Jason YiZhang Chen
*/
#include <reg51.h>
//++++++++++++++++++++++++++++++中斷控制+++++++++++++++++++++++++++++++++//
#define __INT0_SWITCH__ 0 //INT0 中斷開關 0關 1開
@jacyzon
jacyzon / exam_4.c
Created November 19, 2012 18:38
8051 exam4
/*
* exam_4.c
*
* Created: 2012/11/20 下午 01:55:10
* Author: Jason YiZhang Chen
*/
#include <reg51.h>
#define Data P0
@jacyzon
jacyzon / matrix.cpp
Created December 2, 2012 17:14
Matrix operator overloading
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
class matrix {
private:
vector<vector<double>> matrix_double;
public:
@jacyzon
jacyzon / star_sign.sh
Last active December 28, 2015 18:19
Show star sign by entering birth date.
#!/bin/bash
# Show user's star sign by entering birth date.
# 2013/11/19 Jason YiZhang Chen
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
STAR_SIGN=(Capricorn Aquarius Pisces Aries Taurus Gemini Cancer Leo Virgo Libra Scorpio Sagittarius Capricorn)
STAR_SIGN_DATE=(001 019 020 049 050 079 080 109 110 140 141 172 173 203 204 234 235 265 266 296 297 326 327 355 356 365)
@jacyzon
jacyzon / guess_number.sh
Created November 19, 2013 20:37
N-digit guess number game
#!/bin/bash
# Guess number~
# 2013/11/20 Jason YiZhang Chen
ANSWER=1288
LENGTH=$(expr length $ANSWER)
declare -i a
until [ "$a" == $LENGTH ]; do
@jacyzon
jacyzon / stuck_volume
Created December 25, 2013 11:33
Find total stuck volume
#!/usr/bin/perl -w
use HTML::TreeBuilder::XPath;
use WWW::Mechanize;
print "Please enter stock symbol: ";
chomp ($num = <STDIN>);
my $xpath = q{/html/body/div/div/div/div/div/div/table[@id='table2']/tr[3]/td[1]};
my $url = "http://finance.yahoo.com/q?s=$num.TW";
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# First commit
echo "hello" | git hash-object -w --stdin
git update-index --add --cacheinfo 100644 ce013625030ba8dba906f756967f9e9ca394464a hello.txt
git write-tree
git commit-tree aaa96c -m "First commit"
git update-ref refs/heads/master 30b060d9a7b5e93c158642b2b6f64b2b758da40d
# Second commit