Skip to content

Instantly share code, notes, and snippets.

View johnmaxwell's full-sized avatar

John Maxwell johnmaxwell

  • Atlanta, GA
View GitHub Profile
@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
class EventsController < ApplicationController
before_filter :authenticate_user!
def index
end
def show
@event = Event.find_by_id(params[:id])
end
@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
// 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 / 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>');
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
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
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