Skip to content

Instantly share code, notes, and snippets.

View rockstar2046's full-sized avatar

R rockstar2046

  • 天朝
View GitHub Profile
@rockstar2046
rockstar2046 / sqrcode.js
Created March 30, 2014 18:59
Show a qrcode image on browser lower right | left corner
/**
* @fileOverview Show a qrcode image on browser lower right | left corner
* @author ra <ra@rockagen.com>
* @version 0.0.1
* @see {@link http://usejsdoc.org|jsdoc}
*
*
* @example
*
* qrsource:{
@rockstar2046
rockstar2046 / calc.js
Created April 1, 2014 12:52
High-precision calculation for javascript,You can call add,sub,mul,div to calculate you variables.
/**
* @fileOverview Javascript high precision calculate
* @author ra <ra@rockagen.com>
* @version 0.1
* @see {@link http://usejsdoc.org|jsdoc}
* @example
*
* 0.05 + 0.01 //0.060000000000000005
* 1.0 - 0.42 //0.5800000000000001
* 4.015 * 100 //401.49999999999994
@rockstar2046
rockstar2046 / hexdump.js
Created April 1, 2014 17:01
hexdump tool, like linux "xxd" command.
/**
* @fileOverview Hexdump util
* @author ra <ra@rockagen.com>
* @version 0.0.1
* @see {@link http://usejsdoc.org|jsdoc}
* @example
* var stuff="30313233343536";// "0123456"
* var retval=hexdump.pretty(hexdump.decode(stuff));
* console.log(retval);
*
@rockstar2046
rockstar2046 / comm.js
Last active August 29, 2015 13:58
Some common functions for javascript
/**
*@fileOverview JavaScript utils
*@author ra <ra@rockagen.com>
*@version 0.0.1
*@see {@link http://usejsdoc.org|jsdoc}
*@example
*
* var currency=comm.formatCurrency(123456);
* //output
* '123, 456.00'
<html>
<head>
<title>The page is temporarily unavailable</title>
<style>
body { font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body bgcolor="white" text="black">
<table width="100%" height="100%">
<tr>
@rockstar2046
rockstar2046 / cdrun.js
Created September 18, 2014 05:37
count down
var _cdrun = {
seconds:120,
ok:true,
ui: function(){
if(_cdrun.seconds>=0){
__smsId.innerHTML="("+_cdrun.seconds+")秒后重新发送";
__smsId.style.color="gray";
__mobileId.disabled=true;
_cdrun.seconds--;
_cdrun.ok=false;
@rockstar2046
rockstar2046 / unicorn.sh
Last active August 29, 2015 14:06
unicorn service script
#! /usr/bin/env bash
#
# Control unicorn server
#
# NOTICE:
# Environment -> production
#
# Author: Tony
#
@rockstar2046
rockstar2046 / unicorn.rb
Last active May 26, 2016 10:35
unicorn config file
# Set the working application directory
work_path=ENV["WORK_PATH"]
# App path (current dir)
app_path=`pwd`.gsub "\n", ""
puts "work_path: #{work_path}"
puts "app_path: #{app_path}"
# working_directory "/path/to/your/app"
working_directory app_path
# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
@rockstar2046
rockstar2046 / pnt.js
Created September 26, 2014 11:20
Assert phone number type (for china)
/**
* Return phone number type
* <p>For china:</p>
* <ul>
* <li>0 unknow</li>
* <li>1 china mobile (cellphone)</li>
* <li>2 china unicom (cellphone)</li>
* <li>3 china net (cellphone)</li>
* <li>4 china net (telphone)</li>
@rockstar2046
rockstar2046 / rename.sh
Created September 27, 2014 09:41
Rename current files
#! /usr/bin/env bash
arg1=$1
arg2=$2
arg3=$3
FILTER=${arg1:-*}
PREFIX=${arg2:-n}
SUFFIX=${arg3:-.n}