Skip to content

Instantly share code, notes, and snippets.

View Stevearzh's full-sized avatar
🐈
Thinking

Steve Zhang Stevearzh

🐈
Thinking
View GitHub Profile
#!/bin/bash
# function Extract for common file formats
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
else
if [ -f "$1" ] ; then
NAME=${1%.*}
#!/bin/env node
var express = require('express');
var fs = require('fs');
var irc = require('irc');
var Dota2Api = require('dota2-api');
//DOTA_API_KEY = 'D3FE4C4AAE0631B3D9C0E3D4E6560D4F';
var da = Dota2Api.create('D3FE4C4AAE0631B3D9C0E3D4E6560D4F');
var heroes = [];
@MaskRay
MaskRay / a.js
Last active March 15, 2016 05:59
新浪AlphaGo对李世乭文字直播desktop notification
文字直播,网页载入后,打开devtools(一般是F12),在Console里输入一行js,即可获取通知。若弹出对话框提示Allow notification?选Allow。
http://bn.sina.cn/video/live/index/tech/alphago?vt=4 人机围棋大战
Notification.requestPermission(function() { $('section').on('DOMSubtreeModified', function() { var n = new Notification('meow', {body: $('section .chat_item p').eq(0).text().trim()}); setTimeout(function() { n.close() }, 10000) }) })
http://lives.sina.cn/live/live?live_mg=sports&wm=&livetype=qipai&stype=&vt=4&match_id=l_142874 李世石VS谷歌AlphaGo 人机大战III
http://lives.sina.cn/live/live?live_mg=sports&wm=&livetype=qipai&stype=&vt=4&match_id=l_142961 李世石VS谷歌AlphaGo 人机大战Ⅳ
http://lives.sina.cn/live/live?live_mg=sports&wm=&livetype=qipai&stype=&vt=4&match_id=l_143040 李世石VS谷歌AlphaGo 人机大战V
var orig_increment_apply_do = window.increment_apply_do; window.increment_apply_do = function(rs) { Notification.requestPermission(function() { var n = new Notification('meow', {body: rs.data[0].content}); setTimeout(function() { n.close() }, 10000) }); return orig_increment_apply_do(rs)
@chantastic
chantastic / on-jsx.markdown
Last active May 30, 2024 13:11
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@xero
xero / irc.md
Last active July 10, 2024 12:09
irc cheat sheet

IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
  • Leaves the specified channel.
@pkuczynski
pkuczynski / parse_yaml.sh
Last active July 9, 2024 04:42
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@jagt
jagt / roguelike-dossier.mkd
Last active July 10, 2020 03:51
roguelike-dossier

Roguelike 到底是啥

讲讲 Roguelike 相关知识

最后更新 2013.5.28

引言

如果你是一位资深游戏玩家,那么最近你肯定在哪里看到过 Roguelike 这个词。Roguelike 这个古老的游戏类型现在又变得很潮流,其中各种要素都在不断的被新游戏借鉴。作为一名就是比你有更多空余时间的高玩,我想在这里介绍一下我了解的 Roguelike 相关的东西。文章很长,但应该会比较有意思。

@mahata
mahata / eshell-path-env.el
Created September 15, 2012 19:47
eshell-path-env and PATH
(defun eshell-mode-hook-func ()
(setq eshell-path-env (concat "/usr/local/bin:" eshell-path-env))
(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
(define-key eshell-mode-map (kbd "M-s") 'other-window-or-split))
(add-hook 'eshell-mode-hook 'eshell-mode-hook-func)
@cdown
cdown / gist:1163649
Last active July 1, 2024 03:35
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in