Skip to content

Instantly share code, notes, and snippets.

View consatan's full-sized avatar

Chopin Ngo consatan

  • Amoy, Fujian, China
View GitHub Profile
@consatan
consatan / curl_imap_query_commands.md
Last active April 18, 2024 22:08 — forked from akpoff/curl_imap_query_commands.md
curl commands to query imap servers

curl commands to query imap servers

Based on https://busylog.net/telnet-imap-commands-note/

curl options

  • -k -- don't verify certificate (optional)
  • -n -- use .netrc for username and password (optional)
  • -X -- request to send to server
@consatan
consatan / only_jd.js
Created April 17, 2020 11:13
只看京东自营产品
// ==UserScript==
// @name 京东只看自营
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 只看京东自营产品
// @author Chopin Ngo <consatan@gmail.com>
// @match https://list.jd.com/list.html*
// @grant none
// ==/UserScript==
@consatan
consatan / random_password.sh
Last active March 19, 2020 07:08
Generate random password
# Usage: rpasswd [LENGTH] [CHARS]
# Generate random password
#
# CHARS
# 'a': Alphabet, a-z A-Z
# 'n': Numeric, 0-9
# 'c': Character, print characters in ascii code
#
rpasswd() {
len=12
$.fn.select2.amd.define('select2/data/extended-ajax',['./ajax', './tags', '../utils', 'module', 'jquery'], function(AjaxAdapter, Tags, Utils, module, $) {
function ExtendedAjaxAdapter ($element,options) {
//we need explicitly process minimumInputLength value
//to decide should we use AjaxAdapter or return defaultResults,
//so it is impossible to use MinimumLength decorator here
this.minimumInputLength = options.get('minimumInputLength');
this.defaultResults = options.get('defaultResults');
ExtendedAjaxAdapter.__super__.constructor.call(this,$element,options);
}
@consatan
consatan / .cvimrc
Last active May 3, 2018 17:00
cvimrc
let searchalias g = "google"
let barposition = "bottom"
let scrollstep = 70
let searchengine php = ["http://php.net", "http://php.net/manual-lookup.php?scope=quickref&pattern=%s"]
let searchengine fy = "https://translate.google.com/#zh-CN/en/"
let completionengines = ["google", "php", "fy"]
unmap E R K J d x b B u e D f F
map h previousTab
map l nextTab
map d closeTab
@consatan
consatan / keybase.md
Created August 4, 2016 09:29
keybase

Keybase proof

I hereby claim:

  • I am consatan on github.
  • I am consatan (https://keybase.io/consatan) on keybase.
  • I have a public key whose fingerprint is A302 1325 1326 8B2C 778F 32E1 F894 C16B 91D6 C019

To claim this, I am signing this object:

@consatan
consatan / gist:009f505c436d58fd48a7c2ea414b0996
Created August 3, 2016 05:19 — forked from samsamm777/gist:7230159
PHP set private property value using reflection. This allows you to set a private property value from outside the object, great for PHPUnit testing.
<?php
$a = new A();
$reflection = new \ReflectionClass($a);
$property = $reflection->getProperty('privateProperty');
$property->setAccessible(true);
$property->setValue($a, 'new-value');
echo $a->getPrivateProperty();
//outputs:
<?php
class Item
{
private $cost = 100;
public function getTotal($discount = 7) {
return $this->cost *(100+$discount)/100;
}
}
@consatan
consatan / redis_push_1m.php
Created July 5, 2016 14:03
Redis 插入100万数据到 List
<?php
$time = microtime(true);
ini_set('memory_limit', -1);
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$arr = range(1, 1000000);
array_unshift($arr, 'test');
@consatan
consatan / insertPrefixMaxID.sql
Created November 30, 2015 05:05
通过子查询更新或插入固定前缀的递增字段
# 如果前缀要使用年份加月份,第7行需要增加判断条件
UPDATE `table` SET `no`=
(
SELECT `no`
FROM (
SELECT IF(
(SELECT 1 FROM `table` WHERE `no` IS NOT NULL AND `no` <> "") IS NULL,
"NO1000",
(
SELECT CONCAT("NO", SUBSTRING(`no`, 3) + 1)