Skip to content

Instantly share code, notes, and snippets.

View imchao9's full-sized avatar
🎯
Focusing

JunChao imchao9

🎯
Focusing
View GitHub Profile
@imchao9
imchao9 / gist:3ebfac1bdfe4c72709763e9e061def7c
Created February 24, 2020 08:58
gitlab clone all projects
#!/usr/bin/env bash
# should install jq first, for mac:brew install jq
# Documentation
# https://docs.gitlab.com/ce/api/projects.html#list-projects
NAMESPACE="<Your NAMESPACE Name>"
BASE_PATH="https://xxx.xxx.cn"
PROJECT_SEARCH_PARAM=""
import java.security.InvalidKeyException
import java.security.NoSuchAlgorithmException
import java.security.SignatureException
import java.util.*
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
object HmacSha1Signature {
private val HMAC_SHA1_ALGORITHM = "HmacSHA1"
@imchao9
imchao9 / ImageSensor.java
Last active August 18, 2019 08:59
七牛 ImageCensor 内容审查API Java调用
package me.lj.qiniu.ai;
import com.qiniu.common.QiniuException;
import com.qiniu.common.Zone;
import com.qiniu.http.Client;
import com.qiniu.http.Response;
import com.qiniu.storage.Configuration;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;
import me.lj.qiniu.config.Config;
@imchao9
imchao9 / yml
Created March 18, 2019 11:38
Elastic APM docker-compose file
version: '3'
services:
elasticsearch:
image: elasticsearch:6.6.1
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
@imchao9
imchao9 / shell
Created October 31, 2017 09:30
use array for loop in shell
#! /bin/bash
jobs=(12 13 14 15 16 17 18 19 20)
for job in ${jobs[@]}
do
echo "$job";
done;
@imchao9
imchao9 / difference.js
Created September 29, 2017 02:14 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@imchao9
imchao9 / javascript
Created September 28, 2017 03:04
import lodash.js in the browser
function import_lodash() {
var jq = document.createElement('script');
jq.src = "https://lodash.com/vendor/cdn.jsdelivr.net/lodash/4.17.4/lodash.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
}
import_lodash();
@imchao9
imchao9 / multiple_ssh_setting.md
Created July 5, 2017 04:05 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@imchao9
imchao9 / shell,mac
Last active April 19, 2017 04:05
find the similar file name and delete them
#! /bin/bash
find . -name "*.js" -type f -exec sh -c 'for i do declare match_file=$i; if [ -f $i.map ]; then rm -rf $match_file.map; rm -rf $match_file; echo $match_file.map;fi;done' sh {} +
@imchao9
imchao9 / gist:9182a73d2d335cc27f391314ee6ed04a
Created April 18, 2017 06:38
get all urls in a csv file
npm install -g get-urls-cli
get-urls sqlResult_1183013.csv >> urls.txt
awk {'print $1'} new_urls.txt | xargs wget -P bcms