Skip to content

Instantly share code, notes, and snippets.

View kares's full-sized avatar

Karol Bucek kares

View GitHub Profile
@jordansissel
jordansissel / 1-output.txt
Last active November 10, 2021 14:28
Convert curl|bash to an rpm with Docker and FPM
% docker build -t rust .
...
# Export the image to tarball, which itself contains tarballs and a manifest.json
% docker save -o rust.tar rust
# Extract the last layer
# tar's -O flag extracts a single entry from the tarball.
# The file we want is the last "Layer" in the manifest.json
% tar -xf rust.tar -O $(tar -xf rust.tar -O manifest.json | jq -r '.[].Layers[-1]') > curlbash.tar
@SFEley
SFEley / LambdaHandler.java
Created October 22, 2018 18:42
LambdaHandler.java
import java.util.List;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.file.Paths;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import com.amazonaws.services.lambda.runtime.Context;
@LeZuse
LeZuse / stats_logger.rb
Last active June 21, 2021 13:53
Puma plugin for stats logging on Heroku
Puma::Plugin.create do
def production?
ENV.fetch('RACK_ENV', 'development') == 'production'
end
def log(msg)
if production?
Rails.logger.info msg
else
puts msg
@eginez
eginez / kotlinNativeGraal.md
Created May 8, 2018 02:42
Compile kotlin code to a native executable

You need to first install GraalVM, and then set your PATH so that you get the GraalVM binaries

Then you need the kotlin compiler toolchain. Easiest with sdkman Create a Kotlin file and add a simple program

$> cat src/main.kt
fun main() {
    println("hello")
}
@headius
headius / Hello.java
Last active January 19, 2018 16:56
"Hello, %s" using method handles two different ways
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
public class Hello {
private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
public static void main(String[] args) throws Throwable {
System.out.println("Hello, " + args[0]);
}
@voluntas
voluntas / sysctl.conf
Created October 14, 2017 13:07 — forked from techgaun/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@hengyunabc
hengyunabc / ClassLoaderUtils.java
Created October 12, 2017 12:02
Get SystemClassLoader/ClassLoader urls in java9
/**
*
* @author hengyunabc 2017-10-12
*
*/
public class ClassLoaderUtils {
@SuppressWarnings({ "restriction", "unchecked" })
public static URL[] getUrls(ClassLoader classLoader) {
if (classLoader instanceof URLClassLoader) {
return ((URLClassLoader) classLoader).getURLs();
@jsvd
jsvd / lpv.rb
Last active March 18, 2021 10:51
logstash plugin version
#!/usr/bin/env ruby
# use ./lpv.rb logstash_version plugin_name
#
# example:
# % ./lpv.rb 5.2.0 logstash-output-elasticsearch
# logstash-output-elasticsearch 6.2.4 https://github.com/logstash-plugins/logstash-output-elasticsearch/tree/v6.2.4
require 'net/http'
@headius
headius / gist:2a8de5eb6adb115acb4649b698e2f6d3
Created February 1, 2017 06:30
mandelbrot(750) on JRuby with and without a tweaked Graal
~/projects/graal-core $ jruby -v mandelbrot.rb
jruby 9.1.8.0-SNAPSHOT (2.3.1) 2017-01-25 2b97d78 Java HotSpot(TM) 64-Bit Server VM 9-ea+152 on 9-ea+152 +indy +jit [linux-x86_64]
1.4988730000000001
0.875144
0.6610520000000001
0.666915
0.67083
0.658069
0.6749970000000001
0.667617