Skip to content

Instantly share code, notes, and snippets.

View osuritz's full-sized avatar

Olivier Suritz osuritz

View GitHub Profile
@osuritz
osuritz / base64codec.ts
Created October 21, 2022 03:21
URL-Safe Base64 encode/decode in TypeScript/JavaScript
/** Returns a Base64-encoded string is safe to embed in URLs. */
function base64UrlEncode(str: string) {
return btoa(str).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
/**
* Deocdes a string of URL-safe, Base64-encoded data into bytes, and encodes
* those bytes into a string using Latin-1 (ISO-8859-1).
*
* The input data is typically encoded with a `base64UrlEncode` method.
@osuritz
osuritz / add-subtitles.sh
Last active January 26, 2018 06:25
Adding subtitles to an existing MKV file
mkvmerge --default-language eng -o output_file.mkv input_file.mkv --language 0:eng english_subs.srt --language 0:fre french_subs.srt
@osuritz
osuritz / gist:136e8e805c8c9d779502
Created May 7, 2014 22:26
Xcode treat warnings as errors
https://lightyearsoftware.com/2013/03/xcode-hard-mode/
Xcode 5 > select project > Build Settings > Apple LLVM Custom Compiler Flags > Other C Flags
-Weverything -Werror -Wno-pedantic -Wno-objc-missing-property-synthesis -Wno-direct-ivar-access -Wno-arc-repeated-use-of-weak
@osuritz
osuritz / ValidateJsonAntiForgeryTokenAttribute.cs
Created December 16, 2012 01:40
.NET 4.5 / MVC4-compatible version of ValidateKsonAntiForgeryTokenAttribute
namespace Casero.Web.Mvc
{
using System;
using System.Collections.Specialized;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
// Checks the User's CSRF token
// http://haacked.com/archive/2011/10/10/preventing-csrf-with-ajax.aspx