Skip to content

Instantly share code, notes, and snippets.

module Linux
class User
class << self
# Generate an MD5 salt string
def salt
seeds = ('a'..'z').to_a
seeds.concat( ('A'..'Z').to_a )
seeds.concat( (0..9).to_a )
@adam12
adam12 / dragonfly.rb
Last active September 30, 2015 04:13
require 'dragonfly'
# Adding image_optim to Dragonfly
image_optim = ImageOptim.new(nice: 20, threads: 4, verbose: true, advpng: { level: 4 }, jpegoptim: { strip: :all }, jpegrecompress: { quality: 2 }, optipng: { level: 4 }, pngcrush:{ chunks: :alla } )
# Configure
Dragonfly.app.configure do
plugin :imagemagick
# Image optimization processor.
ctrl.createField = function (e) {
e.preventDefault();
ctrl.vm.ContractSectionId = args.contractSection.Id;
var saveField = function () {
return Field.save(ctrl.vm).result
}
saveField()
@adam12
adam12 / kinda?.rb
Last active January 20, 2017 03:36 — forked from mfifth/full error
require 'sunspot'
require 'sunspot/rails'
require 'feedjira/feed'
module Sunspot
module Feedjira::Feed
def self.included(base)
base.class_eval do
extend Sunspot::Rails::Searchable::ActsAsMethods
Sunspot::Adapters::DataAccessor.register(DataAccessor, base)
@adam12
adam12 / Gemfile
Last active June 13, 2017 02:17 — forked from tatey/benchmark.rb
Mocha VS MiniTest::Mock and SimpleDelegate VS SimpleMock VS RR
# frozen_string_literal: true
source "https://rubygems.org"
gem "benchmark-ips"
gem "rr"
gem "mocha"
gem "simple_mock"
@adam12
adam12 / cgi.go
Created February 17, 2018 20:04 — forked from icholy/cgi.go
package main
import (
"fmt"
"net/http"
"net/http/cgi"
"os"
)
type Handler func(http.ResponseWriter, *http.Request)
package main
import (
"bufio"
"fmt"
"io"
"log"
"os/exec"
)
@adam12
adam12 / build.py
Created August 15, 2018 18:29 — forked from icholy/build.py
#!/usr/bin/env python
import errno
import os
import subprocess
import sys
import shutil
import glob
import tarfile
import os.path
@adam12
adam12 / jail.conf
Created October 18, 2018 14:48 — forked from paulc/jail.conf
FreeBSD ZFS Jail
interface = "lo1";
host.hostname = "$name";
ip4.addr = "172.16.0.$n";
path = "/jail/run/$name";
exec.prestart = "/sbin/zfs clone zroot/jail/template/10.2-RELEASE/root@10.2-RELEASE-p8 zroot/jail/run/$name &&
/usr/sbin/sysrc -f /jail/run/$name/etc/rc.conf hostname=$name &&
/usr/sbin/sysrc -f /jail/run/$name/etc/rc.conf sshd_enable=YES &&
/usr/sbin/sysrc -f /jail/run/$name/etc/rc.conf sshd_flags=\"-o ListenAddress=172.16.0.$n\" &&
/usr/sbin/pw -R /jail/run/$name useradd -n u01 -m -w random &&
/usr/sbin/pw -R /jail/run/$name lock root &&
@adam12
adam12 / async.rb
Created April 1, 2019 15:44 — forked from paul/async.rb
Implementations of useful step adapters for dry-transaction
# frozen_string_literal: true
module Tesseract
module Transaction
module Steps
# Executes the step in a background job. Argument is either an ActiveJob
# or another Transaction (or anything that implements `#perform_later`.
#
# If the provided transaction implements a `validate` step, then that
# validator will be called on the input before the job is enqueued. This