Skip to content

Instantly share code, notes, and snippets.

View itsjavi's full-sized avatar

Javi Aguilar itsjavi

View GitHub Profile
@itsjavi
itsjavi / next-dev--open.sh
Last active November 25, 2023 03:29
Open nextjs dev server URL after start
#!/bin/bash
set -e
# Load .env file
if [ -f .env ]; then
export $(cat .env | sed 's/#.*//g' | xargs)
else
echo "No .env file found"
exit 1
@itsjavi
itsjavi / JsonEncoder.php
Last active March 5, 2021 15:43
PHP json_encode prettify compact mode with indentation level options
<?php
declare(strict_types=1);
namespace App\Support;
class JsonEncoder
{
private const JSON_PRETTY_PRINT_INDENT = 4;
@sudkumar
sudkumar / frontmatter.js
Last active September 9, 2023 17:50
MDX Remark plugin to handle frontmatter
// helps us in parsing the frontmatter from text content
const matter = require('gray-matter')
// helps us safely stringigy the frontmatter as a json object
const stringifyObject = require('stringify-object')
// helps us in getting the reading time for a given text
const readingTime = require('reading-time')
// please make sure you have installed these dependencies
// before proceeding further, or remove the require statements
// that you don't use
import Document from 'next/document'
import { ServerStyleSheet } from 'styled-components'
export default class MyDocument extends Document {
static async getInitialProps (ctx) {
const sheet = new ServerStyleSheet()
const originalRenderPage = ctx.renderPage
try {
ctx.renderPage = () =>
@ian4uh
ian4uh / PokemonForms.md
Last active January 29, 2022 03:03
Pokebank compatible Pokemon forms

Pokemon Forms Available in Pokemon Home

Gender

Ndex Pokemon Gender Gen
003 Venusaur 4
003 Venusaur 4
012 Butterfree 4
012 Butterfree 4
@itsjavi
itsjavi / service_proxy_pattern.php
Last active May 29, 2017 01:02
PHP Service Proxy + Lazy Proxy patterns
<?php
namespace Foo;
use BadMethodCallException;
use Closure;
use DomainException;
/*
* This example encapsulates before/after method call callbacks inside a the service itself, using a proxy,
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 5, 2024 16:40
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@vinzenz
vinzenz / dial-mysql-via-ssh.go
Created November 7, 2016 10:27
Using MySQL / MariaDB via SSH in Golang
package main
import (
"database/sql"
"fmt"
"net"
"os"
"github.com/go-sql-driver/mysql"
"golang.org/x/crypto/ssh"
@itsjavi
itsjavi / scriptloader.js
Last active January 25, 2023 13:07
JS ScriptLoader using ES6 Promises
/*!
* ES6 ScriptLoader snippet
* (c) Javier Aguilar mjolnic.com
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Source: https://gist.github.com/mjolnic/93cc837dd2213ec0636a
*/
window.ScriptLoader = function () {
/**
*
* @param {string} url