Skip to content

Instantly share code, notes, and snippets.

View rilian's full-sized avatar

rilian rilian

View GitHub Profile
@rilian
rilian / slackpost
Created February 20, 2018 14:05 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@rilian
rilian / gist:12dcdaded69b5cd26ccf204188c3c6d9
Created July 17, 2017 10:00 — forked from stiucsib86/gist:ebff282a3989f9a24117
Backup MySQL dump to Azure Storage
#!/bin/sh
mkdir /home/bitnami/backups/
export BACKUP_FILE=/home/bitnami/backups/db-backup.sql.gz
export DATABASE_SCHEMA_NAME=--all-databases
export AZURE_CONTAINER=YOUR_VALUE_HERE
export AZURE_NAME=YOUR_VALUE_HERE
export AZURE_KEY=YOUR_VALUE_HERE
export AZURE_BLOB_NAME=db-production-$(date +%Y%m%d%H%M%S).sql.gz
@rilian
rilian / count.gs
Last active June 22, 2017 09:30
count cells by color in google excel rows
/**
* based on a work of
* https://webapps.stackexchange.com/questions/50511/pass-range-in-google-apps-script-custom-function-without-using-a1-notation
*
* Counts cell values in a range if they have the given background color
* =countByColor("A5", ROW(A5))
*
* @param {String} cell reference to get color
* @param {int} startrow reference to the row to calculate count
* @return {int} Count of all cell values matching the condition
@rilian
rilian / non_digest.rake
Created June 6, 2017 13:47
copy-non-digest-assets.txt
task non_digested: :environment do
assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*'))
regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/
assets.each do |file|
next if File.directory?(file) || file !~ regex
source = file.split('/')
source.push(source.pop.gsub(regex, '.'))
non_digested = File.join(source)
@rilian
rilian / connection-fix-for-azure.txt
Last active May 22, 2017 14:32
connection fix for Azure
# Display the current tcp_keepalive_time value.
$ cat /proc/sys/net/ipv4/tcp_keepalive_time
# Set tcp_keepalive_time to 60 seconds and make it permanent across reboots.
$ echo 'net.ipv4.tcp_keepalive_time = 60' | sudo tee -a /etc/sysctl.conf
# Apply the change.
$ sudo /sbin/sysctl --load=/etc/sysctl.conf
# Display the tcp_keepalive_time value to verify the change was applied.
@rilian
rilian / config-environments-test.rb
Last active October 5, 2019 07:49 — forked from keithtom/no_animations.rb
Rack Middleware to disable Disable CSS3/jQuery Animations for Capybara
Rails.application.configure do
# ...
require_relative '../../spec/support/no_animations'
config.middleware.use Rack::NoAnimations
end
@rilian
rilian / slack_delete.rb
Created September 29, 2016 12:52 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@rilian
rilian / pg-setup.sh
Created September 22, 2016 14:15
install pg 9.5 on semaphore
#!/usr/bin/env bash
set -e
pg_version=${1:-'9.5'}
echo "Installing PostgreSQL version: $pg_version"
sudo apt-get update -q
sudo apt-get -y install postgresql-client-$pg_version postgresql-$pg_version postgresql-contrib-$pg_version postgresql-server-dev-$pg_version libpq-dev postgresql-$pg_version-postgis-2.2
@rilian
rilian / ransack and or.txt
Last active September 8, 2016 15:35
ransack and or
https://github.com/activerecord-hackery/ransack/issues/169
https://github.com/activerecord-hackery/ransack/issues/211
https://github.com/activerecord-hackery/ransack/issues/218
https://github.com/activerecord-hackery/ransack/issues/219
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//