Skip to content

Instantly share code, notes, and snippets.

Paul Dlug pdlug

Block or report user

Report or block pdlug

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:30901
describe DataMapper::Types::Slug do
before(:all) do
class SlugTest
include DataMapper::Resource
property :id, Serial
property :name, Slug
property :title, String
property :title_slug, Slug
View gist:31202
require 'rubygems'
gem 'dm-core'
gem 'dm-types'
require 'dm-core'
require 'dm-types'
class User
include DataMapper::Resource
View gist:356879
describe "when handling results" do
before(:each) do
MQ.stub!(:new)'mapperproxy', {})
@instance = Nanite::MapperProxy.instance
@fanout = stub(:fanout, :publish => true)
@payload = {:payload => ['nanite', 'eventmachine', 'rabbitmq']}
pdlug / gist:962855
Created May 9, 2011
AMQP connection failure handling
View gist:962855
def setup_connection(connection)
# open channel, set up exchanges and bindings, subscribe
:host => '',
:vhost => '/search',
:timeout => 0.3,
:on_tcp_connection_failure => { |settings| puts "Failed to connect"; EM.stop }) do |connection, open_ok|
pdlug / gist:1072288
Created Jul 8, 2011
Test AMQP consumer/producer with auto recovery
View gist:1072288
require 'amqp'
def setup_connection(connection)
puts "Setting up connection"
channel =, :auto_recovery => true)
channel.on_error do |ch, channel_close|
raise channel_close.reply_text
View pacer_loop_test.rb
require 'bundler/setup'
require 'pacer'
require 'pacer-neo4j'
#graph =
graph = Pacer.neo4j('/tmp/test-neo4j')
c1 = graph.create_vertex(name: 'Concept 1')
c2 = graph.create_vertex(name: 'Concept 2')
View paul.zsh-theme
# Paul's ZSH Theme, based on several others
PROMPT='$(_user_host)${_current_dir}$(git_prompt_info)%{$reset_color%}${_return_status}%# '
local _current_dir="%3~ "
local _return_status="%{$fg[red]%}%(?..⍉)%{$reset_color%}"
local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
function _user_host() {
if [[ -n $SSH_CONNECTION ]]; then
pdlug / contribs.clj
Created Feb 4, 2015
Demo of parsing JATS XML using `` to extract contributors.
View contribs.clj
(ns jats.contribs
(:require [ :as io]
[ :as zip]
[ :as xml]
[ :as zx]
[clojure.pprint :as pprint])
(:gen-class :main true))
(defn contrib-name [name]
(let [first-name (zx/xml1-> name :given-names zx/text)
pdlug / index.ts
Last active Oct 21, 2018
Example of embedding Apollo GraphQL server inside next.js
View index.ts
import * as express from 'express'
import * as next from 'next'
import { ApolloServer, gql } from 'apollo-server-express'
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev, quiet: false })
const handle = app.getRequestHandler()
You can’t perform that action at this time.