This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AlaCarte where | |
-- Control.Monad.Free | |
data Free f a = Free (f (Free f a)) | Pure a | |
instance Functor f => Monad (Free f) where | |
Pure a >>= f = f a | |
Free r >>= f = Free (fmap (>>= f) r) | |
return = Pure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreatePlaces < ActiveRecord::Migration | |
# Rails migration for GeoWorldMap db into postgresql db | |
#(inspired by http://blog.inspired.no/populate-your-database-with-free-world-cities-countries-regions-in-2-minutes-using-a-rails-migration-273/ post) | |
#extract files from GeoWorldMap.zip archive from here | |
# http://www.geobytes.com/GeoWorldMap.zip | |
# | |
#and place them into #{Rails.root}/db/migrate/ | |
##the archive has 'cities.txt' file, rename it 'Cities.txt' | |
#mv cities.txt Cities.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ScopedTypeVariables #-} | |
module Data.Time.ISO8601.Duration where | |
import Control.Applicative | |
import Data.ByteString (ByteString) | |
import qualified Data.ByteString.Char8 as BS8 | |
import Data.Attoparsec.ByteString.Char8 | |
import Test.QuickCheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Concurrent (threadDelay) | |
import Test.Hspec | |
import qualified Test.Hspec.Core.Hooks as Hooks | |
main :: IO () | |
main = hspec spec | |
-- | When a hook is set up with `beforeAll`, that changes the type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
require 'json' | |
class QueueInspector | |
include HTTParty | |
basic_auth "guest", "guest" | |
base_uri "http://192.168.0.1:55672" | |
def messages | |
body = {'count' => 5,'requeue' => true, 'encoding' => 'auto', 'truncate' => 50000}.to_json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Accommodation < ActiveResource::Base | |
class << self | |
def element_path(id, prefix_options = {}, query_options = nil) | |
prefix_options, query_options = split_options(prefix_options) if query_options.nil? | |
"#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}" | |
end | |
def collection_path(prefix_options = {}, query_options = nil) | |
prefix_options, query_options = split_options(prefix_options) if query_options.nil? | |
"#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ShallowNestedRoutes | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
# Pass in the name of the parent class | |
def set_shallow_nested_route_parent(parent) | |
parent = parent.to_s | |
# Override these methods so they set the prefix path before a call and reset it afterward. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveResource::Connection | |
# HACK 1: Add an attr_reader for response | |
attr_reader :response | |
def request(method, path, *arguments) | |
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload| | |
payload[:method] = method | |
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}" | |
payload[:result] = http.send(method, path, *arguments) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Determines the coordinates (latitude and longitude) of the places or | |
# addresses passed as arguments (either on the command line or via stdin) | |
# and prints the results. | |
# This script requires the Ruby Geocoder gem by Alex Reisner | |
# (http://www.rubygeocoder.com). | |
# To install the gem, run this command from a Terminal session: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div id="react-root"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-with-addons.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-dom.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.7/babel.min.js"></script> | |
<script id="App" type="text/template"> | |
const App = ({name}) => { |
OlderNewer