Skip to content

Instantly share code, notes, and snippets.

require "excon"
require "platform-api"
require "pry"
app = "smith-fronty"
heroku = PlatformAPI.connect_oauth("abcdefg")
`rm -f #{ENV['HOME']}/app.tar.gz && cd #{ENV['HOME']}/Projects/railsconf_fronty && tar cfz #{ENV['HOME']}/app.tar.gz *`
source = heroku.source.create(app)
@smith
smith / iee754
Created April 8, 2016 18:59
ieee 754 lol
nathansmith@opstop ~> pry
[1] pry(main)> 0.1 + 0.2
=> 0.30000000000000004
[2] pry(main)>
nathansmith@opstop ~> python
Python 2.7.4 (default, May 6 2013, 00:06:59)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1 + 0.2
0.30000000000000004
@smith
smith / GravatarComponent.ts
Last active May 9, 2017 03:55
Gravatar Component for Angular 2
import {Component} from "angular2/core";
const md5 = require("blueimp-md5");
@Component({
selector: "gravatar",
inputs: ["defaultStyle", "email", "size"],
template: `
<img class="my-gravatar"
width="{{size || DEFAULT_SIZE}}" height="{{size || DEFAULT_SIZE}}"
src='{{gravatarUrl(defaultStyle, email, size)}}'>`
@smith
smith / load.rb
Last active October 16, 2015 11:46
Greenspun's tenth rule
# See https://github.com/coderanger/chef-dialects-testbed, https://github.com/chef/chef-rfc/blob/master/rfc036-dialects.md
require "edn"
require "json"
open("recipe.rb", "w") do |f|
EDN.read("(#{open('recipe.edn').read})").each do |resource|
type = resource.shift.to_s
name = resource.shift.to_s
properties = resource.shift || {}
@smith
smith / version-manifest.txt
Created March 25, 2015 13:39
Example Supermarket Version Manifest
supermarket 1.7.0-alpha.0
Component Installed Version Version GUID Overridden From
--------------------------------------------------------------------------------------------------------------
berkshelf master git:3d4b5971f86dd7927d198a1acdaf13c33e867179
bundler 1.7.3 1.5.3
bzip2 1.0.6 md5:00b516f4704d4a7cb50a1d97e6e8e15b
cacerts 2014.08.20 md5:c9f4f7f4d6a5ef6633e893577a09865e 2014.09.03
curl 7.36.0 md5:643a7030b27449e76413d501d4b8eb57
dep-selector-libgecode 1.0.2
  1. get a vm 4:11 - 4:14
  2. configure a resource 4:14 - 4:23
  • Running the terminal in a different window is weird, especially since it's a browser window and not my terminal and I have to keep context-switching in between the two.
  • It tells me to create a file and edit its contents and save it, which assumes that I know how to do all of these things from a unix shell or a linux desktop. If you're running in the console you can do gedit hello.rb & which gives a nice editor. Maybe we should make this the default.
  • It says, "From your terminal window, run chef-apply to apply what you've written.", but below it says to run "chef-apply hello.rb". If you just run chef-apply, you get "TypeError: no implicit conversion of nil into String", which isn't very friendly. The commands should match and the error output should say something that makes sense.
  1. configure a package and a service 4:24 - 4:30
  • Maybe the desktop should just have the icons for the things we're using on it
@smith
smith / gem_make.out
Created May 21, 2014 14:32
Output of build of dep-selector-libgecode on CentOS 5.8
/opt/chef/embedded/bin/ruby extconf.rb
-> sh /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/dep-selector-libgecode-1.0.0/ext/libgecode3/vendor/gecode-3.7.3/configure --prefix=/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/dep-selector-libgecode-1.0.0/lib/dep-selector-libgecode/vendored-gecode --disable-doc-dot --disable-doc-search --disable-doc-tagfile --disable-doc-chm --disable-doc-docset --disable-qt --disable-examples --disable-flatzinc
checking for the host operating system... Linux
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++44 accepts -g... yes
@smith
smith / chef-stacktrace.out
Created February 20, 2014 23:49
stacktrace huh?
Generated at 2014-02-20 23:35:12 +0000
TypeError: can't convert nil into String
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.18.0/lib/ohai/system.rb:134:in `join'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.18.0/lib/ohai/system.rb:134:in `block in all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.18.0/lib/ohai/system.rb:131:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.18.0/lib/ohai/system.rb:131:in `all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/client.rb:266:in `run_ohai'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/client.rb:478:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/client.rb:199:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/client.rb:193:in `fork'
@smith
smith / extractor
Created February 14, 2014 03:29
Starter extractor example
#!/usr/bin/env ruby
#
# As a possible replacement for a Chef Starter kit, we could download a single
# "bundle" that contains the user's custom knife.rb and keys and use a command
# to install it in ~/.chef. This is a prototype of such a command.
#
# The script takes a filename (we'll call it starter.rb) as an argument. The
# file consists of the following:
#
# * A knife.rb
@smith
smith / requests.rb
Created November 5, 2013 02:39
Making an https request in ruby
string_uri = 'https://api.opscode.piab/organizations/test/nodes'
# Using Net::HTTP
require 'net/http'
require 'openssl'
require 'uri'
uri = URI.parse('https://api.opscode.piab/organizations/test/nodes')
http = Net::HTTP.new(uri.host, uri.port)