Skip to content

Instantly share code, notes, and snippets.

@jmlrt
jmlrt / backdup.rake
Last active August 29, 2015 14:21
Duplicity Rakefile
# Rakefile
# Use env.rb for environment variables
require "./env"
# Duplicity command
$cmd = "/usr/local/bin/duplicity --ssh-options=\"-oIdentityFile=#{$keyfile}\""
# Print message
def msg(task, dir)
msg = "*** #{task.upcase} - #{dir.upcase} ***"
@jmlrt
jmlrt / gemrepo.rake
Last active August 29, 2015 14:21
Gem Web server Rakefile
# Rakefile
# use web.rb to run web server
task generate: [:clean] do
sh "gem generate_index --no-modern -d ."
end
task :clean do
sh "rm -fr latest_specs.4.8* prerelease_specs.4.8* quick specs.4.8*"
end
@jmlrt
jmlrt / dotfile.rake
Last active July 22, 2023 07:44
Dotfiles Rakefile
require 'date'
date = DateTime.now.strftime("%Y%m%d%H%M")
$homedir = Dir.home
$dotfiles = [ '.bash_profile', '.bashrc', '.gitconfig', '.kshrc', '.profile', '.tmux.conf', '.vimrc' ]
desc "backup dotfiles"
task :backup do |t|
backupdir = File.join($homedir,"/",t.name)
backupfile = "dotfiles-home.#{date}.tar"
#!/bin/sh
#
# source: http://www.macgasm.net/2013/01/18/good-morning-your-mac-keeps-a-log-of-all-your-downloads/
#.
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'.
@jmlrt
jmlrt / docker-compose.yml
Created February 18, 2016 07:22
MongoDB Replica Set with Docker
version: '2'
services:
mongo1:
container_name: mongo1
image: mongo:2.4
expose:
- 27017
networks:
- mongo
command: mongod --replSet rs0 --smallfiles --oplogSize 128
@jmlrt
jmlrt / salt-bootstrap.sh
Created March 28, 2016 21:59
deploy ssh keys, configure sudo and install salt on new debian server
#!/bin/sh
#
# deploy ssh keys, configure sudo and install salt on new debian server
# require config file .myenv with variables MYUSER and SSHPUBKEY
source_my_env()
{
if [ -f ${MYENV} ]
then
. ${MYENV}
---
- hosts: ansible
vars:
local_user: {{ user }}
ansible_private_key: ansible.pem
ansible_public_key: ansible.pub
become: yes
tasks:
- name: ensure ansible and passlib are installed
@jmlrt
jmlrt / fabfile.py
Created September 9, 2016 05:53
Fabfile sample using require function
from fabric.api import *
def is_local():
if env.host == 'localhost':
env.lrun = local
else:
env.lrun = run
print('host %(host)s using function %(lrun)s' % env)
@jmlrt
jmlrt / gdrive_upload_folder.py
Last active October 18, 2023 22:14
Python script to upload folder to Google Drive
# -*- coding: utf-8 -*-
"""
Upload folder to Google Drive
"""
# Enable Python3 compatibility
from __future__ import (unicode_literals, absolute_import, print_function,
division)
import com.ifountain.opsgenie.client.http.OpsGenieHttpClient
import com.ifountain.opsgenie.client.util.ClientConfiguration
import com.ifountain.opsgenie.client.util.JsonUtils
import org.apache.http.HttpHeaders
import org.apache.http.auth.UsernamePasswordCredentials
import org.apache.http.impl.auth.BasicScheme
LOG_PREFIX = "[${action}]:";
logger.warn("${LOG_PREFIX} Will execute action for alertId ${alert.alertId}");