Skip to content

Instantly share code, notes, and snippets.

@schacon
schacon / better-git-branch.sh
Created January 13, 2024 18:41
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@enepomnyaschih
enepomnyaschih / base64.js
Last active March 6, 2024 23:45
https://www.npmjs.com/package/byte-base64 - Encode JS Uint8Array, simple array of bytes or native JS string to base64 and back
/*
MIT License
Copyright (c) 2020 Egor Nepomnyaschih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@ianks
ianks / slugify.sql
Last active October 31, 2023 05:03
Generating Slugs in Postgres
CREATE EXTENSION IF NOT EXISTS "unaccent";
CREATE OR REPLACE FUNCTION slugify("value" TEXT)
RETURNS TEXT AS $$
-- removes accents (diacritic signs) from a given string --
WITH "unaccented" AS (
SELECT unaccent("value") AS "value"
),
-- lowercases the string
"lowercase" AS (
@Jurawa
Jurawa / Rails-local-development-with-SSL-on-Mac-OS-X.md
Last active December 9, 2021 22:24
Rails local development with SSL on Mac OS X

Assumes you will be running your local app at local.dev, and already have a hosts file entry for this domain pointing to 127.0.0.1.

Generate self-signed cert and key

openssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout ~/path/to/local.dev.key -out ~/path/to/local.dev.crt

You can leave all the address and organization info blank.

@kkosuge
kkosuge / sample.php
Last active April 8, 2022 09:46
PHP <=> Ruby ( OpenSSL AES-256-CBC )
<?php
const PASSWORD = '!!!!!sufficiently_long_password!!!!!';
const CIPHER_METHOD = 'AES-256-CBC';
function encrypt($str) {
$iv_length = openssl_cipher_iv_length(CIPHER_METHOD);
$iv = mcrypt_create_iv($iv_length, MCRYPT_RAND);
$str = $iv.$str;
$val = openssl_encrypt($str, CIPHER_METHOD, PASSWORD, 0, $iv);