Skip to content

Instantly share code, notes, and snippets.

@lloeki
lloeki / brutalize_openssl.rb
Created December 2, 2014 10:29
Violently disable OpenSSL cert validation (dangerous!)
require 'openssl'
class OpenSSL::SSL::SSLContext
def verify_mode
OpenSSL::SSL::VERIFY_NONE
end
def verify_mode=(_)
@verify_mode = OpenSSL::SSL::VERIFY_NONE
end
@lloeki
lloeki / class_diagram.rake
Last active August 29, 2015 14:10
Rails class diagram (e.g models) with graphviz
# (c) Loic Nageleisen
# License: MIT
Node = Struct.new(:type, :name, :attributes)
Edge = Struct.new(:type, :from, :to, :name)
class DiagramGraph
def initialize
@nodes = []
@edges = []
@lloeki
lloeki / monad_id.rb
Created September 1, 2014 11:52
Identity monad in Ruby
# http://moonbase.rydia.net/mental/writings/programming/monads-in-ruby/01identity
# Identity monad
class Identity
def initialize(value)
@value = value
end
# unit operation: Haskell 'return'
def self.munit(value)
@lloeki
lloeki / lua.go
Created August 7, 2014 07:16
Go <-> Lua
package main
/*
#cgo LDFLAGS: -lluajit-5.1
#include <stdlib.h>
#include <stdio.h>
#include <luajit-2.0/lua.h>
#include <luajit-2.0/lualib.h>
#include <luajit-2.0/lauxlib.h>
@lloeki
lloeki / arel_composition_without_activerecord.rb
Last active August 15, 2023 18:11
Arel composition (without ActiveRecord)
# rebuttal of http://www.try-alf.org/blog/2013-10-21-relations-as-first-class-citizen
require 'arel'
require 'sqlite3'
require 'pry'
def suppliers
@suppliers ||= Arel::Table.new(:suppliers)
end

Keybase proof

I hereby claim:

  • I am lloeki on github.
  • I am lloeki (https://keybase.io/lloeki) on keybase.
  • I have a public key whose fingerprint is D2CB 6310 2C72 5899 1C0D 4A53 971B 4D9F 125C D31E

To claim this, I am signing this object:

@lloeki
lloeki / patch_ati6870_gibba.sh
Created April 10, 2014 12:36
Fix 5-ports for ATI 6870 on OSX (10.8/10.9) using Gibba framebuffer
cd /System/Library/Extensions/ATI6000Controller.kext/Contents/MacOS
sudo perl -pi -e 's|\x00\x04\x00\x00\x04\x03\x00\x00\x00\x01\x00\x00\x12\x04\x05\x01\x00\x04\x00\x00\x04\x03\x00\x00\x00\x01\x00\x00\x22\x05\x04\x02\x00\x08\x00\x00\x04\x02\x00\x00\x00\x01\x00\x00\x11\x02\x06\x04\x00\x02\x00\x00\x14\x02\x00\x00\x00\x01\x00\x00\x00\x00\x03\x05\x04\x00\x00\x00\x04\x02\x00\x00\x00\x01\x00\x00\x11\x02\x01\x03|\x00\x04\x00\x00\x04\x03\x00\x00\x00\x01\x00\x00\x12\x04\x04\x01\x00\x04\x00\x00\x04\x03\x00\x00\x00\x01\x00\x00\x22\x05\x05\x02\x00\x08\x00\x00\x04\x02\x00\x00\x00\x01\x00\x00\x11\x02\x06\x04\x00\x02\x00\x00\x14\x02\x00\x00\x00\x01\x00\x00\x00\x00\x03\x05\x04\x00\x00\x00\x04\x02\x00\x00\x00\x01\x00\x00\x11\x02\x01\x06|g' AMD6000Controller
@lloeki
lloeki / Settings
Last active February 15, 2016 21:04
PS3 controller setting for Fez on OSX
~/Library/Application Support/FEZ/Settings
--8<-- Default (Xbox 360)
gamepadMapping Jump=1 GrabThrow=0 CancelTalk=2 OpenMap=8 OpenInventory=3 MapZoomIn=5 MapZoomOut=4 Pause=9 RotateLeft=6 RotateRight=7 FpViewToggle=10 ClampLook=11
--8<-- Sony PS3 DualShock3 / Logitech RumblePad 2
gamepadMapping Jump=14 GrabThrow=15 CancelTalk=13 OpenMap=0 OpenInventory=12 MapZoomIn=9 MapZoomOut=8 Pause=3 RotateLeft=10 RotateRight=11 FpViewToggle=1 ClampLook=2
--8<--
@lloeki
lloeki / nokogiri_builders.rb
Created September 27, 2013 08:34
Using Nokogiri::XML::Builder in lieu of stock pure ruby Builder for Rails builder templates
# config/initializers/nokogiri_builders.rb
# Using Nokogiri::XML::Builder in lieu of stock pure ruby Builder for Rails builder templates
# unrelated, but you might want this too to enable parsing
# XML params with Nokogiri
#ActiveSupport::XmlMini.backend = 'Nokogiri'
module Nokogiri
module XML
class Builder
@lloeki
lloeki / example.sym
Created September 8, 2013 09:02
$ nm -a example | grep -i glfw
0000000004071c1a t +[GLFWContentView initialize]
000000000407276b t -[GLFWApplication sendEvent:]
0000000004071c10 t -[GLFWApplicationDelegate applicationDidChangeScreenParameters:]
0000000004071b98 t -[GLFWApplicationDelegate applicationDidHide:]
0000000004071bc4 t -[GLFWApplicationDelegate applicationDidUnhide:]
0000000004071b6c t -[GLFWApplicationDelegate applicationShouldTerminate:]
0000000004071dbc t -[GLFWContentView acceptsFirstResponder]
0000000004071db1 t -[GLFWContentView canBecomeKeyView]
0000000004071d5c t -[GLFWContentView dealloc]
00000000040724b9 t -[GLFWContentView flagsChanged:]