Skip to content

Instantly share code, notes, and snippets.

View kennethkalmer's full-sized avatar

Kenneth Kalmer kennethkalmer

View GitHub Profile
@kennethkalmer
kennethkalmer / nginx.conf
Last active August 3, 2021 19:44
Sample nginx config for serving a rails API and static frontend like Ember on the same domain...
daemon off;
worker_processes 4;
events {
use epoll;
accept_mutex on;
multi_accept on;
worker_connections 1024;
}
@kennethkalmer
kennethkalmer / smtp-sink.rb
Created July 23, 2010 12:15
Very simple SMTP sinkhole that just prints the messages to stdout
require 'rubygems'
require 'eventmachine'
class SmtpSink < EM::Protocols::SmtpServer
def receive_data_chunk( data )
buffer.concat data
end
def receive_message
puts
@kennethkalmer
kennethkalmer / gist:278814
Created January 16, 2010 13:14
node.js SMTP Server
/*
smtpd.js is SMTP server written for node.js
MIT License
*/
var tcp = require('tcp');
var sys = require('sys');
@kennethkalmer
kennethkalmer / _README.md
Last active January 2, 2021 11:06
Simple start with InfluxDB & Grafana using Travis as a source of historical data

InfluxDB & Grafana starter pack

Simple example of how easy it is to jam numbers into InfluxDB and graph something with Grafana. I choose to use Travis as a source of historical time-series data.

Dependencies

Get InfluxDB installed with Homebrew

$ brew install influxdb
@kennethkalmer
kennethkalmer / scrap-tui.rb
Created April 16, 2009 14:47
Automate scrap testing your Rails app
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
puts "Memory Usage Delta "
puts "============ ========"
loop do
agent.get('http://172.16.133.100:3000/session/new')
@kennethkalmer
kennethkalmer / README.md
Last active April 1, 2020 19:41
Making sense of basic port forwarding with SSH tunnels

SSH tunnel example

We all know how to ssh to a remote box...

Basic SSH connection with ssh 99.88.77.66

                            99.88.77.66
 +-------+                            +--------+
 | LOCAL |----------------------------| REMOTE |

Upload component

Context

Based heavily on [s3-beam][1], but uses re-frame events/subs to get the job done. The /sign handler is the [s3-beam][1] handler (near verbatim).

For background on (ui.core/component "...") see https://opensourcery.co.za/2017/02/12/using-semantic-ui-react-with-re-frame/

ui.ajax is just thin wrappers and/or aliases around plumbing from ajax.core from cljs-http

@kennethkalmer
kennethkalmer / grep-postfix-message-ids-osx.sh
Created October 23, 2008 13:41
Grep for a pattern through a Postfix mail log, collect the message ids into a temporary file and then grep for all occurrences of the ID's in the maillog.
#!/bin/sh
# OSX friendly version by jeff donovan
#
# Grep for a pattern through a Postfix mail log, collect the message ids into a temporary
# file and then grep for all occurrences of the ID's in the maillog.
# This is a very intensive operation since it requires 1+N greps through the entire log file,
# where N is the number of unique ID's returned from the first grep.
#
# Usage sample:
@kennethkalmer
kennethkalmer / find_unused_helpers.rb
Created November 29, 2011 07:17
Find unused helpers in a Rails app (slow)
#!/usr/bin/env ruby
#
# Shotgun approach (read: slow and dirty hack) to help find unused helpers in a Rails application
#
puts "Loading all source files into memory :("
source = {}
Dir["app/**/**/*.*"].each do |f|
source[ f ] = File.readlines( f )
class AnnouncementsController < ApplicationController
def index
pagination_options = { :page => params[:page], :per_page => params[:per_page] }
@announcements = Announcement.by_admins( params[:archived], pagination_options )
end
end