Skip to content

Instantly share code, notes, and snippets.

@augustf
augustf / concerto_demo_script.rb
Last active October 8, 2015 00:38
Concerto Demo script
# Script to reset a Concerto demo instance and include useful demo data
# This should be invoked with bundle exec rails runner concerto_demo_script.rb
# Recommended cron entry: 00 00 * * * ruby path/to/concerto_demo_script.rb
#drop, migrate, and seed the database
require 'rake'
Rake.load_rakefile Rails.root.join( 'Rakefile' )
Rake::Task["db:reset"].invoke
# At this point, a demo screen, feed, and group exist. All that's needed is an initial admin, some sample users, and content
@augustf
augustf / rails_service.service
Created August 6, 2015 18:58
systemd script for rails
# systemd unit file
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
# - systemctl enable rectifier_mailman
# - systemctl {start,stop,restart} rectifier_mailman
#
# See Inspeqtor's Systemd wiki page for more detail about Systemd:
# https://github.com/mperham/inspeqtor/wiki/Systemd
@augustf
augustf / gist:10603453
Created April 13, 2014 21:38
Encrypted Email
You may be concerned that the NSA is reading your e-mail. Is there really anything you can do about it though? After all, you don’t really want to move off of GMail / Google Apps. And no place you would host is any better.
Except, you know, hosting it yourself. The way that e-mail was originally designed to work. We’ve all just forgotten because, you know, webapps-n-stuff. It’s a lot of work, mkay, and I’m a lazy software developer.
Today we kill your excuses. Because I’m going to show you exactly how to do it, it’s going to take about two hours to set up, and it’s a “set it and forget it” kind of setup. Not only that, but it is actually going to be better than GMail, from a purely features perspective. It might surprise you to learn that people continue to develop email server software in a post-Google-apps world, and that the state of self-hosted is much better than you remember.
Now fair warning: it took me about two days to figure the stuff out you’re going to see in this blogpost, starting from knowin
@augustf
augustf / reset_nightly.rake
Last active January 3, 2016 10:09
Maintain nightly Concerto instance
namespace :reset_nightly do
system("git checkout .")
system("git pull")
Rake::Task["db:reset"].invoke
Rake::Task["db:migrate"].invoke
@user = User.new(:email => 'admin@concerto-signage.org', :password => 'some_password', :password_confirmation => 'some_password', :is_admin => true)
@user.save
end
@augustf
augustf / gist:5297562
Created April 3, 2013 00:48
Convert all flac files to m4a
find . -name "*.flac" -type f -exec sh -c 'ffmpeg -i "$0" -acodec alac "`basename "$0" .flac`.m4a"' {} \;
In the application controller:
#call on this method to get access to the current user session in models (used in Task model for cocaine)
def set_current_user
User.current = current_user
end
In the User model:
#used to fetch the current user session in models
def self.current
Thread.current[:user]
@augustf
augustf / concerto-latest
Created November 20, 2012 03:36
Get latest Concerto version from Github or How I learned to hate the OpenSSL Nanny State
#!/usr/bin/env ruby
#https://api.github.com/repos/concerto/concerto/git/refs/tags
require 'net/https'
require 'uri'
require 'json'
uri = URI.parse('https://api.github.com/repos/concerto/concerto/git/refs/tags')
http = Net::HTTP.new(uri.host, uri.port)
if uri.scheme == "https" # enable SSL/TLS
@augustf
augustf / gist:2468275
Created April 23, 2012 02:11
Config key-value store\
class Configuration < ActiveRecord::Base
TRUE = "t"
FALSE = "f"
validates_presence_of :key
validates_uniqueness_of :key
# Enable hash-like access to table for ease of use
# Returns false if key isn't found