Skip to content

Instantly share code, notes, and snippets.

@max-power
max-power / css_counter.html
Created August 26, 2015 18:28
CSS Counters
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>ToC</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css" media="screen">
body {
font-family: -apple-system-font;
}
Gem::Specification.new do |s|
s.name = 'cptn-log'
s.version = '0.0.2'
s.platform = Gem::Platform::RUBY
s.author = 'Kevin Melchert'
s.email = 'kevin.melchert@gmail.com'
s.summary = 'MongoDB Logger.'
s.description = 'MongoDB Logger.'
s.files = ['cptn-log.rb']
@max-power
max-power / passbook.rb
Last active August 29, 2015 13:56
ruby passbook generation in one tiny file
%w(pathname json openssl net/http digest/sha1 zip).each { |lib| require lib }
module Passbook
def self.wwdr_certificate
OpenSSL::X509::Certificate.new <<-EOF.gsub /^\s+/, ""
-----BEGIN CERTIFICATE-----
MIIEIzCCAwugAwIBAgIBGTANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQGEwJVUzET
MBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlv
biBBdXRob3JpdHkxFjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwHhcNMDgwMjE0MTg1
NjM1WhcNMTYwMjE0MTg1NjM1WjCBljELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFw
@max-power
max-power / disco.gemspec
Last active August 29, 2015 13:57
Doorkeeper + Guestlist
Gem::Specification.new do |s|
s.name = 'disco'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Kevin Melchert'
s.email = 'kevin.melchert@gmail.com'
s.summary = 'MongoDB + Omniauth = Guestlist + Doorkeeper.'
s.description = 'MongoDB + Omniauth = Guestlist + Doorkeeper.'
s.files = ['disco.rb']
@max-power
max-power / roman_converter.rb
Last active August 29, 2015 14:16
Number to Roman
class RomanConverter
Dictionary = {
1000 => 'M',
900 => 'CM',
500 => 'D',
400 => 'CD',
100 => 'C',
90 => 'XC',
50 => 'L',
40 => 'XL',
@max-power
max-power / haikunator.rb
Created February 24, 2015 01:49
Haikunator
require "securerandom"
module Haikunator
Adjectives = %w(
autumn hidden bitter misty silent empty dry dark summer
icy delicate quiet white cool spring winter patient
twilight dawn crimson wispy weathered blue billowing
broken cold damp falling frosty green long late lingering
bold little morning muddy old red rough still small
sparkling throbbing shy wandering withered wild black
@max-power
max-power / authorization.gemspec
Last active August 29, 2015 14:17
Super simple policy authentication.
Gem::Specification.new do |s|
s.name = 'policy-authorization'
s.version = '0.0.2'
s.platform = Gem::Platform::RUBY
s.author = 'Kevin Melchert'
s.email = 'kevin.melchert@gmail.com'
s.summary = 'Super simple policy authentication.'
s.description = 'Super simple policy authentication.'
s.files = ['authorization.rb']
module Schmutz
Types = {
feinstaub: ["\u0323", "\u0307", "\u0312"],
mettwurst: ["\u0314", "\u031C", "\u0358", "\u0353", "\u0335"],
nein_nein: ["\u0337", "\u0338", "\u0336", "\u0335", "\u20d2", "\u20d3", "\u20e5", "\u20e6", "\u20eb"]
}.freeze
Types.each do |name, runes|
define_singleton_method name do |input, prop = 0.25|
mangle(input, runes, prop)
class Duration
attr_accessor :from, :till
def initialize(from: nil, till: nil)
@from = from || Time.now
@till = till || Time.now
end
def seconds
(till - from).round
@max-power
max-power / geolocation_polyfill.js
Created May 3, 2012 06:12
HTML5 Geolocation Polyfill
// requires jquery.js, tested with reqwest.js with jquery compat mode
// uses http://geoplugin.net/json.gp
// lowercase arguments are just string placeholder
// F = Function placeholder
// Z = Cache placeholder
;(function(N,g,c,x,y,u,j,F,Z) {
F=function(s,e){Z?s(Z):$.ajax({url:'//'+u+'.net/'+j+'.gp',dataType:j+'p',jsonp:j+'callback',error:e,success:function(R){Z={};Z[c]={};Z[c][x]=R[u+'_'+x];Z[c][y]=R[u+'_'+y];s(Z)}})}
N[g]=N[g]||{getCurrentPosition:F,watchPosition:F,clearWatch:function(){Z=undefined}}