Skip to content

Instantly share code, notes, and snippets.

View tzkmx's full-sized avatar
🎉
estrenando repositorios privados

Jesus Franco tzkmx

🎉
estrenando repositorios privados
View GitHub Profile
@tzkmx
tzkmx / script.sh
Created December 9, 2021 07:46
Split commits with git rebase
## Source: https://emmanuelbernard.com/blog/2014/04/14/split-a-commit-in-two-with-git/
### Split a commit in two for the busy onesPermalink
### Let’s see the sequence first before explaining it
git rebase -i <oldsha1>
# mark the expected commit as `edit` (replace pick in front of the line), save and close
git reset HEAD^
git add ...
git commit -m "First part"
# Random string based on /dev/urandom
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1
dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev
@tzkmx
tzkmx / create_user_functions.js
Created November 27, 2021 07:51 — forked from katowulf/create_user_functions.js
Create a Firebase user from an authenticated Cloud Functions HTTPS endpoint.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const express = require('express');
const cookieParser = require('cookie-parser')();
const cors = require('cors')({origin: true});
const app = express();
// See https://github.com/firebase/functions-samples/blob/Node-8/authorized-https-endpoint/functions/index.js
const validateFirebaseIdToken = require('./validateFirebaseIdToken');
@tzkmx
tzkmx / app-navigation-tree.json
Last active June 23, 2023 02:25
App Navigation Tree JSON Schema
{
"$id": "https://gist.githubusercontent.com/tzkmx/0b31897ea96fb3e36f8debdc050121b9/raw/bdda2e9b636d1130e4000d6c829113d62c4bcd4c/app-navigation-tree.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "App Contents Navigation Manifest",
"description": "A blueprint for application navigation",
"properties": {
"home": {
"description": "First screen interactive for users (after authentication flow if required)",
"type": "object",
"properties": {
@tzkmx
tzkmx / attention.md
Last active July 13, 2021 22:12
Test branch path on Request URI

El universo se disolverá en un mar de entropía infinita tibia

No se necesita duplicar todo un script de PHP para solo comentar una funcion que no queremos que se llame.

@tzkmx
tzkmx / HashSha256UploadedFileMacro.php
Last active July 10, 2021 05:50
Custom Upload of Avatar in Nova
<?php
// put this in AppServiceProvider::register to make the hash of the filename
// correspond to the SHA256 of the *CONTENTS* of the UploadedFile automatically
UploadedFile::macro('setHash', function () {
/** @var UploadedFile $this */
$this->hashName = hash_file('sha256',
$this->getRealPath(), false);
});
@tzkmx
tzkmx / fix_offset_datetime.sql
Last active July 29, 2021 19:29
Trigger to fix datetime offset in Laravel Nova
CREATE OR
ALTER PROCEDURE assets.sp_webinar_fix_utc_date @webinar_id BIGINT
AS
BEGIN
DECLARE @fixed_start_date DATETIMEOFFSET;
DECLARE @fixed_end_date DATETIMEOFFSET;
SET @fixed_start_date = (SELECT DATEADD(hh, 5, start_date) AT TIME ZONE 'Central Standard Time'
FROM assets.webinars
WHERE id = @webinar_id);
SET @fixed_end_date = (SELECT DATEADD(hh, 5, end_date) AT TIME ZONE 'Central Standard Time'
<?php
namespace App\Enums;
use BenSampo\Enum\Enum;
final class HttpStatusCode extends Enum
{
const Continue = 100;
const SwitchingProtocols = 101;
@tzkmx
tzkmx / passwordless-login.php
Last active June 11, 2021 21:22
basic passwordless login wordpress
<?php
require __DIR__ . '/../wp-load.php';
// si envías token, antes de esta línea tendrías que validar que el token es vigente, y de ahí obtener el token del usuario directo
if(!isset($_POST['email'])) {
$email = $_POST['email'];
}
$user = get_user_by('login', $email);
if (is_null($user)) {
invalidAuth();
@tzkmx
tzkmx / .js
Created March 11, 2021 01:15 — forked from dusterio/.js
Decrypting Laravel's session cookie with JavaScript and Cloudflare
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const string2buffer = string => {
let tempArray = new Uint8Array(string.length)
for(let i = string.length; i--) tempArray[i] = string.charCodeAt(i)
return tempArray.buffer
}