Skip to content

Instantly share code, notes, and snippets.

View johnmaxwell's full-sized avatar

John Maxwell johnmaxwell

  • Atlanta, GA
View GitHub Profile
def upload_sizing
result = {:export => {use: []}}
if uploads_enabled?
dims = (upload_width? && upload_height?) ? { width: upload_width, height: upload_height } : nil
dims_thumb = (upload_thumb_width? && upload_thumb_height?) ? { width: upload_thumb_width, height: upload_thumb_height } : nil
if enable_images?
if dims
result[:resize] = dims
def upload_sizing; result = {:export => {use: []}} && (uploads_enabled? && (dims_upload = (upload_width? && upload_height? && { width: upload_width, height: upload_height }) || nil) || true) && (dims_thumb = (upload_thumb_width? && upload_thumb_height?) ? { width: upload_thumb_width, height: upload_thumb_height } : nil)) && [[enable_images?, dims_upload, :resize],[enable_images?, dims_thumb, :resize_thumb],[enable_videos?, dims_upload, :encode],[enable_videos?, dims_thumb, :encode_thumb]].inject(result) { |result, (cond, dims, key)| cond && dims && (result[key.to_sym] = dims) && (result[:export][:use] << key.to_s) }) || result; end
vagrant@vagrantup:/publisher$ bundle exec rails g model Platform::Subscription callback_url:string name:string external_id:string token:string secret:string verify_token:string service_id:string state:string type:string
invoke active_record
create db/migrate/20110714153150_create_platform_subscriptions.rb
create app/models/platform/subscription.rb
create app/models/platform.rb
invoke rspec
create spec/models/platform/subscription_spec.rb
error factory_girl [not found]
vagrant@vagrantup:/publisher$ cat db/migrate/20110714153150_create_platform_subscriptions.rbclass CreatePlatformSubscriptions < ActiveRecord::Migration
def self.up
@johnmaxwell
johnmaxwell / hide-inline-images.js
Created February 16, 2012 16:35 — forked from starzonmyarmz/hide-inline-images.js
A userscript for Flowdock that adds a button next to inline elements like Tweets and Images that allows you to hide them. Really useful to hide annoying animated gifs and hubot pug bombs
// originally from: https://gist.github.com/1649063
$(function () {
if (window.fluid) {
setInterval(function(){
$('.image-preview-wrapper').not('.hideBtnAdded').each(function() {
var t = $(this);
if (t.find('.hideImg').length === 0) {
t.append('<button class="hideImg">Hide This Image</button>');
// this won't work because "this" doesn't map to this object
// when the click handler fires.
{
setupHandler: function () {
$('button').click(function () {this.handleClicks});
},
handleClicks: function () {
alert("I got clicked");
}
}
@johnmaxwell
johnmaxwell / Tallahassee restaurant recommendations
Created May 10, 2015 15:23
Tallahassee restaurant recommendations
Breakfast
=========
- Bada Bean
- Paisely Cafe
- Canopy Rd Cafe
- Lucy Leas cupcakes
Lunch
=====
- Paisely Cafe
class EventsController < ApplicationController
before_filter :authenticate_user!
def index
end
def show
@event = Event.find_by_id(params[:id])
end
@johnmaxwell
johnmaxwell / gist:588aff396b5bba4c451f
Last active January 12, 2016 15:27
netcat 0.7.1 webserver that closes connections
while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | netcat -l -c -p 8888 > incoming.txt ; done
If you're a Republican who is aghast by Trump and his supporters, and if you believe that Trump is ruining your otherwise decent party, I hope your are asking yourself, "Why am I surprised by this? Is this what I've been supporting with my votes?"
The answer is yes. Trump isn't ruining your party. He's just making its less flattering core more obvious. Other GOP candidates ordinarily gloss over the fact that . They smile and invoke euphemisms about protecting family or raising concern about law and order, but they support the same ignorant
@johnmaxwell
johnmaxwell / gist:67e77f213090b838776eea557e712cf9
Created July 6, 2016 18:46
Curl some JSON and then print it out all pretty-like
curl "http://jsonip.com" | ruby -e "require 'json'; puts JSON.pretty_generate(JSON.parse(STDIN.gets))"
# {
# "ip": "....",
# "about": "/about",
# "Pro!": "http://getjsonip.com"
# }
# Here's one that copies it straight into your clipboard (on the Mac)
curl "http://jsonip.com" | ruby -e "require 'json'; puts JSON.pretty_generate(JSON.parse(STDIN.gets))" | pbcopy