Skip to content

Instantly share code, notes, and snippets.

View JonatanFlores's full-sized avatar

Jonatan Flores JonatanFlores

View GitHub Profile
@JonatanFlores
JonatanFlores / example.com.import.txt
Created October 24, 2022 00:44 — forked from epicserve/example.com.import.txt
Example Terraform file for importing DNS Records from DigitalOcean
digitalocean_domain.example example.com
digitalocean_record.example example.com,<DO ID>
digitalocean_record.fd-gmail-txt example.com,<DO ID>
digitalocean_record.fd-mx["alt1.aspmx.l.google.com."] example.com,<DO ID>
digitalocean_record.fd-mx["alt2.aspmx.l.google.com."] example.com,<DO ID>
digitalocean_record.fd-mx["aspmx.l.google.com."] example.com,<DO ID>
digitalocean_record.fd-mx["aspmx2.googlemail.com."] example.com,<DO ID>
digitalocean_record.fd-mx["aspmx3.googlemail.com."] example.com,<DO ID>
digitalocean_record.fd-ns["1"] example.com,<DO ID>
digitalocean_record.fd-ns["2"] example.com,<DO ID>
@JonatanFlores
JonatanFlores / submit.md
Created December 7, 2021 03:07 — forked from tanaikech/submit.md
Transposing Slice From (n x m) To (m x n) for golang

Transposing Slice From (n x m) To (m x n) for golang

This is a sample script for transposing slice from (n x m) to (m x n) for golang.

Script :

package main

import "fmt"

func transpose(slice [][]string) [][]string {

Useful Git commands

This is just stuff that I have put down that I find I use a lot of the time for my own reference.

Latest changes from repo to your machine

$ git pull
@JonatanFlores
JonatanFlores / group-objects-by-property.md
Created September 24, 2021 02:43 — forked from mikaello/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group array of JavaScript objects by keys

This fork of JamieMason's implementation changes the key parameter to be an array of keys instead of just a single key. This makes it possible to group by multiple properties instead of just one.

Implementation

const groupBy = keys => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = keys.map(key => obj[key]).join('-');
@JonatanFlores
JonatanFlores / jsUtility.js
Created August 21, 2021 19:58 — forked from btspoony/jsUtility.js
Some JS Utility functions
var __sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? __sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? __sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? __sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? __sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? __sys.safari = s[1] : 0;
function typeofUndefined(value) {
@JonatanFlores
JonatanFlores / node_nginx_ssl.md
Created September 24, 2019 19:02 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to Digital Ocean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@JonatanFlores
JonatanFlores / Config.php
Created September 6, 2019 14:25 — forked from treffynnon/Config.php
A PHP class to access a PHP array via dot notation
<?php
namespace Treffynnon;
/**
* A PHP class to access a PHP array via dot notation
* (Agavi http://www.agavi.org was the inspiration).
*
* This was hacked in to an existing codebase hence the
* global config array variable.
@JonatanFlores
JonatanFlores / varexport.php
Last active May 6, 2019 18:00
PHP var_export() with short array syntax (square brackets) indented 4 spaces
<?php
function varexport($expression, $return=FALSE) {
$export = var_export($expression, TRUE);
$export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export);
$array = preg_split("/\r\n|\n|\r/", $export);
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array);
$export = join(PHP_EOL, array_filter(["["] + $array));
$export = preg_replace('(\d+\s=>\s)', '', $export); // REMOVE THE NUMERIC INDEXES
if ((bool)$return) return $export; else echo $export;
}
@JonatanFlores
JonatanFlores / magic-methods.js
Created April 25, 2019 16:13 — forked from loilo/magic-methods.js
PHP Magic Methods in JavaScript
function magicMethods (clazz) {
// A toggle switch for the __isset method
// Needed to control "prop in instance" inside of getters
let issetEnabled = true
const classHandler = Object.create(null)
// Trap for class instantiation
classHandler.construct = (target, args) => {
// Wrapped class instance
@JonatanFlores
JonatanFlores / git-tag-delete-local-and-remote.sh
Created March 24, 2019 20:36 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName