Skip to content

Instantly share code, notes, and snippets.

View softprops's full-sized avatar
®️
Rustling

Doug Tangren softprops

®️
Rustling
View GitHub Profile
// remix of https://discordapp.com/channels/605571803288698900/1219282855679496243/1219706356718632981
const std = @import("std");
const Timestamp = struct {
seconds: i64,
pub fn format(
self: @This(),
comptime _: []const u8,
_: std.fmt.FormatOptions,
@softprops
softprops / coderpad.go
Last active March 7, 2024 19:03
coder pad go template
// To execute Go code, please declare a func main() in a package "main"
package main
import (
"log"
"reflect"
"time"
)
@softprops
softprops / CoderPad.java
Last active March 7, 2024 19:03
coder pad java template
import java.io.*;
import java.util.*;
import static org.junit.Assert.*;
// fmt: shift + cmd + f
// imports : shift + cmd + o
class Solution {
// impl
// 👇
@softprops
softprops / ecs-exec.sh
Last active November 25, 2022 02:30
when you want `docker exec` but your containers live on ecs container instances. assumes an vpn bastion host
#!/usr/bin/env bash
# runs an arbitrary command on a remote ecs target
#
# usage: `ecs-exec bash`
#
# ssh credentials
#
# Add the following to your ~/.ssh/config file
#
# Assumes ec2 bastion key for authenicating
java.base@11.0.11
exports java.io
exports java.lang
exports java.lang.annotation
exports java.lang.invoke
exports java.lang.module
exports java.lang.ref
exports java.lang.reflect
exports java.math
exports java.net
@softprops
softprops / NonRepeatingStream.java
Created June 16, 2021 18:50
NonRepeatingStream.java
import java.util.stream.*;
import java.util.concurrent.*;
import java.util.*;
public <T> Stream<T> nonRepeatingStream(List<T> src) {
IntSupplier index = () -> ThreadLocalRandom.current().nextInt(0, src.size());
return Stream.iterate(
index.getAsInt(),
(prev) -> {
int next = index.getAsInt();
use rand; // 0.8.3
use rand::Rng;
use std::iter::successors;
fn non_repeating<T: std::cmp::PartialEq + Clone>(src: &[T]) -> impl Iterator<Item = &T> + '_ {
let mut rng = rand::thread_rng();
successors(Some(&src[rng.gen_range(0..src.len())]), move |n| {
let mut next = &src[rng.gen_range(0..src.len())];
while *next == **n {
next = &src[rng.gen_range(0..src.len())];
# using rvm with ruby-1.8.7-p249
# latest version 2.7.7 2010-06-17
brew install libxml2
# installing libxslt from source code
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar xvfz libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
function getHumanReadable() {
echo $(echo $1 | awk '{ sum=$1 ; hum[1024**3]="Gb";hum[1024**2]="Mb";hum[1024]="Kb"; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x];break } }}')
}
This file has been truncated, but you can view the full file.
docker diff 7a3036a55355
C /root
A /root/.cargo
A /root/.cargo/bin
A /root/.cargo/bin/rustfmt
A /root/.cargo/bin/rustup
A /root/.cargo/bin/cargo-fmt
A /root/.cargo/bin/clippy-driver
A /root/.cargo/bin/rustc
A /root/.cargo/bin/rustdoc