Skip to content

Instantly share code, notes, and snippets.

# prevent the use of `` in tests
Spec::Runner.configure do |configuration|
backtick = nil # establish the variable in this scope
saved_system = nil
configuration.prepend_before(:all) do
# raise an exception if Kernel#` or Kernel#system is used
# in our tests, we want to ensure we're fully self-contained
Kernel.instance_eval do
backtick = instance_method(:'`')
saved_system = instance_method(:system)
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@inazt
inazt / service.groovy
Created September 3, 2010 10:53 — forked from pphetra/service
Grails Service ZeroMQ
import org.springframework.beans.factory.InitializingBean
import org.zeromq.ZMQ
class ParseService implements InitializingBean {
def pullSocket
def pubSocket
def running = true
def pollingRate = 200
@telamon
telamon / rdhcpd.rb
Created May 20, 2011 23:58
Pure ruby DHCP server
' Copyright (c) 2007, Tony Ivanov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
@Phrogz
Phrogz / client2.rb
Created October 25, 2011 23:21
One server, multiple clients, asynchronous bi-directional communication using TCP Sockets
#!/usr/bin/env ruby
#encoding: UTF-8
require_relative 'server2'
class Laink::Client
attr_reader :name
def initialize
@server = nil
@name = "Client #{rand(10000).to_s(36)}"
end
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active October 29, 2024 21:43
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@matthutchinson
matthutchinson / launch_instance.rb
Created January 23, 2012 15:10
Launching EC2 instance with aws-sdk gem
#!/usr/bin/ruby
# README
# gem install aws-sdk
# add this to bashrc
# export HT_DEV_AWS_ACCESS_KEY_ID=????
# export HT_DEV_AWS_SECRET_ACCESS_KEY=????
# put your pem file in ~/.ssh and chmod 0400
# for more info see; https://rubygems.org/gems/aws-sdk
@rjmcdonald83
rjmcdonald83 / markdown_to_prawn
Created July 23, 2012 16:52
Markdown to Prawn Parser
class TermsPdf < Prawn::Document
def initialize(application)
super()
@application = application
@listing = @application.listing
@host = @listing.organization
@guest = @application.guest_organization
font "Times-Roman"
default_leading 2
@imkevinxu
imkevinxu / .gitconfig
Created November 5, 2012 09:42
`git random` alias that will commit a random commit message from http://whatthecommit.com/
[alias]
random = !"git add -A; git commit -am \"$(echo $(curl -s http://whatthecommit.com/index.txt)\" (http://whatthecommit.com)\")\"; git pull --rebase; git push"
@maliqq
maliqq / broker.go
Last active November 22, 2018 08:53
Golang message broker
package protocol
import (
"fmt"
"log"
)
// pubsub
type Broker struct {
Send map[string]*chan *Message