Skip to content

Instantly share code, notes, and snippets.

@xmeng1
xmeng1 / wsl2-network.ps1
Created July 14, 2019 06:50
WSL2 Port forwarding port to linux
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@xmeng1
xmeng1 / multiple_ssh_setting.md
Created September 16, 2019 19:55 — 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 "your_email@youremail.com"
@xmeng1
xmeng1 / increment-pom-versions.sh
Created November 21, 2017 11:27 — forked from pdunnavant/increment-pom-versions.sh
Script that uses the versions-maven-plugin to automatically increment the build number in the version of a project. This is intended to be used in a continuous delivery environment.
#!/bin/bash
#################################################################################
# WARNING: DO NOT JUST RUN THIS SCRIPT BLINDLY. MAKE SURE YOU UNDERSTAND WHAT IT
# IS DOING. IT *WILL* TRY TO COMMIT CHANGES. IT WILL ALSO TRY TO EAT YOUR
# CHILDREN. IT MAY CAUSE THE SUN TO GO SUPERNOVA. I CLAIM NO RESPONSIBILITY FOR
# WHATEVER HAPPENS AFTER YOU RUN THIS. NOW, CARRY ON. :-)
#
# This script, run from the root of a Maven single or multi-module project, will
# update the pom files to increment the build number on the version.
@xmeng1
xmeng1 / docker-clear.bat
Created June 3, 2018 17:05 — forked from daredude/docker-clear.bat
delete all docker container and images on windows
@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
FOR /f "tokens=*" %%i IN ('docker images --format "{{.ID}}"') DO docker rmi %%i
@xmeng1
xmeng1 / parser.py
Created September 18, 2019 17:01
parser.py
from __future__ import print_function
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--color', help='The name of the color')
parser.add_argument('--verbose', help='Print more data',
action='store_true')
parser.add_argument('--cuda', '-c', default=True, action='store_false')
@xmeng1
xmeng1 / workers.sql
Created August 14, 2019 10:43 — forked from kenjipm/workers.sql
The following data definition defines an organization's employee hierarchy. An employee is a manager if any other employee has their managerId set to the first employees id. An employee who is a manager may or may not also have a manager. TABLE employees id INTEGER NOT NULL PRIMARY KEY managerId INTEGER REFERENCES employees(id) name VARCHAR(30) …
SELECT name FROM employees
WHERE id NOT IN (SELECT managerId FROM employees WHERE managerId IS NOT NULL);
@xmeng1
xmeng1 / IntelliJ_IDEA__Perf_Tuning.txt
Created July 30, 2019 10:24 — forked from P7h/IntelliJ_IDEA__Perf_Tuning.txt
Performance tuning parameters for IntelliJ IDEA. Add these params in idea64.exe.vmoptions or idea.exe.vmoptions file in IntelliJ IDEA. If you are using JDK 8.x, please knock off PermSize and MaxPermSize parameters from the tuning configuration.
-server
-Xms2048m
-Xmx2048m
-XX:NewSize=512m
-XX:MaxNewSize=512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1
@xmeng1
xmeng1 / kraken.fish
Created July 29, 2019 10:04 — forked from BBlackwo/kraken.fish
Open GitKraken from the terminal
## Forked from https://gist.github.com/dersam/0ec781e8fe552521945671870344147b
## Also received help from https://twitter.com/gitkraken/status/691675309725368321
## Open GitKraken using the current repo directory.
## This code is for fish shell. The same thing can be done in bash
## by creating an alias with the command below.
## `1>/dev/null` directs logs from the terminal
## `&` allows use of the same terminal instance to do other things
@xmeng1
xmeng1 / akkaWebSocket.scala
Created June 22, 2019 06:00
Akka stream and Akka Http WebSocket Example 1
object ChatApp extends App {
implicit val system = ActorSystem("chat")
implicit val executor: ExecutionContextExecutor = system.dispatcher
implicit val materializer = ActorMaterializer()
val route = get {
pathEndOrSingleSlash {
handleWebSocketMessages(websocketFlow)
}
@xmeng1
xmeng1 / TypeClassDemo.scala
Created June 18, 2019 05:02
Cats Type Class Demo
// Define a very simple JSON AST
sealed trait Json
final case class JsObject(get: Map[String, Json]) extends Json
final case class JsString(get: String) extends Json
final case class JsNumber(get: Double) extends Json
case object JsNull extends Json
////////////////// Step 1
// The "serialize to JSON" behaviour is encoded in this trait
trait JsonWriter[A] {