Skip to content

Instantly share code, notes, and snippets.

@afazio
afazio / Test run from the command line with output
Last active August 29, 2015 14:25
Test whyle loop with example run and output
> scala whyle_test.scala Testing the whyle loop
Testing
the
whyle
loop
Predicate is being evaluated
Body is being evaluated
Testing
Predicate is being evaluated
Body is being evaluated
@afazio
afazio / gist:8562ba6ef8146d7b217b
Created October 25, 2014 01:04
Webmock: Not accepting partial query matching in 1.20.0
[Fri Oct 24 2014 20:53:46 GMT-0400 (EDT)] WARNING WebMock::NetConnectNotAllowedError - Real HTTP connections are disabled. Unregistered request: GET http://api.xxx.org/content/items?per_page=100&promoted_showable_on=2014-10-24&promoted_to_homepage=true&site=a9569efc-528c-4549-b33d-1c91bec8880f&state=published,staged with headers {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.0'}
[Fri Oct 24 2014 20:53:46 GMT-0400 (EDT)] WARNING
[Fri Oct 24 2014 20:53:46 GMT-0400 (EDT)] WARNING You can stub this request with the following snippet:
[Fri Oct 24 2014 20:53:46 GMT-0400 (EDT)] WARNING
[Fri Oct 24 2014 20:53:46 GMT-0400 (EDT)] WARNING stub_request(:get, "http://api.xxx.org/content/items?per_page=100&promoted_showable_on=2014-10-24&promoted_to_homepage=true&site=a9569efc-528c-4549-b33d-1c91bec8880f&state=published,staged").
[Fri Oct 24 2014 20:53:46 GMT-0400 (EDT)] WARNING with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,i
@afazio
afazio / .zshrc
Created June 4, 2014 16:08
ZSH prompt for Git and Ruby
## ~/.zshrc
# ...
# Load extensions from ~/.zsh/func/ directory
zgitinit
railsdir
# Setup basic prompt:
if [[ "$TERM" != "dumb" ]]; then
@afazio
afazio / utf8.rb
Last active December 20, 2015 01:09
Decode a hex string into a UTF-8 string. Try this hex string as an example: e299a5205765204d616b652054756d6d792048617070792120e299a5
#!/usr/bin/env ruby
def usage
puts "usage: #{$0} <hex_string>"
exit 1
end
def continuous_byte? (byte)
(0x80..0xBF).include?(byte)
end
@afazio
afazio / main.c
Last active December 14, 2015 00:19
Compile: "gcc -o main main.c" Call: "./main /path/to/some/file/or/directory"
#include <stdio.h>
#include <unistd.h>
int main (int argc, char** argv) {
char* path = argv[1];
printf ("Checking write permissions for %s:\n", path);
int result = access(path, W_OK);
printf ("User %s have write permissions.\n", (result == -1 ? "does NOT" : "DOES"));
@afazio
afazio / gist:4513320
Created January 11, 2013 19:33
"rvm --trace --universal pkg install libyaml"
+__rvm_parse_args:660> [[ -n 4.3.12 ]]
+__rvm_parse_args:695> [[ -z '' && -n '' ]]
+__rvm_parse_args:698> [[ error == || 0 -eq 1 || -n '' ]]
+__rvm_parse_args:16> [[ -n --universal ]]
+__rvm_parse_args:18> rvm_token=--universal
+__rvm_parse_args:20> (( 3 > 0 ))
+__rvm_parse_args:22> next_token=pkg
+__rvm_parse_args:23> shift
+__rvm_parse_args:28> case --universal ([[:alnum:]]*|@*)
+__rvm_parse_args:28> case --universal (-*)
@afazio
afazio / libyaml.rb
Created January 11, 2013 17:52
"cat /usr/local/Library/Formula/libyaml.rb"
require 'formula'
class Libyaml < Formula
url 'http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz'
homepage 'http://pyyaml.org/wiki/LibYAML'
md5 '36c852831d02cf90508c29852361d01b'
def options
[
["--universal", "Build for both 32 & 64 bit Intel."],
@afazio
afazio / config.log
Created January 11, 2013 16:59
/Users/afazio/.rvm/src/yaml-0.1.4/config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by yaml configure 0.1.4, which was
generated by GNU Autoconf 2.67. Invocation command line was
$ ./configure --prefix=/Users/afazio/.rvm/usr --disable-dependency-tracking
## --------- ##
## Platform. ##
@afazio
afazio / gist:4512174
Created January 11, 2013 16:46
Output of "rvm --debug pkg install --universal libyaml" on Mac OS X 10.6.8
__rvm_update_configure_env(4):CFLAGS= -arch i386 -arch x86_64 -O3 CCFLAGS= -arch i386 -arch x86_64 -O3 CXXFLAGS= -arch i386 -arch x86_64 -O3 LDFLAGS= -arch i386 -arch x86_64:found compiler: gcc-4.2
Fetching yaml-0.1.4.tar.gz to /Users/afazio/.rvm/archives
Fetching: https://rvm.io/src/yaml-0.1.4.tar.gz
Fetch command: curl -f -L --create-dirs -C - -o yaml-0.1.4.tar.gz
Archive checksum matched, not downloading
Downloaded archive checksum matched.
Extracting yaml to /Users/afazio/.rvm/src/yaml-0.1.4
Configuring yaml in /Users/afazio/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/afazio/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/afazio/.rvm/usr
@afazio
afazio / gist:4512095
Created January 11, 2013 16:36
Output of "rvm --debug pkg install --universal libyaml" on Mac OS X 10.8.2
__rvm_update_configure_env(4):CFLAGS= -arch i386 -arch x86_64 -O3 CCFLAGS= -arch i386 -arch x86_64 -O3 CXXFLAGS= -arch i386 -arch x86_64 -O3 LDFLAGS= -arch i386 -arch x86_64:
found compiler: /usr/bin/gcc
Fetching yaml-0.1.4.tar.gz to /Users/afazio/.rvm/archives
Fetching: https://rvm.io/src/yaml-0.1.4.tar.gz
Fetch command: curl -f -L --create-dirs -C - -o yaml-0.1.4.tar.gz
Archive checksum matched, not downloading
Downloaded archive checksum matched.
Extracting yaml to /Users/afazio/.rvm/src/yaml-0.1.4
Configuring yaml in /Users/afazio/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/afazio/.rvm/src/yaml-0.1.4.