Skip to content

Instantly share code, notes, and snippets.

@sh1nj1
sh1nj1 / pid-by-port.sh
Created July 19, 2023 02:22
Get PID by listening port number in Mac OS X
#!/bin/sh
lsof -nP -iTCP -sTCP:LISTEN | grep $1
@sh1nj1
sh1nj1 / git-push-all-remote-repositories.md
Last active April 14, 2023 03:29
git push all remote repositories
git remote add all REMOTE-URL-1
git remote set-url --add --push all REMOTE-URL-1
git remote set-url --add --push all REMOTE-URL-2
git push all BRANCH
@sh1nj1
sh1nj1 / gist:7066f0212817d45619bf70ee19cf9749
Created February 18, 2022 00:47
read-redisson-hash-by-redis-cli
redis-cli eval "return redis.call('hset', KEYS[1], KEYS[2], struct.pack('dLc0', 0.0, string.len(ARGV[1]), ARGV[1]))" 2 "test-map" "key1" '{"value":"hello world"}'
redis-cli eval "local value = redis.call('hget', KEYS[1], KEYS[2]); local t, val = struct.unpack('dLc0', value); return val;" 2 "test-map" "key1"
@sh1nj1
sh1nj1 / spring-security-config-for-api-key-auth.code
Created March 24, 2021 09:21
Spring security auth configuration for simple api-key header (Kotlin)
.addFilter(object: AbstractPreAuthenticatedProcessingFilter() {
override fun getPreAuthenticatedPrincipal(req: HttpServletRequest) = req.getHeader("X-API-KEY") ?: ""
override fun getPreAuthenticatedCredentials(req: HttpServletRequest) = ""
}.apply {
setAuthenticationManager {
it.isAuthenticated = it.principal == "{your-api-key}"
it
}
})
@sh1nj1
sh1nj1 / appcrush.rb
Last active March 14, 2017 05:18 — forked from zachwill/appcrush.rb
Extract images from iOS .ipa files
#!/usr/bin/ruby -rubygems
#
# Point appcrush at an .ipa file from the iTunes AppStore and it
# - expands the zip file
# - finds all the images
# - runs pngcrush with the revert-iphone-optimizations option on each image
#
# Requirements Xcode with iOS SDK 3.2 or higher
#
# Usage: appcrush '/Users/boctor/Music/iTunes/Mobile Applications/iBooks.ipa'
@sh1nj1
sh1nj1 / spark-spring-boot-pom.xml
Created March 18, 2016 00:23
Spark application with SpringBoot.
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>tv.anypoint</groupId>
<artifactId>spark-spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
@sh1nj1
sh1nj1 / spring-boot-exclude-jars
Created March 18, 2016 00:12
Exclude some jar files from package with spring-boot-gradle-plugin.
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
}
apply plugin: 'spring-boot'
springBoot {
customConfiguration = 'runtime'
}
@sh1nj1
sh1nj1 / emr_bootstrap_java_8.sh
Last active March 16, 2016 06:21 — forked from ericeijkelenboom/emr_bootstrap_java_8.sh
Bootstrap script for installing Java 8 on an Amazon Elastic MapReduce instance (AMI 3.0.1)
# Check java version
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
if [ "$JAVA_VER" -lt 18 ]
then
# Download jdk 8
echo "Downloading and installing jdk 8"
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.rpm"
# Silent install
@sh1nj1
sh1nj1 / update-file-encoding.sh
Created November 3, 2015 01:04
update file encoding
find ./ -name "*.sql" -exec file -i {} \; | grep "charset=iso-8859-1" | cut -d':' -f1 | while read a; do iconv -c -f euc-kr -t utf-8 $a > "$a-utf8.sql"; cat "$a-utf8.sql" > "$a"; rm "$a-utf8.sql"; done
@sh1nj1
sh1nj1 / jks-to-crt-and-key.txt
Created May 13, 2015 09:46
jks to crt and key
keytool -list -keystore keystore.jks
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias alias -deststorepass password
openssl pkcs12 -in keystore.p12 -nokeys -out cert.pem
openssl pkcs12 -in keystore.p12 -nodes -nocerts -out key.pem
openssl x509 -outform der -in cert.pem -out cert.crt
openssl rsa -in key.pem -out key.key