Skip to content

Instantly share code, notes, and snippets.

View ecasilla's full-sized avatar
🏠
Working from home

Ernie Casilla ecasilla

🏠
Working from home
  • This Crust Planet
  • Washington,DC
View GitHub Profile
##
# Creates an alias called "git hist" that outputs a nicely formatted git log.
# Usage is just like "git log"
# Examples:
# git hist
# git hist -5
# git hist <branch_name>
# git hist <tag_name> -10
##
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
@ecasilla
ecasilla / define.js
Created July 16, 2015 16:22
module definition in all envs
if (typeof module !== 'undefined' && module.exports) {
module.exports = myModule;
} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd){
// AMD. Register as an anonymous module.
define(function () {
return myModule;
});
} else {
window.myModule = myModule;
}
@ecasilla
ecasilla / clear_mongo.js
Last active December 25, 2021 20:44
Clear mongo db before mocha specs
var config = require('path/to/config');
var mongoose = require('mongose');
process.env.NODE_ENV = 'test';
before(function (done) {
function clearCollections() {
for (var collection in mongoose.connection.collections) {
mongoose.connection.collections[collection].remove(function() {});
@ecasilla
ecasilla / README-fail2ban-keycloak.md
Created October 19, 2021 17:38 — forked from thomasdarimont/README-fail2ban-keycloak.md
Use fail2ban to block brute-force attacks to keycloak server. #keycloak #fail2ban #brute-force-attack

Add regular-expression filter under /etc/fail2ban/filter.d/keycloak.conf:

[INCLUDES]

before = common.conf

[Definition]

_threadName = [a-z][-_0-9a-z]*(\s[a-z][-_0-9a-z]*)*
_userId = (null|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})
@ecasilla
ecasilla / DynamicOtpFormAuthenticator.java
Created October 19, 2021 14:15 — forked from thomasdarimont/DynamicOtpFormAuthenticator.java
Dynamic OTP Validation support for Keycloak 1.7.x
package org.keycloak.authentication.authenticators.browser;
import org.keycloak.authentication.AuthenticationFlowContext;
import org.keycloak.models.*;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.util.*;
import java.util.regex.Pattern;
@ecasilla
ecasilla / private_fork.md
Created July 15, 2020 04:23 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

const input = {
x: 'hello world',
y: 2,
f: true,
z: {
a: [1,2,3],
b: new Set([1,2,3]),
c: new Map([['hello', 'world']]),
d: null,
e: undefined
@ecasilla
ecasilla / hex2rgb.js
Last active October 1, 2019 19:30
Hex2Rgb.js
function hex (hex){
if(/^#/.test(hex)){
hex = hex.slice(1);
}
if(hex.length !== 3 && hex.length !== 6 ){
throw new Error("Invaild hex String");
}
var digit = hex.split("");
@ecasilla
ecasilla / cloudSettings
Last active July 15, 2019 16:05
Vscode Settings
{"lastUpload":"2019-07-15T16:05:26.337Z","extensionVersion":"v3.4.0"}
@ecasilla
ecasilla / calculator.js
Created September 22, 2015 03:38
Awesome Calculator
function Calculator() {}
function reduceArgs(operation) {
return function() {
var args = Array.prototype.slice.call(arguments);
var ops = {
'+': function(x, y) {
return x + y;
},
'-': function(x, y) {