Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am samacs on github.
  • I am samacs (https://keybase.io/samacs) on keybase.
  • I have a public key ASC91Jfd2B3qg3G5ZZSR2jCzkDi8EVTuRGaBVmtJhTGk-Qo

To claim this, I am signing this object:

#!/bin/bash
RUBY_VERSION=2.4.1
RAILS_VERSION=5.1.4
PB_VERSION=9.6
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
apt-add-repository multiverse
@samacs
samacs / searchable.rb
Last active August 17, 2017 13:51
A model concern to add search capabilities to a model.
module Searchable
extend ActiveSupport::Concern
included do
scope :filtered, lambda { |values|
current = all
filters.each do |key, method|
if values.try(:key?, key)
current = current.send(method, values[key]) if
curent.respond_to?(method)
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@samacs
samacs / Installation.md
Created June 22, 2017 13:57 — forked from albertbori/Installation.md
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges
@samacs
samacs / docker-cleanup-resources.md
Created June 21, 2017 17:01 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

module CrudManagement
extend ActiveSupport::Concern
module ClassMethods
def crudify(resource_name, model_name = nil, options = {})
model_name ||= resource_name
options[:plural_name] ||= resource_name.to_s.pluralize
options[:singular_name] ||= resource_name.to_s.singularize
options[:permitted_params] ||= []
class SegmentTree
class Segment
attr_reader :range, :value
def initialize range, value
raise ArgumentError, 'Range expected, %s given' % range.class.name unless range.is_a?(Range)
@range, @value = range, value
end
#
# voipmonitor.org configuration file
#
# location of this file is at ~/.voipmonitor.conf or /etc/voipmonitor.conf
# command line parameters overrides configuration directives in this file
# allowed comments are ; or #.
#
[general]

Having the following structure:

/app
|____/config/
     |____endpoints.json
     |____/endpoints/
          |
          |____/module1/
          |    |____contacts.json

| |____agendas.json