Skip to content

Instantly share code, notes, and snippets.

@yingrong
yingrong / customer.el
Last active October 21, 2021 14:34
use advice and setq to change defvar
;; change default defvar
;; use advice and setq to change defvar in function.
(defun my-use-zsh-as-default-shell ()
(setq my-term-program "/bin/zsh"))
(advice-add 'my-switch-to-shell :before #'my-use-zsh-as-default-shell)
brew tap-new uname/old-openssl
brew extract --version=1.0.2t openssl uname/old-openssl
brew install openssl@1.0.2t
cd /usr/local/opt/
ln -snf ../Cellar/openssl@1.0.2t/1.0.2t openssl
task installGitHooks(type: Copy) {
from 'pre-push'
into '.git/hooks'
fileMode 0744
}
defaultTasks 'installGitHooks'
@yingrong
yingrong / get-k8s-token
Created January 2, 2020 06:20
get k8s token
kubectl -n kube-system describe secret $(
kubectl -n kube-system get secret | \
awk '/^deployment-controller-token-/{print $1}'
) | \
awk '$1=="token:"{print $2}'
@yingrong
yingrong / docker-compose.yml
Created May 7, 2019 01:22
dev env include redis mysql and mongo
version: '3.1'
services:
redis:
image: redis
command: redis-server --requirepass yourpassword
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
@yingrong
yingrong / build.gradle
Created April 30, 2019 07:04
intergarte lombok aspectj spring
buildscript {
ext {
springBootVersion = '2.1.4.RELEASE'
aspectjVersion = '1.8.13'
}
repositories {
mavenLocal()
maven {
url "https://s3-eu-west-1.amazonaws.com/gskillz-maven-repo"
}
@yingrong
yingrong / OptionInScala.scala
Last active September 27, 2018 02:22
诡异的 Option in scala
println(Some(null) == None) // false
println(Option(null) == None) // true
println(Option(null).exists(_.toLowerCase == "true")) // compile error
val m = Map.empty + ("" -> "") + ("1" -> null)
println(m.get("1").exists(_.toLowerCase == "true")) // java.lang.NullPointerException
///////
println(Option("true").exists(a => a == "true" || a == "TRUE")) // true
println(Option("false").exists(a => a == "true" || a == "TRUE")) // false
println(Option(null).exists(a => a == "true" || a == "TRUE")) // false
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ggggg</groupId>
<artifactId>aaaaa</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>nnn</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spark.version>1.6.3</spark.version>
@yingrong
yingrong / Resource.java
Last active August 30, 2017 09:41
java 读取 jar 包内的文件
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 获取配置文件
* Created by yingrong on 2017/7/27.
*/
public class Resource {
@yingrong
yingrong / piplineAggScript.es
Last active June 15, 2017 11:51
elasticSearch 聚合 aggs , Pipeline aggregations, https://elasticsearch.cn/article/36
{
"size": 0,
"aggs": {
"dp": {
"date_histogram": {
"field": "@timestamp",
"interval": "hour",
"format": "yyyy-MM-dd HH"
},
"aggs": {