- requires HTTP Basic authorization
user_email
-- users email required
module Foo | |
class Bar;end | |
end | |
module Foo | |
class Baz | |
# lookup order: Foo::Baz::Bar, Foo::Bar, Bar | |
Bar.new # => #<Foo::Bar:...> | |
end | |
end |
class Foo | |
private | |
attr_accessor :foo | |
public | |
def access_foo | |
foo # => nil # as expected | |
self.foo # => NoMethodError: private method... | |
end |
class WhatIsMyPublicApi < BasicObject | |
def initialize(*arguments) | |
method_missing('initialize', *arguments) | |
end | |
def method_missing(method, *arguments) | |
::File.open('what_is_my_public_api.log', 'a') do |f| | |
args = arguments.inspect.gsub(/^\[|\]$/, '') | |
f.write("#{method}(#{args})\n") | |
end |
describe WebService | |
def test_request(t, path, params, &block) | |
# Local variable t persists in both callbacks | |
# However, `block` doesn't make it | |
@result = nil | |
WebService.post(path, params) do |result| | |
@result = result | |
t.resume | |
end |
import sublime_plugin | |
import os | |
class PomodoroStatus(sublime_plugin.EventListener): | |
# TODO: set up an interval callback on_activated | |
def update_pomodoro_status(self, view): | |
f = os.popen('~/Dropbox/dotfiles/bin/pomodoro time') | |
view.set_status("0_pomodoro_status", f.read()) |
#include <Charlieplex.h> | |
#define NUMBER_OF_PINS 5 | |
byte pins[] = {0,1,2,3,4}; | |
Charlieplex charlieplex = Charlieplex(pins,NUMBER_OF_PINS); | |
typedef bool grid[6][5]; | |
int h = 5; | |
int w = 4; |
class WidgetsController < ApplicationController | |
def create | |
@widget = Widget.new(params[:widget]) | |
if @widget.save | |
SpamMailer.widget_spam(@widget).deliver | |
redirect_to widget, notice: 'Widget created' | |
else | |
render 'new' | |
end |
module ActiveAdmin | |
module ViewHelpers | |
module FormHelper | |
def active_admin_form_for(resource, options = {}, &block) | |
options = Marshal.load( Marshal.dump(options) ) | |
options[:builder] ||= ActiveAdmin::FormBuilder | |
+ resource = resource.respond_to?(:model) ? resource.model : resource | |
semantic_form_for resource, options, &block | |
end |
// I have a RestKitManager.m that holds general methods to help set up mappings and routings | |
@implementation RestKitManager | |
- (void)initialize { | |
RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:[AppDelegate appUrlForKey:BASE_URL_KEY]]]; | |
[RKObjectManager setSharedManager:objectManager]; |