Skip to content

Instantly share code, notes, and snippets.

View mdogo's full-sized avatar

Manuel Dominguez mdogo

  • Doofinder
  • Madrid, Spain
View GitHub Profile
@JoeZ99
JoeZ99 / myaws_metadata.ex
Last active April 12, 2021 12:51
to get region an instance is running at
defmodule MyAws.Metadata
# AWS InstanceMetaData URL
@meta_path_region "http://169.254.169.254/latest/meta-data/placement/availability-zone"
@region_regexp ~r/(?<continent>eu|us)-(?<zone>[^-]+)-(?<number>[\d]+)/i
@doc """
Get aws region.
First, it tries with :some_app, :aws_region variable stablished in config (hopefuly using env vars), and if no
it assumes the code is running in an ec2 instance, so it tries to get the region from instance metadata.
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@sigilioso
sigilioso / psql_tmpfs.sh
Last active August 29, 2015 14:04
Posgresql in memory for testing
#!/bin/bash
set -x
service postgresql stop
TMPDIR=/tmp/tmp_psql
MOUNTPOINT=/var/lib/postgresql
mount -t tmpfs -o size=512M,nr_inodes=10k,mode=0777 tmpfs $TMPDIR
rsync --archive $MOUNTPOINT/ $TMPDIR/
mount -o bind $TMPDIR $MOUNTPOINT
service postgresql start
@sigilioso
sigilioso / pre_commit_python.py
Last active December 24, 2015 23:29
Git pre-commit: python. Look for debugger traces, check flake8 on changed code and run unit-test via external script.
#!/usr/bin/env python
import os
import sys
import re
import subprocess
from functools import partial
# Fabric requirement just for easy colour output
from fabric.colors import red, green, yellow
@jefftriplett
jefftriplett / signals.py
Last active April 1, 2016 08:43 — forked from voldmar/signals.py
Django management command to trace / list all signals. My fork is just a few cleanups where CommandError wasn't referenced, etc.
# coding:utf-8
import gc
import inspect
import weakref
from django.core.management.base import BaseCommand, CommandError
from django.dispatch import Signal, saferef
from optparse import make_option
@sigilioso
sigilioso / post-checkout.sh
Last active December 11, 2015 20:19
post-checkout hook to remove old pyc files and avoid errors
# post-checkout hook (on <path-to-project>/.git/hooks/post-checkout file)
# to avoid errors for old pyc files when checkout.
# Remember execution privileges (chmod +x <path-to-project>/.git/hooks/post-checkout).
#!/bin/bash
# Start from the repository root
cd ./$(git rev-parse --show-cdup)
# Delete pyc and empty directories
echo "[post-checkout] Deleting .pyc and empty directories"
find . -name "*.pyc" -delete
@johnantoni
johnantoni / mysql.txt
Created August 7, 2012 18:57
mysql + vagrant + remote access
username: vagrant
password: vagrant
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev
sudo aptitude install mysql-server mysql-client
sudo nano /etc/mysql/my.cnf
@heatzync
heatzync / HOWTO.md
Created May 17, 2012 10:32
HOWTO connect to a company's VPN using the Cisco VPN client on linux

HOWTO connect to a company's VPN using the Cisco VPN client on linux

Introduction

This HOWTO explains connecting to a VPN gateway over IPSec in "cert auth mode" utilizing the Cisco VPN client. The "cert auth mode" refers to the terms used in the vpnc man page, i.e. server + client certificates. The "cert auth mode" has not been implemented for vpnc, otherwise we would just use vpnc and avoid the headache that follows. openconnect is another alternative, but it does not support IPSec, only HTTPS/SSL. This HOWTO is written with the aim to provide a single document to describe all the steps required, instead of having to search many different things on the Internet.

This HOWTO was written from the perspective of an openSUSE 12.1 user, running a 3.1.10-1.9-desktop x86_64 kernel. The author does not claim to be an expert on any terms used, so if you find a mistake then please submit a patch.

Get the certificate provided by Company

@blaix
blaix / settings.py
Created April 3, 2012 19:32
Stubbing django settings with Mock
SOME_SETTING = 'some value'