Skip to content

Instantly share code, notes, and snippets.

View jarrodhroberson's full-sized avatar

Jarrod Roberson jarrodhroberson

View GitHub Profile
@VijayKrishna
VijayKrishna / ReturnAdapter.java
Last active September 8, 2023 19:53
Example code showing how the AdviceAdapter in ASM(.ow2.org) can be used/extended.
package self.vpalepu.stackoverflow;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
@jarrodhroberson
jarrodhroberson / find_in_jar.bat
Last active November 16, 2017 00:50 — forked from leogomes/find_in_jar.sh
bash and windows shell scripts to find classes in .jar files in a directory
# Windows (cmd) Command line version
forfiles /S /M *.jar /C "cmd /c jar -tvf @file | findstr /C:"$1" && echo @path"
@amoilanen
amoilanen / bulk_download_Coursera_videos.js
Last active May 21, 2022 02:18
Bulk download of Coursera videos with wget
/*
* Bulk download of Coursera videos with wget.
*
* Copyright (c) 2014 Anton Ivanov [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
import com.google.common.reflect.TypeToken;
@SuppressWarnings("unchecked")
public T get()
{
final Class<T> entityType = (Class<T>) new TypeToken<T>(getClass()) {}.getRawType();
try { return entityType.newInstance(); }
catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); }
}
@dopoljak
dopoljak / CertificateSigningRequestUsingSunJDK.java
Last active August 28, 2023 13:56
Example how to create PKCS#10 Certificate Signing Request (CSR) using Sun JDK, This example creates signature externally - suitable for Cryptographic devices such as Hardware Security Module (HSM)
package com.ilirium.client;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.KeyPair;
@gene1wood
gene1wood / batch-delete-gmail-emails.js
Last active January 2, 2026 18:30
A Google Apps Script script to bulk delete large amounts of email in Gmail while avoiding the error #793 which Gmail encounters normally
/*
This script, when used with Google Apps Scripts, will delete 400 emails and
can be triggered to run every few minutes without user interaction enabling you
to bulk delete email in Gmail without getting the #793 error from Gmail.
Google returns a maximum of 500 email threads in a single API call.
This script fetches 400 threads in case 500 threads is causing timeouts
Configure the search query in the code below to match the type of emails
you want to delete
/**
* Current standard is RFC 3986, published in 2005: http://tools.ietf.org/html/rfc3986#page-50. Apache Commons has a
* url validator, but it doesn't accept certain urls, probably because it's implementing RFC2396 from 1998. Also, the
* Fitbit API validator has custom needs such as allowing unicode characters.
* <p/>
* REGEX_COMPILED is used by UrlTypeConverter and MultiUrlsTypeConverter to validate third party app urls.
* <p/>
* All regex parts are borrowed from dperini's "https://gist.github.com/dperini/729294" unless otherwise noted.
* The dperini regex satisfies most of the test cases here: https://mathiasbynens.be/demo/url-regex, and has undergone
@thomasdarimont
thomasdarimont / App.java
Last active October 22, 2025 10:34
Example for defining a refreshable Groovy Script in Spring Boot with Java Config - at least thats the current state of affairs :)
package demo;
import java.util.concurrent.TimeUnit;
import org.springframework.aop.TargetSource;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@Kyle-Mendes
Kyle-Mendes / String.prototype.format.js
Last active January 12, 2016 22:44
String.prototype.format
String.prototype.format = function() {
var self = this,
formats = self.match(/{(:?\d*)}/g), // an array of formats `{}` found in the string
counter = 0, // A counter to keep track of what index to replace with
args = arguments; // Dereferencing arguments for use in the nested code blocks
if (formats) {
formats.forEach(function(format) { // We loop through each format expression in the array
var namedMatch = format.match(/{:(\d+)}/), // Checking if the format is a named replacement (i.e. {:1})
reg;
@vincent144
vincent144 / kmp.java
Created December 30, 2016 22:30
Knuth Morris Pratt string searching algorithm in Java
import java.util.Scanner;
public class KMP {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String search = kb.next();
String target = kb.next();
int result = KMP(search, target);
if (result == -1) {
System.out.println("NO");