Skip to content

Instantly share code, notes, and snippets.

View jdx's full-sized avatar

jdx

View GitHub Profile
require 'rest-client'
require 'json'
require 'pry'
require 'awesome_print'
url = "http://www.mashable.com/stories.json"
response = RestClient.get(url)
document = JSON.load(response)
@jdx
jdx / redneck.md
Last active December 19, 2015 03:08
redneck party supplies

Drinks

  • domestic beer
  • micro beer
  • blackberry brandy
  • whiskey
  • soda
  • water

Food

<form method="GET">
<input name="test" />
<a id="button">submit</a>
</form>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'></script>
<script>
$('#button').click(function() {
$('form').submit();
})
</script>
@jdx
jdx / bdd_mongo.md
Created August 5, 2013 18:12
rspec + mongo_mapper

Setting up a blog with rspec and mongo_mapper following BDD

Add gems

Install necessary gems:

gem 'mongo_mapper', github: 'jnunemaker/mongomapper'
gem 'bson_ext'
require 'rest-client'
require 'json'
require 'open-uri'
origin = URI::encode("1520 2nd ST, Santa Monica, CA")
destination = URI::encode("Las Vegas")
url = "http://maps.googleapis.com/maps/api/directions/json?origin=#{origin}&destination=#{destination}&sensor=false"
resp = RestClient.get(url)
directions = JSON.parse(resp)
@jdx
jdx / rails.md
Last active December 27, 2015 05:19
OSX Mavericks Rails setup

Installing Rails on OSX Mavericks

Install homebrew. You should be prompted to install the Xcode Command Line Tools.

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Make sure it is setup appropriately:

class Fixnum
define_method :+ do |i|
rand(100) == 42 ? 42 : i - -self
end
end
@jdx
jdx / stupid.rb
Created April 16, 2014 23:16
dont let me near ruby
class Fixnum
def random_number_between_oneAndTEN!(yaSuRE)
if yaSuRE == 'ya dude!'
return rand(10)
else
raise 'YA GATTA TYPE YA DUDE!!!!!!!'
end
end
end
@jdx
jdx / app.sh
Last active August 29, 2015 14:00
mkdir mynewapp
cd mynewapp
echo "{}" > package.json
npm install --global gulp
npm install --save-dev gulp
npm install --save-dev gulp-less
@jdx
jdx / gulpfile.js
Last active August 29, 2015 14:00
basic less compilation
var gulp = require('gulp');
var less = require('gulp-less');
gulp.task('less', function() {
return gulp.src('css/app.less')
.pipe(less())
.pipe(gulp.dest('dist'));
});