Skip to content

Instantly share code, notes, and snippets.

/* A simple store using libmicrohttp */
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <microhttpd.h>
#include <string.h>
#include <fcntl.h>
Choice.options do
header 'Run a waves application server.'
header ''
option :port do
short '-p'
long '--port=PORT'
desc 'Port to listen on.'
desc 'Defaults to value given in configuration.'
cast Integer
end
require 'waves/foundations/compact'
module Foo
include Waves::Foundations::Compact
module Resources
class Server
on( true ) { "hello" }
end
end
end
DELIMITERS = [ ['(',')'], ['{','}'], ['[',']'] ]
def match?( string, stack = [] )
return true if string.empty? and stack.empty?
first = string[0,1] ; DELIMITERS.any? do | open, close |
case first
when open then match?( string[1..-1], stack.clone.push( close ) )
when close then match?( string[1..-1], stack ) if stack.clone.pop == close
else false
end
end
book (
title: Why Pez Is Better Than You're Mom
author: Lonnie Tran
price: (19.95):usd
description: |-
Learn the fabulous stack-based language, Pez! Also,
you're Mom follows me on Twitter!
)
module MetaHelper
# include this anywhere you want to refer to the model, controller, etc., generically
# all methods are prefixed with x_ to avoid name clashes with existing methods
def x_controller_class ; self.class ; end
def x_controller_name ; self.class.name.underscore.gsub('_controller', '') ; end
def x_model_name ; x_controller_name.singularize ; end
def x_model_class ; x_model_name.camelize.constantize ; end
def x_mailer_name ; x_model_name + "_mailer" ; end
new function(_) { // create the closure
// create the package object
var shapes = new base2.Package(this, {
name: "shapes",
version: "1.0",
exports: "PI,Circle,Rectangle"
});
// evaluate the imported namespace
eval(this.imports);
broadway:SharesPost danyoder$ git checkout controls
Switched to branch 'controls'
broadway:SharesPost danyoder$ git merge l2
Auto-merging app/controllers/asks_controller.rb
CONFLICT (content): Merge conflict in app/controllers/asks_controller.rb
Auto-merging app/controllers/bids_controller.rb
CONFLICT (content): Merge conflict in app/controllers/bids_controller.rb
Auto-merging app/controllers/orders_controller.rb
Auto-merging app/models/ask.rb
CONFLICT (content): Merge conflict in app/models/ask.rb
class CompanySweeper < ActionController::Caching::Sweeper
observe Company, Comment, Document, Order, Trade
%w( create update destroy ).each do | action |
define_method( "after_#{action}") do | instance |
%w( index companies/* pages/home ).each { |p| `rm -rf public/cache/views/#{p}.html.cache` }
end
end
desc "Stop agents from running background tasks"
task :stop do
if File.exist?( pidfile )
pid = File.read( pidfile ).to_i
if pid > 0
puts "Stopping agents (process #{pid})."
Process.kill('INT', pid.to_i ) rescue nil
end
`rm #{pidfile}`
else