Skip to content

Instantly share code, notes, and snippets.

@humbertodosreis
humbertodosreis / pipeline
Created April 26, 2021 19:52 — forked from mmonti/pipeline
Pipeline Pattern in Kotlin
package com.sunrun.fi.ingestion.input
import java.io.ByteArrayOutputStream
import java.nio.file.Paths
import java.util.zip.ZipInputStream
interface Step<I, O> {
fun process(input : I) : O
}
@whatnickcodes
whatnickcodes / base64.js
Created April 24, 2014 15:01
How to Encode and Decode Strings with Base64 in JavaScript
// Create Base64 Object
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r
@lunny
lunny / diskinfo.go
Created March 28, 2014 08:59
Disk Info for Golang
package main
import (
"fmt"
"syscall"
)
type DiskStatus struct {
All uint64 `json:"all"`
Used uint64 `json:"used"`
@rcmorano
rcmorano / docker-cheat-sheet.md
Last active July 28, 2022 13:23
my miscelaneous docker cheat sheet

rcmorano docker cheat sheet

Remove recursively zombie containers

In e.g.: you 'docker run -t -i' a 'bash' session and '.bashrc' is fucked up, container will forever respawn disallowing you to 'docker rmi' the used image .

docker rmi triangle/ubuntu-saucy-with-rvm 2>&1|grep ^Error|awk '{print $10}'|xargs docker rm
@thanhhh
thanhhh / puma.rb
Created May 20, 2013 06:13
Create file puma.rb on /home/redmine/redmine/config/puma.rb
#!/usr/bin/env puma
# Start Puma with next command:
# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
# uncomment and customize to run in non-root path
# ENV['RAILS_RELATIVE_URL_ROOT'] = "/redmine"
application_path = '/home/redmine/redmine'
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)