Skip to content

Instantly share code, notes, and snippets.

View ancyrweb's full-sized avatar
🏠
Working from home

Anthony Cyrille ancyrweb

🏠
Working from home
View GitHub Profile
@ancyrweb
ancyrweb / types.ts
Last active April 9, 2019 17:59
TypeScript basic types
export type OrNull<T> = T | null;
export type OrUndefined<T> = T | undefined;
export type Maybe<T> = OrNull<OrUndefined<T>>;
export type StringMap<V> = {[key: string]: V}
@ancyrweb
ancyrweb / carousel.html
Created May 17, 2018 14:35
Home-made simple carousel
<?php
/**
* See http://sylvana.net/jpegcrop/exif_orientation.html
*/
function fixOrientation(Imagick $image) {
$orientation = $image->getImageOrientation();
switch($orientation) {
case 2:
$image->flipImage();
break;
@ancyrweb
ancyrweb / slugify.js
Created December 14, 2017 12:23
Slugify inspired by another gist
function slugify(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-')
.replace(/[éèëê]/g, "e")
.replace(/[iïî]/g, "i")
.replace(/[àâ]/g, "a")
.replace(/[oôö]/g, "o")
.replace(/[^\w\-]+/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
@ancyrweb
ancyrweb / extractBits.js
Created September 14, 2017 10:18
extractBits
/**
* Extracts bits out of the decimal num from msb to lsb
*
* @param num
* @param msb the most significant bit
* @param lsb the least significant bit
* @returns {number}
*/
function extractBits(num, msb, lsb) {
msb = msb || 0;
@ancyrweb
ancyrweb / normalize.js
Created January 21, 2017 11:37
Normalize deeply
import * as normalizr from 'normalizr';
/**
* Given an object where keys are IDs
* Return all the objects and an array of unique IDs
*
* @param object
* @returns {{entities: {}, result: Array}}
*/
export const shallowNormalize = (object) => {