Skip to content

Instantly share code, notes, and snippets.

View madalinignisca's full-sized avatar
🏡
Open for business

Madalin Ignisca madalinignisca

🏡
Open for business
View GitHub Profile
@madalinignisca
madalinignisca / Adopting SRE Principles at StackOverflow.md
Created July 9, 2019 12:15
Notes about Site Reliability Engineering

Site Reliability Practices

Ben Treynor's SREcon14 Keynote

  1. Hire only coders.
  2. Have an SLA for your service.
  3. Measure and report performance against the SLA.
  4. Use Error Budgets and gate lanches on them.
  5. Have a common staffing pool for SRE and Developers.
  6. Have excess Ops work overflow to the Dev team.
  7. Cap SRE operational load at 50 percent.
alias docker_remove_all_containers='docker rm ($docker ps -aq)'
alias force_docker_remove_all_containers='docker rm -f ($docker ps -aq)
alias docker_remove_all_unused_volumes='docker volume prune'
alias docker_remove_all_images='docker rmi $(docker images -q)'
alias force_docker_remove_all_images='docker rmi -f $(docker images -q)'
@madalinignisca
madalinignisca / jargon.md
Last active August 22, 2018 10:12
Developers Jargon
  • IIFE -- immediately invoked function expression
  • closure -- technique for implementing lexically scoped name binding in a language with first-class functions
  • transpiler, transcompiler, source-to-source compiler -- is a type of compiler that takes the source code of a program written in one programming language as its input and produces the equivalent source code in another programming language
@madalinignisca
madalinignisca / createdb.sh
Created March 8, 2018 12:38
Shell script to create a database
if [ $# -eq 0 ]
then
echo "No arguments supplied"
else
mysql -uroot --execute="CREATE DATABASE $1 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
fi
@madalinignisca
madalinignisca / docker-volume-funcs.sh
Created February 4, 2018 11:40 — forked from DALDEI/docker-volume-funcs.sh
Backup/Restore Docker Volumes
# backup files from a docker volume into /tmp/backup.tar.gz
# from http://stackoverflow.com/questions/21597463/how-to-port-data-only-volumes-from-one-host-to-another
function docker-volume-backup-compressed() {
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}"
}
# restore files from /tmp/backup.tar.gz into a docker volume
function docker-volume-restore-compressed() {
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:2}"
echo "Double checking files..."
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie ls -lh "${@:2}"
@madalinignisca
madalinignisca / solveMeFirst.c
Last active June 2, 2017 20:35
Comparison returning the sum of 2 numbers read on CLI in many programming languages (looks like JavaScript is not so friendly...)
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int solveMeFirst(int a, int b) {
return a+b;
}
int main() {
int num1,num2;
@madalinignisca
madalinignisca / count_db_rows.sql
Created April 23, 2017 09:41
Count ROWS total in a MySQL Database
SELECT SUM(TABLE_ROWS) FROM `information_schema`.`tables` WHERE `table_schema` = 'your_database_name';
@madalinignisca
madalinignisca / settings.php
Created April 21, 2017 20:59
Heroku Postgres DB for Drupal 7
<?php
// ...
# using a Heroku Postgresql DB
$heroku_db_url = parse_url($_ENV['DATABASE_URL']);
$databases['default']['default'] = array(
'driver' => 'pgsql',
'database' => substr($heroku_db_url['path'], 1),
'username' => $heroku_db_url['user'],
'password' => $heroku_db_url['pass'],
@madalinignisca
madalinignisca / .htaccess
Created January 23, 2017 19:11
Simple Apache HTTPD Expire module rules and efficient
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 year"
ExpiresByType text/html "access plus 300 seconds"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
@madalinignisca
madalinignisca / YOUR_MODULE_NAME.views.inc
Last active October 3, 2016 15:09
Load correct number of items when using Views Load More
<?php
/**
* Implements hook_views_query_alter()
*/
function views_pager_mod_views_pre_execute(&$view) {
// some data to be used
$query_params = drupal_get_query_parameters();