Skip to content

Instantly share code, notes, and snippets.

@programus
programus / guess.sh
Last active August 29, 2015 14:04
guess number game in shell script
#!/bin/sh
# 猜数字游戏Shell版程序
function generateGoal()
{ # 生成被猜数字
# 准备一个包含0-9的池
local pool=($(seq 0 9))
for i in $(seq 0 3)
do
@programus
programus / planes.sh
Created August 3, 2014 15:43
Hit plane game in shell script
#!/bin/sh
HIT="X"
BLANK="."
function printBanner()
{
echo "****************************"
echo "* PLANE *"
echo "****************************"
@programus
programus / mine.sh
Last active August 29, 2015 14:04
mine sweeper shell version
#!/bin/bash
MINE="@"
BOOM="X"
BLANK=" "
NEW="."
MARK="M"
OPEN_FLAG=1
MARK_FLAG=2
@programus
programus / from.html
Last active August 29, 2015 14:27
close popup after changed html
<!DOCTYPE html>
<html lang="ja-JP">
<head>
<title>From</title>
<meta charset="UTF-8">
</head>
<body onload="document.getElementById('closed-flg').checked = true;">
<input type="checkbox" id="closed-flg"/>
<a href="#" onclick="window.open('popup.html', 'popup'); document.getElementById('closed-flg').checked = false; ">popup</a>
<a href="#" id="link-to" onclick="window.location.href='to.html' + (document.getElementById('closed-flg') ? '' : '?popup');">To</a>
@programus
programus / _config.yml
Created March 3, 2012 14:52
A side bar html for using weibo in Octopress.
# 其它内容....
default_asides: [asides/recent_posts.html, asides/weibo.html, asides/github.html, asides/[Twitter][].html, asides/googleplus.html]
# 其它内容....
# Weibo
# Please refer to http://weibo.com/tool/weiboshow to get your uid and verifier.
weibo_uid: 1098907490
weibo_verifier: abd54ad9
@programus
programus / sharebutton.js
Created March 4, 2012 11:32
Sina weibo share button source generated by system.
<script type="text/javascript" charset="utf-8">
(function(){
var _w = 86 , _h = 50;
var param = {
url:location.href,
type:'6',
count:'1', /**是否显示分享数,1显示(可选)*/
appkey:'', /**您申请的应用appkey,显示分享来源(可选)*/
title:'', /**分享的文字内容(可选,默认为所在页面的title)*/
pic:'', /**分享图片的路径(可选)*/
@programus
programus / setlocale.sh
Created March 4, 2012 11:37
Set locale environments
set LANG=zh_CN.UTF-8
set LC_ALL=zh_CN.UTF-8
@programus
programus / _config.yml
Created March 4, 2012 11:52
sharing.html with weibo share button and the config file
# Weibo
# Please refer to http://weibo.com/tool/weiboshow to get your uid and verifier.
weibo_uid: 1098907490
weibo_verifier: abd54ad9
weibo_fansline: 0 # How many lines for the fan list
weibo_show: true # Whether you want your weibo content to be shown
weibo_pic: true # Whether you want the pictures in weibo to be shown
weibo_skin: 10 # Please refer to http://weibo.com/tool/weiboshow
weibo_share: true # Whether show the sharing button
@programus
programus / StringMerger.java
Created March 5, 2012 14:22
StringBuffer vs String + String
import java.util.Calendar;
/**
* This is a class to prove that merge strings by StringBuffer is quite quicker than String.
*
* @author Programus
*
*/
public class StringMerger {
/**
@programus
programus / NewOrNot.java
Created March 6, 2012 01:40
String initialization in Java
import java.lang.ref.WeakReference;
/**
* Class to research strings.
* constant string like "AAA" won't be reclaimed while instance created by new will.
* when you new a String by a constant string, there will be two memory field stored the same value.
* so initialize a String by constant String is recommended.
* @author Programus
*/
public class NewOrNot {