Skip to content

Instantly share code, notes, and snippets.

View bindiego's full-sized avatar
🎸
be cool

Bin Wu bindiego

🎸
be cool
View GitHub Profile
@bindiego
bindiego / warning.sh
Last active August 29, 2015 14:08
System notifications
#!/bin/bash
echo 'Shutdown notice: save all your work. THE SYSTEM IS GOING DOWN!!' | wall
@bindiego
bindiego / time_date.sql
Last active August 29, 2015 14:08
MySQL time date operations
SELECT
NOW(),
CURDATE(),
CURTIME(),
DATE_ADD(CURDATE(), INTERVAL -100 DAY),
DATE_ADD(CURDATE(), INTERVAL +100 DAY);
@bindiego
bindiego / git-addremove.sh
Created October 30, 2014 01:46
hg addremove – a useful Mercurial command that adds all untracked files and removes all missing files. This is the Git impl
#!/usr/bin/env bash
# git-addremove
git add .
git ls-files -deleted | xargs git rm
@bindiego
bindiego / checkstyle.xml
Created November 3, 2014 01:48
Maven checkstyle sample
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- This is a checkstyle configuration file. For descriptions of
what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->
<module name="Checker">
@bindiego
bindiego / date_format.sql
Created November 18, 2014 09:14
MySQL String to Date
select date_format(str_to_date('11/20/2014', '%m/%d/%Y'), '%Y-%m-%d');
@bindiego
bindiego / HelloTestSuite.java
Last active August 29, 2015 14:10
Junit usage examples
package org.bindiego.junit.test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ ParameterizedHelloUnitTest.class, HelloUnitTest.class })
public class HelloTestSuite
{
@bindiego
bindiego / latest.sh
Created December 5, 2014 07:58
nodejs package manament
#!/bin/bash
npm outdated | grep -v Package | awk '{print $1}' | xargs -I% npm install %@latest --save
@bindiego
bindiego / tcpdump.sh
Created February 4, 2015 01:02
tcpdump capture packets
#!/bin/bash -ex
# 1. To monitor HTTP traffic including request and response headers and message body:
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
# 2. To monitor HTTP traffic including request and response headers and message body from a particular source:
tcpdump -A -s 0 'src example.com and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
# 3. To monitor HTTP traffic including request and response headers and message body from local host to local host:
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo
@bindiego
bindiego / get_col_by_cell.js
Last active April 3, 2017 17:57
Google Apps Script
/*
* get column number by column name
*/
function testGetColumnNrByName() {
var sheet = SpreadsheetApp.getActiveSheet();
Logger.log(getColumnNrByName_(sheet, '%COLUM_TITLE%'));
}
function getColumnNrByName(sheet, name) {
@bindiego
bindiego / Base64.java
Last active August 29, 2015 14:15
Cross mobile platform encryption and decryption
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Base64编码工具类
*
*/
public class Base64 {
private static final char[] legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();