Skip to content

Instantly share code, notes, and snippets.

View maoosi's full-sized avatar

Sylvain maoosi

View GitHub Profile
@maoosi
maoosi / amplifyauth-scheme.ts
Last active October 26, 2021 18:24
[WIP] Custom amplify auth scheme for nuxt/auth (auth.nuxtjs.org).
import { Amplify, Auth, withSSRContext } from 'aws-amplify'
import { Auth as NuxtAuth } from '@nuxtjs/auth-next'
export interface AmplifyAuthSchemeOptions {
name: string
}
export default class AmplifyAuthScheme {
public $auth: NuxtAuth
public options: AmplifyAuthSchemeOptions
@maoosi
maoosi / iam-policy.json
Created September 11, 2019 00:48
Buddy.works AWS IAM JSON Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BuddyPolicy",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetObject",
"s3:GetObjectAcl",
@maoosi
maoosi / iosfix.js
Last active September 28, 2018 05:06
ES6 Class to prevent "doubleTapZoom" and "overscroll" issues with IOS browsers.
/* eslint-disable padded-blocks */
export default class IOSFix {
constructor (options = {}) {
this.options = {
target: options.target || document,
doubleTapZoom: options.doubleTapZoom || true,
overscroll: options.overscroll || true,
overscrollExcl: options.overscrollExcl || []
}
@maoosi
maoosi / getUniqAlphaNum.js
Last active September 28, 2018 05:07
Function to generate alpha-numeric strings. First parameter is the length, second parameters is the number of numeric characters.
const getUniq = (digits, nbTotalNumerics) => {
let numerics = '0123456789';
let alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
let nbNumerics = 0;
let uniqCode = '';
for (let i = digits; i > 0; --i) {
let forceNumeric = (i <= nbTotalNumerics && nbNumerics < nbTotalNumerics);
if ((forceNumeric || (Math.floor(Math.random() * 2) + 0) === 0) && nbNumerics < nbTotalNumerics) {
@maoosi
maoosi / drawCanvasImage.js
Last active September 28, 2018 05:07
Image drawing function for Canvas context. Include rotation and resizing.
drawImage (context, image, width, height, posX = 0, posY = 0, rotate = 0) {
let rotation = rotate * (Math.PI / 180)
let translateX = posX + (width / 2)
let translateY = posY + (height / 2)
context.translate(translateX, translateY)
context.rotate(rotation)
context.drawImage(image, -(width / 2), -(height / 2), width, height)
context.rotate(-rotation)
context.translate(-translateX, -translateY)
@maoosi
maoosi / git.bash
Last active April 13, 2016 04:45
Some useful git commands.
# Reset local repo to the last commit
git reset --hard
# Reset local repo to a specified commit
git reset --hard <SOME-COMMIT>
# Check last commit on your local
git log -1
# Get remote url used on your local
@maoosi
maoosi / provision.sh
Last active June 22, 2017 16:17
Provision script for Ubuntu 14.04 LTS - Apache, PHP, MySql, Git, Composer, NodeJS
#! /usr/bin/env bash
#
# Provision script for Ubuntu 14.04 LTS
# ------------
#
# Author: https://github.com/maoosi
# Includes: Apache, PHP, MySql, Git, Composer, NodeJS
#
@mixin blurryFix() {
-webkit-transform: translateZ(0);
-webkit-filter: blur(0);
}
.blurry-fix {
@include blurryFix();
}
@maoosi
maoosi / throttle.js
Last active May 9, 2016 02:35
Simple JavaScript throttle function - From Grafikart https://www.grafikart.fr/tutoriels/javascript/debounce-throttle-642
function throttle(callback, delay) {
var last;
var timer;
return function () {
var context = this;
var now = +new Date();
var args = arguments;
if (last && now < last + delay) {
clearTimeout(timer);
timer = setTimeout(function () {
@maoosi
maoosi / debounce.js
Last active April 12, 2016 01:01
Simple JavaScript debounce function - From Grafikart https://www.grafikart.fr/tutoriels/javascript/debounce-throttle-642
function debounce(callback, delay){
var timer;
return function(){
var args = arguments;
var context = this;
clearTimeout(timer);
timer = setTimeout(function(){
callback.apply(context, args);
}, delay)
}