Skip to content

Instantly share code, notes, and snippets.

View daronco's full-sized avatar

Leonardo C. Daronco daronco

View GitHub Profile
@daronco
daronco / resque-prestop.sh
Created July 14, 2022 14:11
A script to be used as a preStop hook on kubernetes for resque workers
#!/bin/bash
# This script issues a SIGQUIT to the resque worker and waits for all jobs
# (forked processes) to be finished before exiting. To be used as a preStop hook
# for resque processes on Kubernetes.
# Kubernetes by default issues a SIGTERM when terminating a pod, but that causes
# resque to immediately kill child processes and then exit. A SIGQUIT tells resque
# to wait for child to finish before exiting.
# Set `terminationGracePeriodSeconds` to the number of seconds to wait before
# ignoring this preStop script and forcing the pod to terminate.
@daronco
daronco / solution.md
Last active October 14, 2020 15:10
Dependency errors trying to install aptitude on Ubuntu 18.04 on DigitalOcean

Got the following errors trying to install aptitude on a clean Ubuntu 18.04 on DigitalOcean:

$ sudo apt install aptitude

The following packages have unmet dependencies:
 aptitude : Depends: libapt-pkg6.0 (>= 1.9.11~) but it is not installable
            Depends: libboost-iostreams1.71.0 but it is not installable
            Depends: libcwidget4 (>= 0.5.18-1) but it is not going to be installed
 Depends: libgcc-s1 (>= 3.0) but it is not installable
MOODLE_HOME="/var/www/moodle"
MOODLE_DATA="/var/www/moodle/moodledata"
sudo mkdir -p $MOODLE_DATA/lang/pt_br
cd $MOODLE_HOME
sudo wget https://github.com/mconf/moodle-mod_bigbluebuttonbn/archive/v2.2-elos.zip
sudo unzip v2.2-elos.zip
sudo mv moodle-mod_bigbluebuttonbn-2.2-elos mod/bigbluebuttonbn
cp mod/bigbluebuttonbn/lang/pt_br/bigbluebuttonbn.php $MOODLE_DATA/lang/pt_br/bigbluebuttonbn.php
@daronco
daronco / letsencrypt-webroot-apache.md
Last active February 15, 2024 11:50
Letsencrypt with webroot on Apache

Config Apache with /etc/apache2/conf-available/le.conf:

Alias /.well-known/acme-challenge/ "/var/www/html/.well-known/acme-challenge/"
<Directory "/var/www/html/">
    AllowOverride None
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>
@daronco
daronco / gist:95042bca628fb6924286
Last active August 29, 2015 14:13
Using setConfigXML in the API Mate
  • Access the API Mate: http://mconf.github.io/api-mate/
  • Create a new meeting.
  • Join this meeting to make sure it won't be removed from the server in case you take too long to run the other steps.
  • Use getDefaultConfigXML via GET to get the default config.xml.
  • Copy and paste this config.xml into a new file. Edit it to remove any special characters (e.g. you might have HTML tags in the copyright field, so you have to remove or escape them).
  • Edit your config.xml according to your needs.
  • Put the edited XML content in the "XML for setConfigXML via POST" field in the API Mate.
  • Instead of using the API Mate to call setConfigXML (don't just click in the link), use another tool that runs outside of the browser. curl is a good option. First, copy the link the API Mate generated to setConfigXML. It will be a really long URL. Then use it with curl (replace <link> by the URL):
@daronco
daronco / have_attr_accessor.rb
Created November 23, 2012 00:13
Shoulda matcher have_attr_accessor
# Ensures the model has an attr_accessor, attr_reader or attr_writer
# Examples:
# it { should have_attr_accessor(:value) }
# it { should have_attr_accessor(:value).read_only }
# it { should have_attr_accessor(:value).write_only }
module Shoulda
module Matchers
module ActiveModel # :nodoc
def have_attr_accessor(attribute)
@daronco
daronco / README
Created January 19, 2012 13:31
Organize javascripts and stylesheets like views in rails 3.1
Call the helpers 'javascript_include_tags_for_action' and 'stylesheet_link_tags_for_action' in the headers section
of your layout to automatically include javascript and stylesheet files for the current controller and action.
The files are included only if they exist. It is first included the file for all the actions of acontroller (e.g 'events/_all.js')
and then the file for the current action (e.g. 'events/show.js').
You can organize javascripts and stylesheets like views are organized.
Assuming you have the controllers "Events" and "Spaces":
- app/
@daronco
daronco / restart_file_touched.rb
Created January 17, 2012 18:13 — forked from technicalpickles/restart_file_touched.rb
A custom condition for God that checks for change in a file (usually tmp/restart.txt)
module God
module Conditions
class RestartFileTouched < PollCondition
attr_accessor :restart_file
def initialize
super
end
def process_start_time
Time.parse(`ps -o lstart -p #{self.watch.pid} --no-heading`)