Skip to content

Instantly share code, notes, and snippets.

require 'minitest/autorun'
require 'rack/test'
require 'active_record'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :tickets, force: true do |t|
@crackedmind
crackedmind / Output
Created February 10, 2016 14:34 — forked from Circuitsoft/Output
Capture single image V4L2
Driver Caps:
Driver: "omap3"
Card: "omap3/mt9v032//"
Bus: ""
Version: 0.0
Capabilities: 04000001
Camera Cropping:
Bounds: 752x480+0+0
Default: 752x480+0+0
Aspect: 1/1
@crackedmind
crackedmind / git_json.rb
Last active August 29, 2015 14:06
Git log in json format
module GitJson
extend self
DEFAULT_TEMPLATE = {
hash: '%H',
commit: '%s',
date: '%at'
}
def self.log(from_commit: '', to_commit: '', n: 0, template: DEFAULT_TEMPLATE)
@crackedmind
crackedmind / macos_hints.md
Last active August 29, 2015 13:58
Some useful Mac OS X hints found by the internet
  1. No icons bouncing in the Dock
    $ defaults write com.apple.dock no-bouncing -bool TRUE
    
    $ killall Dock
    
  2. Change the screenshot save file location
    $ defaults write com.apple.screencapture location /path/
    
    
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

module Serel
class Question
def self.search_advanced
url("search/advanced")
end
end
class Relation
%w(q).each do |meth|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
class StackexchangePlugin
include Cinch::Plugin
API_KEY = '<empty>'
SITES = %w(stackoverflow serverfault)
SITES.each do |site|
match /#{site} (.+)/, method: site.to_sym
class_eval %{
def #{site}(m,search_string)