Skip to content

Instantly share code, notes, and snippets.

View mariusrugan's full-sized avatar

Marius Rugan mariusrugan

View GitHub Profile
@jlecour
jlecour / post_to_slack.rb
Last active May 22, 2022 17:43
How to post alerts from Monit to Slack
# encoding: UTF-8
require 'optparse'
require 'net/http'
require 'json'
def parse_options(argv)
opts = {}
@parser = OptionParser.new do |o|
@dmccreary
dmccreary / arduino-draw-8x8-led.cpp
Last active April 18, 2025 16:04
Arduino program to draw pixels in an 8x8 LED matrix using multiplexing. This example draws "I", "Heart", "U".
/*
Display "I", "Heart", "U" on a 8 by 8 LED matrix
Dan McCreary, Feb. 14th, 2014
*/
// You can get an red LED matrix for under $5
// Here is a sample: http://www.amazon.com/Common-Anode-Diameter-Display-Matrix/dp/B00EZBZF5K/ref=pd_sim_sbs_e_1
// we are not using pins 0 and 1 and 13
// Connect pins 1-8 (bottom edge) and pins 9-16 (top edge) on the LED matrix
// to the Arduino digital outputpins 2-12 and Analog pins A0 to A3 as outputs
@mtigas
mtigas / nginx.conf
Last active March 20, 2025 14:14
Nginx configuration for securedrop.propublica.org. (Based on Ubuntu 13.10 / Nginx 1.4.1 default config.)
# This configuration file is provided on an "as is" basis,
# with no warranties or representations, and any use of it
# is at the user's own risk.
#
# You will need to edit domain name information, IP addresses for
# redirection (at the bottom), SSL certificate and key paths, and
# the "Public-Key-Pins" header. Search for any instance of "TODO".
user www-data;
worker_processes 4;
@Gaya
Gaya / fill-container-floats.css
Last active January 4, 2016 03:09
Fills container height containing floating elements without setting `overflow: hidden`.
.container:after {
content: "";
clear: both;
display: table;
}
//or as a mixin
@mixin clearfix {
&:after {
content: "";
@tobert
tobert / cassandra.service
Created December 31, 2013 22:01
A systemd unit for Cassandra
[Unit]
Description=Cassandra
After=network.target
[Service]
Type=forking
PIDFile=/var/lib/cassandra/cassandra.pid
User=cassandra
Group=cassandra
ExecStart=/usr/bin/cassandra -p /var/lib/cassandra/cassandra.pid
@plentz
plentz / nginx.conf
Last active April 19, 2025 04:46
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@matsev
matsev / CustomResponseEntityExceptionHandler.java
Last active January 16, 2023 06:04
Generic response error handling using @ControllerAdvice
@ControllerAdvice
public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
List<ObjectError> globalErrors = ex.getBindingResult().getGlobalErrors();
List<String> errors = new ArrayList<>(fieldErrors.size() + globalErrors.size());
String error;
for (FieldError fieldError : fieldErrors) {
@jahewson
jahewson / smartos-on-a-budget.sh
Last active March 9, 2024 07:27
Installing and Configuring SmartOS on a budget server (with a /29)
# Licensed under CC BY 3.0 http://creativecommons.org/licenses/by/3.0/
# Derived works must attribute https://gist.github.com/4492300 at the beginning, and the date.
##################################################################
Installing and Configuring SmartOS on a budget server (with a /29)
##################################################################
# if you find this gist useful, please star it
# please be aware that budget hosting companies usually cut corners somewhere,
@dsparks
dsparks / fanny_example.R
Created December 11, 2012 04:34
Clustering breakfast foods
doInstall <- TRUE
toInstall <- c("ggplot2", "cluster", "MASS", "smacof")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Generate a matrix of dissimilarities from pairwise correlations
data(breakfast) # Preference orderings of breakfast items, from smacof
corrMat <- cor(breakfast, use = "pair")
distMat <- dist(corrMat)
@sgergely
sgergely / gist:3793166
Created September 27, 2012 09:43
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name