Skip to content

Instantly share code, notes, and snippets.

View agate's full-sized avatar
🏠
Working from home @ Shanghai

Hao Hong agate

🏠
Working from home @ Shanghai
View GitHub Profile
@agate
agate / 4clojure-answers.md
Last active November 3, 2015 03:48 — forked from SegFaultAX/gist:3607101
4Clojure Answers
// ==UserScript==
// @name 4clojure navigate buttons
// @namespace http://agate.github.com
// @version 0.1
// @description add a prev / next button for problem page
// @author agate
// @match https://www.4clojure.com/problem/*
// @match http://www.4clojure.com/problem/*
// @grant none
// ==/UserScript==
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@agate
agate / zixuan.html
Last active August 29, 2015 14:05 — forked from mavericklou/zixuan.html
<!DOCTYPE html>
<html>
<head>
<title>Stocks</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style type="text/css" media="screen">
.stock {
min-height: 273px;
padding: 0;
@agate
agate / performance_test.rb
Created December 12, 2013 03:06
Curl / Curl with multi / Curl with parallel gem
require 'parallel'
require 'curb'
TEST_URL = 'http://www.baidu.com'
def normal
responses = []
100.times do
easy = Curl::Easy.new(TEST_URL)
easy.perform
@agate
agate / md_readbit.rb
Created September 10, 2013 09:12
Ruby Modbus Test
#!/usr/bin/env ruby
require 'rmodbus'
# PORT = '/dev/ttyACM0'
PORT = '/dev/tty.usbmodemfd1221'
def bytes2holdings(bytes)
bytes.each_slice(2).map { |arr| arr[0] * 256 + arr[1].to_i }
end
@agate
agate / script.sh
Last active December 16, 2015 22:20
DIR is the real directory of this script
SOURCE="${BASH_SOURCE[0]}"
# resolve $SOURCE until the file is no longer a symlink
while [ -h "$SOURCE" ]; do
TARGET="$(readlink "$SOURCE")"
if [[ $SOURCE == /* ]]; then
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
# if $SOURCE was a relative symlink, we need to resolve it relative
# to the path where the symlink file was located
@agate
agate / gist:5020407
Last active December 14, 2015 03:19
curl -s "http://just-ping.com/index.php?vh=$1&c=&s=ping%21" | sed 's/.*\/\/<!\[CDATA\[ //' | sed 's/\/\/\]\]>.*//' | tr ";" "\n" | sed 's/ *xmlreqGET(./http:\/\/just-ping.com\//' | sed "s/',.*//" | grep "^http:\/\/just-ping.com" | while read line; do
curl -s $line
echo
done
@agate
agate / CDB
Created August 3, 2012 13:52
My Afpd Logs
Aug 03 21:51:11.202754 afpd[23137] {auth.c:136} (I:AFPDaemon): uam: "DHX2" available
Aug 03 21:51:11.202996 afpd[23137] {auth.c:136} (I:AFPDaemon): uam: "DHCAST128" available
Aug 03 21:51:11.203179 afpd[23137] {auth.c:136} (I:AFPDaemon): uam: "2-Way Randnum exchange" available
Aug 03 21:51:11.203358 afpd[23137] {auth.c:136} (I:AFPDaemon): uam: "Randnum exchange" available
Aug 03 21:51:11.203535 afpd[23137] {auth.c:136} (I:AFPDaemon): uam: "No User Authent" available
Aug 03 21:51:11.203709 afpd[23137] {auth.c:136} (I:AFPDaemon): uam: "Cleartxt Passwrd" available
Aug 03 21:51:11.233162 afpd[23137] {cnid.c:53} (I:AFPDaemon): Registering CNID module [last]
Aug 03 21:51:11.233416 afpd[23137] {cnid.c:53} (I:AFPDaemon): Registering CNID module [cdb]
Aug 03 21:51:11.233608 afpd[23137] {cnid.c:53} (I:AFPDaemon): Registering CNID module [dbd]
Aug 03 21:51:11.233783 afpd[23137] {cnid.c:53} (I:AFPDaemon): Registering CNID module [tdb]
@agate
agate / script.rb
Created October 13, 2011 03:04
Ruby Script For Testing to_yaml method
require 'yaml'
data = []
File.read("text.txt").lines.each do |line|
data << line
end
puts data.to_yaml