This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Converts a markdown file from 4-space code blocks to ``` gated code blocks. | |
| # aka, normal markdown code blocks to Github Formatted markdown code blocks. | |
| # | |
| # Usage: | |
| # | |
| # ruby gfm_code_block.rb path/to/file.md | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Turn a list of elements into a sentence listing them | |
| # | |
| # Expected outcomes: | |
| # [] => "" | |
| # %w(one) => "one" | |
| # %(one two) => "one and two" | |
| # %w(one two three) => "one, two and three" | |
| # | |
| def list_sentence(elements) | |
| case elements.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "Got 0 (false)" | |
| "Got 1 (false)" | |
| "Got 2 (true)" | |
| "Got 3 (false)" | |
| "Got 4 (false)" | |
| "Got 5 (false)" | |
| "Got 6 (false)" | |
| "Got 7 (false)" | |
| "Got 8 (false)" | |
| "Got 9 (false)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # You could just `gem rdoc --all`, but where's the fun in that? | |
| gem list | \ | |
| ruby -ne 'n, v = $_.scan(/(.+) \(([\d., ]+)\)/).first; next unless v; v = v.split(", "); puts Array.new(v.length) { n }.zip(v).map {|x| x.join(" -v ") }' | \ | |
| xargs -P$(sysctl -n hw.ncpu) -L1 gem rdoc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module CustomTypes | |
| class SmfProperty < Serverspec::Type::Base | |
| module Helper | |
| def smf_property(fmri, group, property, options = {}) | |
| SmfProperty.new(fmri, group, property, options) | |
| end | |
| end | |
| def initialize(fmri, group, property, options = {}) | |
| super("#{fmri}-#{group}/#{property}", options) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ uname | |
| Linux | |
| $ mkdir -p 1/ 2/ shared/assets | |
| $ ln -s `pwd`/shared/assets `pwd`/1/assets | |
| $ ls -l 1/ 2/ shared/ | |
| 1/: | |
| total 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| thing_2 # => | |
| rescue Exception => e | |
| e # => #<NameError: undefined local variable or method `thing_2' for main:Object | |
| end | |
| if true | |
| thing_1 = 1 # !> assigned but unused variable - thing_1 | |
| else | |
| thing_2 = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Skips the foreman line starting "tomcat:", runs everything else in the Procfile | |
| foreman start -c $(awk -F: 'NR > 1 { printf "," }; $1 != "tomcat" { printf $1 "=1" }' Procfile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class person( | |
| $first_name, | |
| $second_name, | |
| $full_name = "${first_name} ${second_name}", | |
| $prenom = $first_name | |
| ) { | |
| notify { "first_name: ${first_name}": } | |
| notify { "second_name: ${second_name}": } | |
| notify { "full_name: ${full_name}": } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react-router/1.0.3/ReactRouter.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/history/2.0.0/History.js" type="text/javascript" charset="utf-8"></script> | |
| <script type="text/babel"> |