Skip to content

Instantly share code, notes, and snippets.

View dbongo's full-sized avatar

Michael Crowther dbongo

View GitHub Profile
@dbongo
dbongo / vpngen.rb
Created December 17, 2019 21:48 — forked from arnehormann/vpngen.rb
Configuration file generator for OpenVPN which also sets up a ca and generates keys.
#!/usr/bin/env ruby
# Just call this without arguments. It will show a friendly help text.
# For xterm-256color, it will even use colors for some commands!
class AppConfig
@@default_remote = 'vpn.example.com'
@@default_networks = '10.0.0.0/24>192.168.1.0/24'
@@default_subject = '/C=US/ST=CA/L=San Francisco/O=Example/OU=/CN={{name}}'
@dbongo
dbongo / optparse-template.rb
Created August 15, 2019 18:20 — forked from rtomayko/optparse-template.rb
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@dbongo
dbongo / bfile.rb
Created April 29, 2019 03:36 — forked from skord/bfile.rb
A simple file server and uploader using sinatra
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
$pwd = ENV['PWD']
if File.exists?(ARGV.last)
if ARGV.last != 'bfile.rb'
@dbongo
dbongo / database_cleaner.rb
Created April 8, 2016 16:52 — forked from jsteiner/database_cleaner.rb
Database Cleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
<div contenteditable="true" class="editable" data-editable-input-id="input-name"></div>
<input id="input-name" type="text" name="input-name" value="" placeholder="Don't Touch Me" />
$(document).ready(function() {
// Loop through each of the empty .editable elements and add filler edit text.
$('.editable:empty').each(function(){
$(this).text('Edit Me');
});
// On .editable blur() - when a user clicks off of an .editable element take it's text and pass it to the corresponding input.
$('.editable').blur(function() {
var editableContent = $(this).text();
@dbongo
dbongo / server.go
Last active August 29, 2015 14:10 — forked from elbuo8/server.go
package main
import (
"fmt"
"io/ioutil"
"net/http"
"github.com/codegangsta/negroni"
jwt "github.com/dgrijalva/jwt-go"
"github.com/gorilla/mux"
@dbongo
dbongo / bootstrap.sh
Last active August 29, 2015 14:07 — forked from jdx/bootstrap.sh
apt-get update
apt-get install -y git npm
npm install -g n
n stable
@dbongo
dbongo / boot.js
Last active August 29, 2015 14:07 — forked from jdx/boot.js
'use strict';
var numCpus = require('os').cpus().length
var cluster = require('cluster')
cluster.setupMaster({exec: __dirname + '/server.js'})
// workerIds returns the node cluster index for each worker
function workerIds() { return Object.keys(cluster.workers) }
// Gets the count of active workers
package mypackage.web
import akka.actor._
import akka.io.IO
import akka.pattern.{AskTimeoutException, ask, gracefulStop, pipe}
import com.typesafe.scalalogging.slf4j.Logger
import javax.inject.Inject
import org.slf4j.LoggerFactory
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}