Skip to content

Instantly share code, notes, and snippets.

@idletekz
idletekz / smart-caps-lock.md
Created October 30, 2022 13:36 — forked from tanyuan/smart-caps-lock.md
Smart Caps Lock: Remap Caps Lock to Control AND Escape

Smart Caps Lock: Remap to Control AND Escape (Linux, Mac, Windows)

Caps Lock 變成智慧的 Control 以及 Escape

  • 單獨輕按一下就是 Escape
  • 若按下時同時按著其他鍵,就會是 Control

這應該是 Vim 和 Emacs 的最佳解了!(Emacs? Bash 的快捷鍵就是 Emacs 系列的)

  • Send Escape if you tap Caps Lock alone.
@idletekz
idletekz / 01-curl.go
Created May 15, 2019 14:17 — forked from jmoiron/01-curl.go
io.Reader & io.Writer fun
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func init() {
@idletekz
idletekz / java
Last active July 18, 2018 16:48
unexpected cryptoapi failure generating seed
java.lang.InternalError: Unexpected CryptoAPI failure generating seed
at sun.security.provider.NativeSeedGenerator.getSeedBytes(Unknown Source)
at sun.security.provider.SeedGenerator.generateSeed(Unknown Source)
at sun.security.provider.SecureRandom.engineGenerateSeed(Unknown Source)
oracle provided solution,
The issue seems in the random number generator which is used to seed cryptography .
1.) Add following system property in setDomainEnv.cmd / setDomainEnv.sh in the JAVA_OPTIONS used on server startup -
@idletekz
idletekz / disableSSL.groovy
Created February 21, 2018 03:06 — forked from thomastaylor312/disableSSL.groovy
Disable SSL validation in Groovy
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.HttpsURLConnection
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager
def nullTrustManager = [
checkClientTrusted: { chain, authType -> },
checkServerTrusted: { chain, authType -> },
@idletekz
idletekz / HttpURLConnection
Last active February 16, 2018 21:01
Basic Groovy URL Get/PUT/DELETE
def authString = "username:password".getBytes().encodeBase64().toString()
def conn = addr.toURL().openConnection()
conn.setRequestProperty( "Authorization", "Basic ${authString}" )
## To perform an HTTP PUT:
URL url = new URL("http://www.example.com/resource");
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.setDoOutput(true);
httpCon.setRequestMethod("PUT");
project.configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
println it.name // << the artifact name
println it.file // << the file reference
}
project.configurations.compile.each { println it.name }
subprojects {
task allDeps(type: DependencyReportTask) {}
https://dzone.com/articles/how-analyze-java-thread-dumps
ps -o nlwp <pid>
NLWP stands for Number of LightWeight Processes which is the number of threads
@idletekz
idletekz / gac
Last active January 23, 2018 17:00
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q123550_.htm
https://social.msdn.microsoft.com/Forums/en-US/78f31e59-0250-438b-a9d2-3a4cd6440198/why-cant-we-add-reference-an-assembly-from-gac-created-by-the-user?forum=csharplanguage
The significance of the GAC and shared assemblies exists only at deployment time, not at build time.
Suppose you are developing a solution that contains two executables - for example, a Windows service and a client console application. Both of these executables rely on a library assembly. You ship this product to a customer and decide not to use GAC deployment, but you put these two executables in different locations on the drive. Since the shared library is used by both executables it would need to sit along side both of your executables for each to work, which means you'd have two copies of the assembly.
Now suppose you find a bug in your shared library and you need to issue a hotfix. Now you need to instruct your customer to copy your hotf
scp your_username@remotehost:/remote/dir/foobar.txt /local/dir
https://stackoverflow.com/questions/17831777/write-to-a-windows-network-share-from-unix
try {
String filePath = "myserver/dir";
String fileName = "myFile.txt";
String user = "username";
String password = "password";
// URL: smb://user:passwd@host/share/filname
SmbFileOutputStream out = new SmbFileOutputStream("smb://" + user + ":" + password + "@" + filePath
+ File.separator + fileName);