Skip to content

Instantly share code, notes, and snippets.

View tedkulp's full-sized avatar

Ted Kulp tedkulp

View GitHub Profile
@tedkulp
tedkulp / app.rb
Created June 11, 2014 20:09
Ruby version
#!/usr/bin/env ruby
# encoding: utf-8
require 'rubygems'
require 'amqp'
require 'json'
EventMachine.run do
connection = AMQP.connect(:host => '192.168.100.10', :user => 'admin', :password => 'changeme')
_ = require('lodash')
rpc = require('amqp-rpc').factory
url: "amqp://admin:changeme@192.168.100.10:5672"
exchange: "rpc_exchange"
rpc.on 'echo.*', (params, cb, callInfo) ->
if params.message
reply = {
echo: true
message: params.message
@tedkulp
tedkulp / after_chaining.js
Last active August 29, 2015 14:03
Code for "A few reasons to use Underscore.js (or Lo-Dash)"
function capAndJoinWords(aryOfWords) {
return _.chain(aryOfWords)
.map(function(item) { return item + '123'; })
.map(function(item) { return item.toUpperCase(); })
.reverse()
.value()
.join(' ');
}
capAndJoinWords(['array', 'this', 'in', 'are', 'words', 'test']); // "TEST123 WORDS123 ARE123 IN123 THIS123 ARRAY123"
@tedkulp
tedkulp / gist:5fc8563f906d501caa32
Created April 17, 2015 19:01
Cleanup removed/merged remote branches and the local branches that tracked them
alias grcl='git checkout master && git pull && git remote prune origin && git branch -avv | grep "gone]" | awk '\''{ print $1 }'\'' | xargs git branch -d'
@tedkulp
tedkulp / 44-my-devices.rules
Created May 1, 2015 11:18
Set /dev path on Raspberry Pi based on what USB port it's plugged into
SUBSYSTEM=="tty", ATTRS{devpath}=="1.2", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="topmatrix"
SUBSYSTEM=="tty", ATTRS{devpath}=="1.3", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="bottommatrix"
<?php
if (!function_exists('getPageChooser')) {
function getPageChooser($pageLinks=array(), $activeIndexNumber=0, $previousText="Previous", $nextText="Next", $firstVisableNumber=1) {
// This function takes an array with links and makes a nice page chooser from it.
// The index of the array is 0 based, so is the activeIndexNumber.
// Make firstVisableNumber 0 if you want to see pagenumbers start with 0 (Why would you???).
$pagermenu = array();
if (!is_array($pageLinks)) return "";
$pageLinksCount = count($pageLinks);
<?php
#-------------------------------------------------------------------------
# Module: Cart - A simple example frontend form module
# Version: 1.0, calguy1000 <calguy1000@cmsmadesimple.org>
#
#-------------------------------------------------------------------------
# CMS - CMS Made Simple is (c) 2005 by Ted Kulp (wishy@cmsmadesimple.org)
# This project's homepage is: http://www.cmsmadesimple.org
# The module's homepage is: http://dev.cmsmadesimple.org/projects/skeleton/
#
<?php
include 'lib/silk/silk.api.php';
SilkDatabase::connect('mysql://root:@localhost/cms_innodb', true, true, 'cms_');
$users = orm('user')->find_all(array('order' => "id ASC"));
var_dump($users[0]->full_name());
var_dump($users[0]->groups[0]->name);
<?php
include_once('lib/silk/silk.api.php');
$config = SilkYaml::load(join_path(ROOT_DIR, 'config', 'setup.yml'));
include_once('config/routes.php');
//SilkDatabase::connect($config['database']['dsn'], $config['debug'], true, $config['database']['prefix']);
We couldn’t find that file to show.