Skip to content

Instantly share code, notes, and snippets.

@taoalpha
taoalpha / transfer.js
Last active August 29, 2015 14:05
Using nodejs with bower set up your own CDN or resource library.
// Use bower install to install modules and then run the transfer.js to copy all the main files in each modules to root dir
// Mainly use as a quick tool to manage your cdn or resource library.
// directory structure:
// ├───root
// ├───js/
// └───jqeury
// └───jquery.js
// └───jquery.min.js
// └───css/
// └───normalize.css
@taoalpha
taoalpha / mysqlcheck.sh
Last active August 29, 2015 14:05
simple shell script which can restart mysql when your site down.
log=autocheck.log
nflag=`curl --connect-timeout 3 --max-time 2 "http://callmet.zzgary.info/link/" -o $log`
# change the grep text according to your condition.
err=$?
# get the error code.
flag=`cat $log | grep "Database Error" -c`
pflag=`cat $log | grep "502 Bad Gateway" -c`
#echo $err;
#echo $flag;
#echo $pflag;
@taoalpha
taoalpha / fireworks.html
Last active August 29, 2015 14:08
Use canvas show a beautiful fireworks
<!DOCTYPE html>
<html>
<head>
<title>I love U</title>
<meta charset="UTF-8">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="improvedNoise.js"></script>
<script type="text/javascript" src="fizzyText.js"></script>
<script type="text/javascript">
//requestAnimationFrame动画方法的兼容性

Breaking Bad

A tribute to the best fucking series in the world.

Just some CSS and SVG. I created the SVG from the original Logo with Photoshop (path) and Illustrator (SVG).

The making of: http://timpietrusky.com/breaking-bad-logo

# -*- coding=utf-8 -*-
# Update 2-12
# Add spam IP list and ignore the spam IPs
# Add a time delay for ipinfo API - There is a limit usage for the ipinfo api: 1000/day for free, if you want more, you can buy from the website
# You can edit and add your spam ips list file yourself, remember separate your ip address with other information by one space.
import urllib
import json
import os
{
"lastupdate":"2015-10-30 00:50:00",
"puzzles":
{
"2015-10-01":
{
"18:00:00":
{
"title":"In JS, when I create an object with initial value, like {}. How much space the object will have in head ? Will it expand automatically ?",
"desc":"I am working on implementing all frequently used data structures in JS. When I was doing HashTable, I saw there are two variables: capacity and load factor and one function called rehash() in HashTable of Java. But I don't know how to implement this in JS, seems I don't need to do anything about the memory management.",
@taoalpha
taoalpha / testcase4bplustree.java
Last active October 5, 2015 19:30
testcases for b plus tree
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Collections;
import org.junit.Test;
public class Tests {
// add some nodes, see if it comes out right, delete one, see if it's right
@taoalpha
taoalpha / sorting-algorithms.js
Last active September 6, 2016 09:50
Popular sorting algorithms in JS
"use strict"
// Popular sorting algorithm in javascript
// 1. insertionSort
// 2. selectionSort
// 3. bubbleSort
// 4. mergeSort
// 5. quickSort
// 6. bucketSort
// 7. radixSort
@taoalpha
taoalpha / list.js
Created January 23, 2016 04:53
array-base list and linkedlist-base list, double linked list based list, three in one :)
"use strict"
/*
* Data Structure of Javascript
* 1. List
* 2. Stack
* 3. Queue
* 4. LinkedList
* 5. Dictionary
* 6. Hashing
* 7. Set
@taoalpha
taoalpha / my_configs.vim
Last active April 27, 2016 00:26
customized config for vim
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" show ruler and number
set ruler
set nu
" modifiable
set modifiable