Skip to content

Instantly share code, notes, and snippets.

Genar Trias Ortiz gtrias

View GitHub Profile
View gist:5f709ce8674d7437b4715d3623334555
find ./db/migrate/* | xargs sed -i 's/create_table [^ ]*/&, :options => "ENGINE=MEMORY"/'
@gtrias
gtrias / Component.jsx
Created Oct 1, 2018 — forked from krambertech/Component.jsx
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
View Component.jsx
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
super();
@gtrias
gtrias / beep-starwars
Created Jul 18, 2017 — forked from tong/beep-starwars
PC speaker star wars vader theme
View beep-starwars
#!/bin/bash
beep -l 350 -f 392 -D 100 --new -l 350 -f 392 -D 100 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 700 -f 392 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 250 -f 622.26 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 350 -f 369.99 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 700 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 392 -D 100 --new -l 25 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 739.98 -D 100 --new -l 25 -f 698.46 -D 100 --new -l 25 -f 659.26 -D 100 --new -l 25 -f 622.26 -D 100 --new -l 50 -f 659.26 -D 400 --new -l 25 -f 415.3 -D 200 --new -l 350 -f 554.36 -D 100 --new -l 250 -f 523.25 -D 100 --new -l 25 -f 493.88 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 25 -f 440 -D 100 --new -l 50 -f 466.16 -D 400 --new -l 25 -f 311.13 -D 200 --new -l 350 -f 369
@gtrias
gtrias / gpg-import-and-export-instructions.md
Created Mar 30, 2017 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys
View gpg-import-and-export-instructions.md

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/
# or, instead of backing up trustdb...
@gtrias
gtrias / Instructions.md
Created Jul 28, 2016 — forked from shreyu86/Instructions.md
Route Docker Logs to ELK Stack
View Instructions.md
  • With Docker 1.8.0 shipped new log-driver for GELF via UDP, this means that the logs from Docker Container(s) can be shipped directly to the ELK stack for further analysis.
  • This tutorial will illustrate how to use the GELF log-driver with Docker engine.
  • Step 1: Setup ELK Stack:
    • docker run -d --name es elasticsearch
    • docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
    • Note the config for Logstash can be found at this link
    • docker run --link es:elasticsearch -d kibana
  • Once the ELK stack is up now let's fire up our nginx container which ships its logs to ELK stack.
  • LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
  • `docker run -d --net=host --log-driver=gelf --log-opt gelf-address=u
@gtrias
gtrias / AppKernel.php
Created Jan 18, 2016 — forked from K-Phoen/AppKernel.php
Functional tests for standalone Symfony2 bundles
View AppKernel.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
return array(
@gtrias
gtrias / request-array-parameter-to-dict.py
Created Jan 11, 2016
Convert array parameter whatever[index] to dict
View request-array-parameter-to-dict.py
def multiarraytodict(listname):
from flask import request
options = dict()
for key, value in request.form.items():
if key[:len(listname)] == listname:
options[key[len(listname)+1:-1]] = value
return options
@gtrias
gtrias / docker-clean.sh
Created Jan 10, 2016
Docker cleaning unused containers
View docker-clean.sh
docker rm `docker ps -a | grep Exited | awk '{print $1 }'`
docker rmi `docker images -aq`
@gtrias
gtrias / docker_get_host_ip.sh
Last active Dec 22, 2015
Get the docker host IP from a container
View docker_get_host_ip.sh
# Source http://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container
/sbin/ip route|awk '/default/ { print $3 }'
@gtrias
gtrias / ionic-load-screen-main.js
Created Nov 17, 2015
Ionic loading screen intercepting http calls
View ionic-load-screen-main.js
// Ionic loading page
.run(function ($rootScope, $ionicLoading) {
$rootScope.$on('loading:show', function() {
$ionicLoading.show({template: 'foo'});
});
$rootScope.$on('loading:hide', function() {
$ionicLoading.hide();
});
})
You can’t perform that action at this time.