Skip to content

Instantly share code, notes, and snippets.

@bryanjswift
bryanjswift / abbreviated-unbound.conf
Last active September 19, 2022 05:02
Unbound (http://unbound.net/) configuration for local network device testing.
# The server clause sets the main parameters.
server:
# Allow network connections outside of localhost
interface: 0.0.0.0
# Don't automatically run in the background because I want to be able to kill it without hunting a pid
do-daemonize: no
# TODO: Change this to your network range, like `192.168.0.0/16 allow`
access-control: 10.0.0.0/16 allow
# TODO: Change this to your username, or whatever user you want to run/own the `unbound` process
username: "bryanjswift"
@bryanjswift
bryanjswift / mail_virtual_users.rb
Created February 27, 2014 06:10
Process STDIN containing DB row sets from a command selecting email address and password hash. Used in pipeline like `ssh {{ main_user_name }}@{{ domain }} 'PGPASSWORD={{ mail_db_password }} psql -U {{ mail_db_username }} -h 127.0.0.1 --command="SELECT email, password FROM virtual_users;" {{ mail_db_database }}' | grep '\$6\$' | ./mail_virtual_u…
#!/usr/bin/env ruby
require 'yaml'
# Part of command to sync down hashed user passwords
accounts = []
$stdin.each_line do |line|
email = line.split('|')[0].gsub(/\s+/, '')
hash = line.split('|')[1].gsub(/\s+/, '')
accounts << {
@bryanjswift
bryanjswift / Vagrantfile
Last active February 25, 2016 02:26 — forked from helloIAmPau/Vagrantfile
A file to install redis server onto an Ubuntu virtual machine.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@bryanjswift
bryanjswift / vimeo.class.php
Created September 23, 2012 06:52
Perch2 field type for vimeo embeds. Heavily based on youtube.class.php by Drew McLellan.
<?php
/**
* A field type for Vimeo videos
*
* @package default
* @author Bryan Swift
*/
class PerchFieldType_vimeo extends PerchAPI_FieldType
{
@bryanjswift
bryanjswift / twitter-entities.js
Created August 19, 2012 02:31 — forked from wadey/twitter-entities.js
JavaScript parser for Tweet Entities
/*
* twitter-entities.js
* This function converts a tweet with "entity" metadata
* from plain text to linkified HTML.
*
* See the documentation here: http://dev.twitter.com/pages/tweet_entities
* Basically, add ?include_entities=true to your timeline call
*
* Copyright 2010, Wade Simmons
* Licensed under the MIT license
@bryanjswift
bryanjswift / build.sbt
Created March 8, 2012 15:37
Project files for debugging
organization := "com.momentumww"
name := "sxsw-12"
version := "0.0.5"
scalaVersion := "2.9.1"
resolvers ++= Seq(
"Bryan's Repo" at "http://repos.bryanjswift.com/maven2/"
@bryanjswift
bryanjswift / inClassLoader.scala
Created January 19, 2012 03:56
Work around CaseClassSigParser exceptions in sbt:console

When doing something in an SBT console which requires the loading of Case Class instances via fig or jerkson if the code is executed within inClassLoader it will produce a result rather than a ClassNotFoundException.

For example in Persnicketly:

val articles = inClassLoader(classOf[com.persnicketly.persistence.Connection$]) {
  ScoredArticleDao.select(from = 60, count = 100)
}

Will successfully load MongoDB configuration from config.json, access the db and retrieve articles.

@bryanjswift
bryanjswift / .rtorrent.rc
Created December 28, 2011 02:42
rtorrent configuration file with description
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
# Maximum and minimum number of peers to connect to per torrent.
min_peers = 1
max_peers = 100
# Same as above but for seeding completed torrents (-1 = same as downloading)
@bryanjswift
bryanjswift / Servlet.scala
Created June 11, 2011 04:51
Basic Servlet trait and helper objects to make HttpServletRequest and HttpServletResponse interactions easier
package com.example
import javax.servlet.http.{Cookie, HttpServlet, HttpServletRequest => Request, HttpServletResponse => Response}
import scala.util.matching.Regex
trait Servlet extends HttpServlet {
override def doGet(request:Request, response:Response) = doGet(new HttpHelper(request, response))
override def doPost(request:Request, response:Response) = doPost(new HttpHelper(request, response))
def doGet(http:HttpHelper) { }
def doPost(http:HttpHelper) { }
/* Graph */
#graph { padding: 5px; width: 477px; height: 299px; }