Skip to content

Instantly share code, notes, and snippets.

View pachacamac's full-sized avatar
🌶️
Mmmmhmmmm

Marc pachacamac

🌶️
Mmmmhmmmm
  • Hacker/Founder
  • Germany, Berlin
View GitHub Profile
@pachacamac
pachacamac / piratize.rb
Created June 3, 2017 21:15
pirate speech
def piratize(text)
dictionary = {"address"=>"port o' call", "admin"=>"helm", "am"=>"be", "an"=>"a", "and"=>"n'", "are"=>"be", "award"=>"prize", "bathroom"=>"head", "beer"=>"grog", "before"=>"afore", "belief"=>"creed", "between"=>"betwixt", "big"=>"vast", "bill"=>"coin", "bills"=>"coins", "boss"=>"admiral", "bourbon"=>"rum", "box"=>"barrel", "boy"=>"lad", "buddy"=>"mate", "business"=>"company", "businesses"=>"companies", "calling"=>"callin'", "canada"=>"Great North", "cash"=>"coin", "cat"=>"parrot", "cheat"=>"hornswaggle", "comes"=>"hails", "comments"=>"yer words", "cool"=>"shipshape", "country"=>"land", "dashboard"=>"shanty", "dead"=>"in Davy Jones's Locker", "disconnect"=>"keelhaul", "do"=>"d'", "dog"=>"parrot", "dollar"=>"doubloon", "dollars"=>"doubloons", "dude"=>"pirate", "employee"=>"crew", "everyone"=>"all hands", "eye"=>"eye-patch", "family"=>"kin", "fee"=>"debt", "female"=>"wench", "females"=>"wenches", "food"=>"grub", "for"=>"fer", "friend"=>"shipmate", "friends"=>"crew", "fuck"=>"shiver me timbers
@pachacamac
pachacamac / cipher.rb
Last active May 29, 2017 18:18
Rails encryption/decryption helper
module Cipher
ENCRYPTOR = ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base)
def self.encrypt(data)
ENCRYPTOR.encrypt_and_sign(data)
end
def self.decrypt(data)
ENCRYPTOR.decrypt_and_verify(data)
end
@pachacamac
pachacamac / soma.rb
Last active March 31, 2020 10:53
soma
#!/usr/bin/env ruby
require 'json'
require 'open-uri'
#require 'byebug'
def load_json(url)
#JSON.parse(`wget -q -O- #{url}`, symbolize_names: true)
JSON.parse(open(url).read, symbolize_names: true)
end
@pachacamac
pachacamac / letsencrypt_this.rb
Created August 31, 2016 10:32
letsencrypt helper
#!/usr/bin/env ruby
require 'acme-client'
require 'openssl'
require 'uri'
require 'net/http'
class Acme::Client::Crypto
def generate_signed_jws(header:, payload:)
jwt = JSON::JWT.new(payload || {})
@pachacamac
pachacamac / color_extension.rb
Last active August 17, 2016 17:14
add some colors to your cli output
class String
def black; "\e[30m#{self}\e[0m" end
def red; "\e[31m#{self}\e[0m" end
def green; "\e[32m#{self}\e[0m" end
def brown; "\e[33m#{self}\e[0m" end
def blue; "\e[34m#{self}\e[0m" end
def magenta; "\e[35m#{self}\e[0m" end
def cyan; "\e[36m#{self}\e[0m" end
def gray; "\e[37m#{self}\e[0m" end
def bg_black; "\e[40m#{self}\e[0m" end
/*
* If the loop bumps into an function, it returns true, and moves on,
* but if it bumps into a number, it waits x milliseconds,
* it stops the _.every loop by returning false, and recursively
* calls the sequence function with the rest of the array.
* Nifty, huh? 😝😝
*/
const sequence = b => b.every((a, i) => !(a.call ? a() : setTimeout(() => sequence(b.slice(++i)), a)));
@pachacamac
pachacamac / svg-creator-tool.html
Last active October 7, 2016 00:04
simple as fuck svg creator
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>SVG Helper Tool</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>click and drag on the canvas ... you're making a polygon ... <button id="reset">reset</button><button id="undo">undo</button></p>
<canvas id="x" width="500" height="500" style="border: 1px solid black;"></canvas>
@pachacamac
pachacamac / galcon_hacking.html
Last active May 29, 2016 17:29
galcon hacking
<style>*{margin:0;padding:0;box-sizing:border-box;}canvas{width:100%;height:100%}</style>
<canvas id='C' style='background:#000;'>
<script>
var c=C.getContext("2d"),R=Math.random,tick=Date.now(),selectedPlanets=new Set(),i,j,ships=[],planets=[],sfx=[];
C.width = window.innerWidth; C.height = window.innerHeight;
c.font = '18px Helvetica'; c.textAlign = 'center'; c.textBaseline = 'middle';
function synth(f,d){
for(var t=0,s='RIFF_oO_WAVEfmt '+atob('EAAAAAEAAQBAHwAAQB8AAAEACAA')+'data';++t<d;)s+=String.fromCharCode(f(t));
@pachacamac
pachacamac / codepenclone.html
Created April 29, 2016 12:52
Mini Codepen Clone with sharing function
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MiniCodepenClone</title>
<style>
body,textarea,iframe{ margin:0; box-sizing:border-box; }
textarea,iframe { width:100%; height:50vh; float:left; }
textarea { color:#eee; background:#111; font-family:monospace; font-size:11pt; line-height:1.4; width:33.33%; }
#shareBtn { position:absolute; bottom:0; left:0; }
@pachacamac
pachacamac / vidup2.rb
Last active April 28, 2016 02:33
new version of vidup, made to work with https
require 'sinatra'
require 'sinatra-websocket'
require 'thin'
$logger = Logger.new(STDERR)
$logger.level = Logger::INFO
set server: 'thin', bind: '127.0.0.1', port: 7777
set namespaces: {}