Skip to content

Instantly share code, notes, and snippets.

View rhamses's full-sized avatar

Rhamses rhamses

View GitHub Profile
@ogiovannyoliveira
ogiovannyoliveira / makeSlug.ts
Last active November 26, 2023 04:29
Make a slug from string
function makeSlug(value: string, separator?: string = '_'): string {
const mapAccentsHex: any = {
a : /[\xE0-\xE6]/g,
A : /[\xC0-\xC6]/g,
e : /[\xE8-\xEB]/g,
E : /[\xC8-\xCB]/g,
i : /[\xEC-\xEF]/g,
I : /[\xCC-\xCF]/g,
o : /[\xF2-\xF6]/g,
O : /[\xD2-\xD6]/g,
@smashah
smashah / remove_silence.ts
Last active June 3, 2024 08:24
A simple way to remove silences below a certain threshold in an audio file [NODEJS/TS]
//add this to your package.json
// "audio-buffer-utils": "^5.1.2",
// "audio-decode": "^1.4.0",
// "audiobuffer-to-wav": "^1.0.0",
// "node-lame": "^1.2.0",
// "ogg.js": "^0.1.0",
// "opus.js": "^0.1.1",
const fs = require('fs');
@esamattis
esamattis / graphql.php
Last active May 11, 2020 10:43
wp-graphql cache
<?php
// UPDATE! Checkout this plugin https://github.com/valu-digital/wp-graphql-cache
// Requires some persistent object cache such as wp-redis.
define( 'WP_GRAPHQL_CACHE_AGE', 10 ); // in seconds
add_action( 'do_graphql_request', function () {
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active July 20, 2024 14:39
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
@amrza
amrza / run.py
Last active July 8, 2024 08:13
How to write RTL(Arabic/Persian) text on images in python.
# Tested on Python 3.6.1
# install: pip install --upgrade arabic-reshaper
import arabic_reshaper
# install: pip install python-bidi
from bidi.algorithm import get_display
# install: pip install Pillow
from PIL import ImageFont
@allenday
allenday / make_TsvHttpData.pl
Last active September 3, 2018 10:07
Create URL list for Google Cloud Storage Transfer Service, see: https://cloud.google.com/storage/transfer/create-url-list
#!/usr/bin/perl
use strict;
my $http_base = shift;
my $path_base = shift;
my $prev_file = shift;
if ( ! $http_base || ! $path_base ) {
print STDERR <<"HERE";
USAGE:
@michelmany
michelmany / app.js
Last active April 22, 2023 00:42
Vue.js 2 Vee-validate (pt-br) CPF Validation
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VeeValidator, { Validator } from 'vee-validate'
import CpfValidator from './components/validators/cpf.validator'
import Dictionary from './components/validators/dictionary'
import Produto from './components/produtos.vue'
Validator.extend('cpf', CpfValidator)
@jkubecki
jkubecki / ExportKindle.js
Last active June 1, 2024 22:51
Amazon Kindle Export
// The following data should be run in the console while viewing the page https://read.amazon.com/
// It will export a CSV file called "download" which can (and should) be renamed with a .csv extension
var db = openDatabase('K4W', '3', 'thedatabase', 1024 * 1024);
getAmazonCsv = function() {
// Set header for CSV export line - change this if you change the fields used
var csvData = "ASIN,Title,Authors,PurchaseDate\n";
db.transaction(function(tx) {
var gulp = require('gulp');
var runSequence = require('run-sequence');
var minifyCss = require('gulp-minify-css');
var buildDir = './build/';
var build = new Date().getTime();
var minifyCssSettings = { advanced: true, aggressiveMerging: true };
// Main build