Skip to content

Instantly share code, notes, and snippets.

View bloatfan's full-sized avatar
🤒
Out sick

bloatfan bloatfan

🤒
Out sick
View GitHub Profile
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@bloatfan
bloatfan / utf8.php
Created May 9, 2017 13:57
gbk utf8 check
<?php
// refer: http://hustnaive.github.io/php/2015/08/21/php-detect-encoding.html
/**
* 检测字符串编码(注意:存在误判的可能性,降低误判的几率的唯一方式是给出尽可能多的样本$line)
* 检测原理:对给定的字符串的每一个字节进行判断,如果误差与gb18030在指定误差内,则判定为gb18030;与utf-8在指定误差范围内,则判定为utf-8;否则判定为utf-16
* @param string $line
* @return string 中文字符集,返回gb18030(兼容gbk,gb2312,ascii);西文字符集,返回utf-8(兼容ascii);其他,返回utf-16(双字节unicode)
* @author fangl
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
#!/bin/sh
cd ~
sudo yum install -y epel-release
sudo yum install -y man
sudo echo '[nginx]
name=nginx repo
@bloatfan
bloatfan / Netease.js
Created June 12, 2017 08:52
Netease.js
const http = require('http');
const pack = require('./pack.js');
const crypto = require('crypto');
const querystring = require('querystring');
// 私有方法
const neteaseAESECB = Symbol('neteaseAESECB');
const getHttpOption = Symbol('getHttpOption');
const makeRequest = Symbol('makeRequest');
const onResponse = Symbol('onResponse');
@bloatfan
bloatfan / pack.js
Created June 12, 2017 08:52
pack.js
module.exports = function pack (format) {
// discuss at: http://locutus.io/php/pack/
// original by: Tim de Koning (http://www.kingsquare.nl)
// parts by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// bugfixed by: Tim de Koning (http://www.kingsquare.nl)
// note 1: Float encoding by: Jonas Raoni Soares Silva
// note 1: Home: http://www.kingsquare.nl/blog/12-12-2009/13507444
// note 1: Feedback: [email protected]
// note 1: "machine dependent byte order and size" aren't
// note 1: applicable for JavaScript; pack works as on a 32bit,
#!/bin/sh
standard="OSR0"
phpcsVersion="2.9.1"
function phpcsEvnCheck()
{
# check phpcs exist
which phpcs > /dev/null 2>&1
@bloatfan
bloatfan / parse-options.sh
Created July 13, 2017 03:35 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 1.8
version = '1.0'
mainClassName='com.hello.Application'
jar {
manifest {