Skip to content

Instantly share code, notes, and snippets.

View aindong's full-sized avatar
🎯
Focusing

Alleo Indong aindong

🎯
Focusing
View GitHub Profile
@aindong
aindong / deploy_to_s3_and_cf.sh
Created June 20, 2019 04:45
Build and deploy a create-react-app to s3 and cloudfront
#!/bin/bash
## Colors for cli output messages
ERROR=`tput setaf 1`
SUCCESS=`tput setaf 2`
PC=`tput setaf 3`
NC=`tput sgr0`
## Available choices on args
## You can create as many project as you like for choices
@aindong
aindong / provision.sh
Last active June 13, 2019 12:57
provision laravel server with nginx, php, awscli, composer, node, ruby, python
#!/bin/bash
# Add Ruby2.0 respository
add-apt-repository -y ppa:brightbox/ruby-ng-experimental
# Add PHP 7.* ppa
sudo add-apt-repository ppa:ondrej/php
# Add node source respository
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
@aindong
aindong / .htaccess
Created September 14, 2016 07:37
Redirect http to https using aws load balancer and .htaccess
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@aindong
aindong / getVideoDuration.js
Created November 21, 2018 15:20
Get local video duration using promise
const getDuration = file => {
return new Promise((resolve, reject) => {
let videoElement = document.createElement("video");
videoElement.preload = "metadata";
videoElement.onloadedmetadata = function() {
window.URL.revokeObjectURL(videoElement.src);
resolve(videoElement.duration);
};
@aindong
aindong / aws-policy.json
Last active November 13, 2018 15:52
React-S3-CloudFront Deployment Shell Script
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1489770487230",
"Effect": "Allow",
"Principal": {
"AWS": "arn user"
},
"Action": [
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aindong
aindong / downloader.js
Last active August 22, 2018 09:31
Download blob client side
const download = blob => {
if (window.navigator.msSaveOrOpenBlob) { // IE hack; see http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx
window.navigator.msSaveBlob(blob, "filename.csv");
} else {
let a = window.document.createElement("a");
a.href = window.URL.createObjectURL(blob, {type: "text/plain"});
a.download = "filename.csv";
document.body.appendChild(a);
a.click(); // IE: "Access is denied"; see: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access
document.body.removeChild(a);
@aindong
aindong / FormGathererSpreadsheet.js
Created July 31, 2018 05:37
Save data to spreadsheet
// https://script.google.com/macros/s/AKfycbxqaARMsIrSYKysoN5RByYe0PlWAgW9VrRi16p8IojhFKpgYpc/exec
function doGet(e){
//return handleResponse(e);
}
function doPost(e){
return handleResponse(e);
}
@aindong
aindong / TenantDetector.php
Last active July 10, 2018 03:34
Multi-Tenant Middleware Laravel
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Config\Repository as Config;
class TenantDetector {
protected $config;
public function __construct(Config $config)
import random
def main():
# Generate digits
code = generate_digits(3, [])
print(code)
# Some story
print("Welcome to CodeBreaker Game, You need to unlock something before something happened")
print("Can you guess the code to unlock that something?")