Skip to content

Instantly share code, notes, and snippets.

View fullofcaffeine's full-sized avatar

Marcelo Serpa fullofcaffeine

View GitHub Profile
@vlucas
vlucas / markdown-import.php
Last active May 19, 2024 17:58
Imports Markdown files in a local directory into a WordPress installation
<?php
// Turn on all error reporting so we can see if anything goes wrong
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
// Relative path to your wp-config.php file (to connect to the database)
require '../wp-config.php';
require './frontmatter.php'; // Parses YAML frontmatter - https://github.com/Modularr/YAML-FrontMatter
require './Parsedown.php'; // Markdown parser - https://github.com/erusev/parsedown
@shawnsi
shawnsi / README.md
Last active March 24, 2025 10:37
Ansible Vault Environment Variable

Ansible Vault Environment Variable

Per http://docs.ansible.com/ansible/playbooks_vault.html you can set an environment variable to use a password file for vault access. We can use this to create an environment variable to hold the password.

Password Script

Copy vault-env from this project to ~/bin. Then add this to your ~/.bashrc:

export ANSIBLE_VAULT_PASSWORD_FILE=~/bin/vault-env
var scrollPosition = sessionStorage.getItem("scrollPosition")
if(scrollPosition) window.scrollTo(0, scrollPosition)
document.addEventListener("scroll", function() {
sessionStorage.setItem("scrollPosition", window.pageYOffset | document.body.scrollTop)
})
@ygotthilf
ygotthilf / jwtRS256.sh
Last active May 12, 2025 12:07
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
import haxe.Constraints.Function;
@:pythonImport("flask", "Flask")
extern class Flask {
function new(module:String);
function run():Void;
function route<T:Function>(path:String):T->T;
}
class Main {
@obfusk
obfusk / break.py
Last active December 7, 2024 13:12
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@phrawzty
phrawzty / 2serv.py
Last active January 16, 2025 08:46
simple python http server to dump request headers
#!/usr/bin/env python2
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
@benjamingr
benjamingr / gist:0237932cee84712951a2
Last active October 6, 2023 08:31
Promise unhandled rejection tracking global handler hook

Possibly Unhandled Rejection NodeJS Promise Hook

###Unhandled Rejection Tracking

Several promise libraries such as bluebird and when as well as some native promise implementations offer potentially unhandled rejection tracking. This means that the following:

Promise.reject(new Error("err")); // never attach a `catch`
@Warry
Warry / propMap.elm
Last active November 19, 2019 04:15
Convert a List of objects into a Dict (≈ Map) using an object's property as key, in a type safe way with ELM
import Dict
-- The transformation function
listToDict : (a -> comparable) -> [a] -> Dict.Dict comparable a
listToDict getKey values = Dict.fromList (map (\v -> (getKey v, v)) values)
-- Demo type
type FooBar =
{ foo : String
, bar : Int
@skial
skial / Builder.hx
Last active October 3, 2017 14:47
Code exercise while my internet was down for the safe navigation operator from AS3 started by this Haxe mailing list thread https://groups.google.com/forum/#!topic/haxelang/Rrj9AUbXGuA using Haxe 3.2.0 (git build development @ 3a255a8).
package ;
import haxe.macro.*;
import haxe.macro.Expr.ComplexType;
using haxe.macro.ExprTools;
/**
* ...
* @author Skial Bainn
*/