Skip to content

Instantly share code, notes, and snippets.

View antonioaguilar's full-sized avatar

Antonio Aguilar antonioaguilar

View GitHub Profile
@antonioaguilar
antonioaguilar / README.md
Created August 3, 2023 21:17 — forked from claytonrcarter/README.md
Bash script to check GitLab pipeline status

A super simple bash script to check the status of a GitLab CI pipeline.

$ git push
...
$ git pipeline-status
Status of last pipeline for user/project on gitlab/master:
"pending"
...
$ git pipeline-status
@antonioaguilar
antonioaguilar / db_backup.sh
Created March 25, 2023 21:36 — forked from lucaswilric/db_backup.sh
Back up, compress and encrypt a small MySQL or PostgreSQL database.
#!/bin/bash
# This script dumps a database to SQL, compresses, encrypts and timestamps it, then saves it to Dropbox. Ideal for a cronjob.
# It uses symmetric encryption, so guard your password carefully.
#
# NOT RECOMMENDED FOR LARGE DATABASES!
# Dump a MySQL database
# Read this for how to get your password into mysqldump:
# https://dev.mysql.com/doc/refman/5.1/en/password-security-user.html
mysqldump -u username > database.sql
@antonioaguilar
antonioaguilar / README.md
Created March 23, 2023 05:37 — forked from obscurerichard/README.md
Simulates a low bandwidth, high-latency network connection

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency
slow dsl -b 1mbps         # Simulate DSL with a slower speed than the default

slow modem-56k -d eth0 # Simulate a 56k modem on the eth1 device. eth0 is unchanged.

@antonioaguilar
antonioaguilar / sql-mixin.md
Created October 12, 2021 11:53 — forked from rgbkrk/sql-mixin.md
Turning lodash into declarative SQL

Lodash has a sweet feature called a mixin that lets you alias function names. Below here I alias names that we're used to using in SQL to (roughly) equivalent functions in lodash.

_.mixin({
  select: _.map,
  from: _.chain,
  where: _.filter,
  groupBy: _.sortByOrder,
})
@antonioaguilar
antonioaguilar / nginx-tuning.md
Created January 18, 2021 09:24 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@antonioaguilar
antonioaguilar / event-aggregator.js
Created October 31, 2019 20:40
Simple event aggregator using Lodash
const _ = require('lodash');
const colors = require('colors/safe');
const EventEmitter = require('events').EventEmitter;
const ev = new EventEmitter();
const predicate = ['q3', 'q6', 'q9'];
let agg = {};
@antonioaguilar
antonioaguilar / obfuscate.js
Created September 18, 2019 09:50 — forked from olastor/obfuscate.js
Simple algorithm to quickly obfuscate a string in javascript.
/**
* Obfuscate a plaintext string with a simple rotation algorithm similar to
* the rot13 cipher.
* @param {[type]} key rotation index between 0 and n
* @param {Number} n maximum char that will be affected by the algorithm
* @return {[type]} obfuscated string
*/
String.prototype.obfs = function(key, n = 126) {
// return String itself if the given parameters are invalid
if (!(typeof(key) === 'number' && key % 1 === 0)
@antonioaguilar
antonioaguilar / zigzag-encoding.README
Created July 20, 2019 22:07 — forked from mfuerstenau/zigzag-encoding.README
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation
@antonioaguilar
antonioaguilar / superagent.js
Created December 3, 2018 13:45 — forked from pherris/superagent.js
Jest superagent mock
'use strict';
//mock for superagent - __mocks__/superagent.js
var mockDelay;
var mockError;
var mockResponse = {
status() {
return 200;
},
@antonioaguilar
antonioaguilar / GitConfigHttpProxy.md
Created July 25, 2018 00:21 — forked from evantoli/GitConfigHttpProxy.md
Configure Git to use a proxy

Configure Git to use a proxy

##In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like: