Skip to content

Instantly share code, notes, and snippets.

View twoixter's full-sized avatar

Jose Miguel Pérez twoixter

View GitHub Profile
@twoixter
twoixter / color_streams.h
Created September 29, 2011 17:33
Colorize output streams with ANSI color codes
/*
* Copyright (c) 2011 Jose Miguel Pérez, Twoixter S.L.
*
* Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@twoixter
twoixter / gist:1711769
Created January 31, 2012 17:37
PHP Code to Tidy up PHP output
<?
ob_start();
$__tidy = true;
?>
<body>
<p>this is
a test,
is a
test
@twoixter
twoixter / ssltips.md
Created July 4, 2012 00:16
Nginx SSL and OpenSSL command tips

Generación de claves

Generar en un sólo paso, clave privada (con o sin passphrase) y CSR:

$ openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

Generar clave privada, con password y clave de 4096 bits

$ openssl genrsa -des3 -out example.com_secure.key 4096
@twoixter
twoixter / gist:3222552
Created August 1, 2012 01:42
Disable Smooth Scrooling in Mountain Lion+ to fix weird TextMate scroll
defaults write -g NSScrollAnimationEnabled -bool NO
@twoixter
twoixter / gist:5719133
Created June 6, 2013 03:33
CMake config lines to include GTest as source un Ubuntu
add_subdirectory( /usr/src/gtest ${PROJECT_BUILD_OUTPUT}/gtest )
include_directories( "/usr/include/gtest" )
target_link_libraries( test_executable ${TEST_SOURCES} gtest gtest_main pthread )
@twoixter
twoixter / compile_gtest.sh
Created June 6, 2013 03:41
Compile GTest on Ubuntu
cd $(mktemp -d)
cmake /usr/src/gtest
make
sudo mv libgtest.a /usr/lib/
sudo mv libgtest_main.a /usr/lib
@twoixter
twoixter / DefaultKeyBinding.dict
Created October 14, 2013 22:49
Fix the Home and End keys on Mac OS X
{
/* Put this file in ~/Library/KeyBindings/DefaultKeyBinding.dict */
/* Remap Home / End keys to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
@twoixter
twoixter / pjsc2har.js
Created September 22, 2016 19:20
Proof of concept of a filter node.js script to convert PhantomJSCloud JSON events to HAR
#!/usr/bin/env node
/**
* Script to convert PhantomJSCloud JSON output to HAR.
* See: https://phantomjscloud.com
*
* Usage: pipe in the JSON from PhantomJSCloud and pipe out to a file.
* Be sure to use the following options when using PhantomJSCloud:
*
* + outputAsJson = true To force JSON output
@twoixter
twoixter / envsubst.consul.sh
Last active August 13, 2024 16:56
Consul watch script to use templates with envsubst
#!/bin/bash
# This bash script handles input from Consul Watch (JSON) in order to be able
# to use "envsubst" to fill arbitrary file templates. It handles both single
# as well as multi-object inputs. E.G: JSON strings like "{ object }" or
# "[ {}, {}, array of objects ]".
#
# Usage:
# - Object JSON from Consul comes from standard input.
# - You must provide a file template from which ENV substitution will be made.
@twoixter
twoixter / update-certs.consul.sh
Created September 24, 2024 19:22
Consul watch script to update certificates based on a key prefix
#!/bin/bash
# This bash script handles input from consul 'watch' for keys holding
# certificates in PEM format. For this to correctly handle certificates
# the Consul key **MUST** have the following schema:
#
# certificates/<Domain Name>/<Filename>
#
# For example, this is how we handle keys for Consul server certificates:
#