Skip to content

Instantly share code, notes, and snippets.

View roolo's full-sized avatar

Mailo Světel roolo

View GitHub Profile
@roolo
roolo / gist:2146612
Created March 21, 2012 12:31
Ruby https request
require 'net/https'
https = Net::HTTP.new('encrypted.google.com', 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
https.request_get('/')
@roolo
roolo / command.sh
Created March 26, 2012 12:09
yard-tomdoc -- Unhandled exception in YARD::Handlers::Ruby::MethodHandler:
yard --plugin tomdoc -n .
@roolo
roolo / README.md
Created April 6, 2012 19:25
Ruby 1.9.3 p125 @ Lion

Installing Ruby 1.9.3p125 on Mac OS X 10.7.3 – Lion

About this gist

  • Environment — clean Mac OS X 10.7.3 – Lion installation
  • all other files are examples of each of following installation steps
  • commented lines in examples is output of preceding command
  • I'll use rvm for installing Ruby in this gist

Installation

jekyll_site_var = nil
def jekyll_site
if jekyll_site_var.nil?
jekyll_site_var = Jekyll::Site.new
end
jekyll_site_var
end
@roolo
roolo / pdo_connect.php
Created May 25, 2012 14:44
Old times :)
<?php
$a = new PDO('pgsql:host=localhost;dbname=travis_development', 'mailo', 'password');
$sth = $a->prepare("SELECT * FROM artifacts");
$sth->execute();
$data = $sth->fetchAll(PDO::FETCH_ASSOC);
var_dump($data);
var_dump($a->errorInfo());
@roolo
roolo / cosi.zsh
Created June 18, 2012 12:18
Google url shortener
curl -v https://www.googleapis.com/urlshortener/v1/url -X POST -H 'Content-Type: application/json' -d "{\"longUrl\": \"$1\"}"
╰─$ defaults read com.apple.Safari NSQuitAlwaysKeepsWindows
2012-06-19 10:46:19.180 defaults[3319:707]
The domain/default pair of (/Users/mailo/Library/Preferences/com.apple.Safari.plist, NSQuitAlwaysKeepsWindows) does not exist
@roolo
roolo / rails c
Created August 1, 2012 14:37
How to get mass assignable attributes for model
Loading development environment (Rails 3.2.6)
1.9.2p320 :001 > Game.accessible_attributes
=> #<ActiveModel::MassAssignmentSecurity::WhiteList: {"", "name"}>
1.9.2p320 :002 > Game.accessible_attributes.to_a
=> ["", "name"]
1.9.2p320 :003 > Game.accessible_attributes.to_a.reject{|i| i.empty?}
=> ["name"]
Capybara.register_driver :selenium_chrome do |app|
Capybara::Selenium::Driver.new app, :browser => :chrome
end
Capybara.javascript_driver = :selenium_chrome
@roolo
roolo / touch_file.plist
Created September 27, 2012 18:34
Basic LaunchAgent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.touchsomefile</string>
<key>ProgramArguments</key>
<array>
<string>touch</string>
<string>/tmp/helloworld</string>