Skip to content

Instantly share code, notes, and snippets.

@loufq
loufq / ArrayInMogoose.js
Created May 29, 2014 08:45
Match an Array Element
db.inventory.find( { tags: 'fruit' } )
@loufq
loufq / DecryptEncrypt.cs
Created May 12, 2014 07:49
C# aes-256-cbc DecryptEncrypt
/// <summary>
/// aes-256-cbc 解码
/// </summary>
/// <param name="cipherData"></param>
/// <param name="keyString"></param>
/// <param name="ivString"></param>
/// <returns></returns>
public static string Decrypt(string cipherData, string keyString, string ivString)
{
byte[] key = Encoding.UTF8.GetBytes(keyString);
@loufq
loufq / Decrypt.js
Last active August 29, 2015 14:01
nodejs aes-256-cbc Decrypt pair2C#
//require cyrpto module
var crypto=require('crypto');
//key and iv should be same as the one in encrypt.php
var decipher=crypto.createDecipheriv('aes-256-cbc','12345678901234561234567890123456','1234567890123456');
//since we have already added padding while encrypting, we will set autopadding of node js to false.
decipher.setAutoPadding(false);
// copy the output of encrypt.php and paste it below
var crypto = require('crypto');
var cipher = crypto.createCipher('aes256', 'passphrase');
var encrypted = cipher.update("test", 'utf8', 'base64') + cipher.final('base64');
console.log(encrypted);
var decipher = crypto.createDecipher('aes256', 'passphrase');
var plain = decipher.update(encrypted, 'base64', 'utf8') + decipher.final('utf8');
console.log(plain);
@loufq
loufq / UFT82String.cs
Created May 11, 2014 02:21
C# fetch js page convert utf82string
private string Unicode2Chinese(string strUnicode)
{
string[] splitString = new string[1];
splitString[0] = "\\u";
string[] unicodeArray = strUnicode.Split(splitString, StringSplitOptions.RemoveEmptyEntries);
StringBuilder sb = new StringBuilder();
foreach (string item in unicodeArray)
{
byte[] codes = new byte[2];
@loufq
loufq / gm_install.sh
Created May 4, 2014 00:44
nodejs gm install about
//macos
brew update
brew doctor
sudo chown -R $USER /usr/local
brew install ImageMagick
//ubuntu
apt-get install ImageMagick
brew link libtool
//liunx
@loufq
loufq / change_Permission.sh
Created May 4, 2014 00:17
change permission macos
sudo chown -R $USER /usr/local
@loufq
loufq / addLink.sh
Created May 1, 2014 00:06
给终端增加软链接
@loufq
loufq / kill.sh
Last active August 29, 2015 14:00
查杀PID
fuser -n tcp 12004
sudo kill 9358
@loufq
loufq / gist:11342653
Created April 27, 2014 10:45
install xcode plugin sheel
#https://github.com/supermarin/Alcatraz/blob/master/Scripts/install.sh
#!/bin/sh
DOWNLOAD_URI=https://github.com/supermarin/Alcatraz/releases/download/1.0.4/Alcatraz.tar.gz
PLUGINS_DIR="${HOME}/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
mkdir -p "${PLUGINS_DIR}"
curl -L $DOWNLOAD_URI | tar xvz -C "${PLUGINS_DIR}"
echo "Alcatraz successfuly installed!!1!🍻 Please restart your Xcode."