Skip to content

Instantly share code, notes, and snippets.

@EaseTheWorld
EaseTheWorld / AndroidPromise.js
Last active August 1, 2024 08:10
Simple implementation of AndroidPromise(Run android async work from javascript using ES6 Promise/async/await)
var AndroidPromise = {
callbacks: {},
requestId: 0,
request: function (work, params={}) {
return new Promise((resolve, reject) => {
let requestId = this.requestId++
this.callbacks[requestId] = {
'resolve': resolve,
'reject': reject
}
@Neo23x0
Neo23x0 / log4j_rce_detection.md
Last active September 11, 2024 21:41
Log4j RCE CVE-2021-44228 Exploitation Detection

log4j RCE Exploitation Detection

You can use these commands and rules to search for exploitation attempts against log4j RCE vulnerability CVE-2021-44228

Grep / Zgrep

This command searches for exploitation attempts in uncompressed files in folder /var/log and all sub folders

sudo egrep -I -i -r '\$(\{|%7B)jndi:(ldap[s]?|rmi|dns|nis|iiop|corba|nds|http):/[^\n]+' /var/log
@pathnirvana
pathnirvana / AsyncJava.js
Last active December 2, 2024 01:22
Async Await call to JavascriptInterface Android Java WebView
// Allows to call a Android java function asynchronously
// spawn long running computations/io on the Java/Android without blocking the JS/Website running inside the WebView
// Eg. const result = await callAndroidAsync('javaFunction', { param1: 'value1', param2: 'value2' })
// Please give a star if you find this useful
export async function callAndroidAsync(javaFuncName, params) {
const rand = 'asyncJava_' + Math.floor(Math.random() * 1000000)
window[rand] = {}
// func called from android
@tobecwb
tobecwb / DummyUserDetailsService.java
Created October 16, 2019 12:59
Kerberos Login with Spring Boot
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
public class DummyUserDetailsService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
@matzegebbe
matzegebbe / ApiGatewayApplication
Last active May 27, 2021 22:38
SpringCloudGatewayLogging
public class ApiGatewayApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(ApiGatewayApplication.class);
public static void main(String[] args) {
SpringApplication.run(ApiGatewayApplication.class, args);
}
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
@dyllanwli
dyllanwli / Pdf2JpegConverter.java
Created July 23, 2019 07:39
convert PDF to JPEG/multi-page tiff/image-pdf files
package org.doc2pdf.lambda;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
@metafloor
metafloor / zpl-quick-reference.md
Last active February 14, 2025 16:32
ZPL Quick Reference

ZPL Commands

Command Format Description
^A ^Afo,h,w,d:f.x Use Scalable/Bitmapped Font
^A@ ^A@o,h,w,d:f.x Use Font Name to Call Font
^B0 ^B0a,b,c,d,e,f,g Aztec Bar Code Parameters
^B1 ^B1o,e,h,f,g Code 11 Bar Code
^B2 ^B2o,h,f,g,e,j Interleaved 2 of 5 Bar Code
^B3 ^B3o,e,h,f,g Code 39 Bar Code
@VoidMonk
VoidMonk / redis_exporter.service
Created May 17, 2019 03:30
Systemd service file redis_exporter
[Unit]
Description=Redis Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=redis_exporter
Group=redis_exporter
Type=simple
ExecStart=/usr/local/bin/redis_exporter
@angristan
angristan / single-node-es.md
Last active February 6, 2025 11:10
Elasticsearch settings for single-node cluster (1 shard, 0 replica)

Elasticsearch settings for single-node cluster

1 shard, 0 replica.

For future indices

Update default template:

curl -X PUT http://localhost:9200/_template/default -H 'Content-Type: application/json' -d '{"index_patterns": ["*"],"order": -1,"settings": {"number_of_shards": "1","number_of_replicas": "0"}}' 
package main
import (
"strings"
"path/filepath"
)
func fileNameWithoutExtension(fileName string) string {
return strings.TrimSuffix(fileName, filepath.Ext(fileName))
}