Skip to content

Instantly share code, notes, and snippets.

View nopolabs's full-sized avatar

Dan Revel nopolabs

View GitHub Profile
@nopolabs
nopolabs / list-yum.sh
Created April 27, 2015 20:09
list packages in a given yum repo
sudo yum --disablerepo="*" --enablerepo="osis" --showduplicates list available
@nopolabs
nopolabs / gist:1354281
Created November 10, 2011 06:41 — forked from hay/gist:1351230
Enterprisify your Java Class Names!
<!doctype html>
<html>
<head>
<title></title>
<style>
body {
background: white;
text-align: center;
padding: 20px;
font-family: Georgia, serif;
@nopolabs
nopolabs / login.rb
Created December 11, 2011 03:21 — forked from amscotti/login.rb
Sample of Sinatra authentication
require 'rubygems'
require 'bcrypt'
require 'haml'
require 'sinatra'
enable :sessions
userTable = {}
helpers do
@nopolabs
nopolabs / nmvn
Created May 12, 2012 22:19
Create a new project using maven's quickstart archetype
#!/bin/bash
PKG=${1:?Usage: nmvn pkg}
PACKAGE=com.nopolabs.$PKG
mvn archetype:generate -DgroupId=$PACKAGE -DartifactId=$PACKAGE -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
@nopolabs
nopolabs / remove_trailing_whitespace_from_java
Created May 12, 2012 22:16
Removing trailing whitespace in java files.
find . -name \*.java -exec sed -i 's/[ \t]*$//' '{}' ';'
@nopolabs
nopolabs / coin_core.clj
Created January 15, 2013 05:47
greedy change
(ns coin.core)
(def no-change {1 0 5 0 10 0 25 0})
(def coins [25 10 5 1])
(defn count-change
[change]
(reduce
(fn [value coin]
#/bin/bash
DEV_DIR=riak-1.2.1/dev
for i in 1 2 3 4
do
PORT_PREFIX=99${i}
APP_CONFIG=${DEV_DIR}/dev${i}/etc/app.config
cp $APP_CONFIG $APP_CONFIG.bak
perl -pi -e "s/(pb_port,)\s*\d+/\1 ${PORT_PREFIX}1/" $APP_CONFIG
perl -pi -e "s/(http,.*127.0.0.1.*,)\s*\d+/\1 ${PORT_PREFIX}2/" $APP_CONFIG
@nopolabs
nopolabs / silex
Last active December 15, 2015 22:09
composer.json
---
{
"require": {
"silex/silex": "1.0.*@dev"
},
"autoload": { "psr-0": { "App": "./app" } }
}
@nopolabs
nopolabs / csvBuilder_example.js
Last active December 19, 2015 23:09
javascript csvBuilder to output results of mongo query as csv
// Usage: mongo localhost:27017/test csvBuilder_example.js | awk 'NR > 3 { print }' > products.out
var c = db.products.find({}, { _id: 1, name: 1, type: 1, shipper: 1 });
function printCsv(c) {
while (c.hasNext()) {
var r = c.next();
print(csvBuilder().
add(r._id).
add(r.name).
@nopolabs
nopolabs / Apollo.java
Last active June 3, 2016 08:57
Sample code demonstrating reading and writing to Apollo MQ using Java, but failure to read messages posted to Apollo MQ from PHP using STOMP.
package test;
import org.apache.activemq.ActiveMQConnectionFactory;
import javax.jms.*;
public class Apollo {
public static void main(String[] args) throws JMSException {
String user = "guest";