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 / routes.ts
Created March 21, 2022 05:56
Dynamic Routing on Express JS
import express, { Response, Request } from 'express';
import fs from 'fs';
import { IRouterSettings } from './interfaces/IRouterSettings';
import Logger from './utils/logger';
const router = express.Router();
// loop through all the routes
const controllersPath = `${__dirname}/controllers`;
const controllers = fs.readdirSync(controllersPath);
@aindong
aindong / timedmint.sol
Created March 11, 2022 16:21
Hashlips simple nft contract with added start date of minting
// SPDX-License-Identifier: MIT
// Amended by HashLips
/**
!Disclaimer!
These contracts have been used to create tutorials,
and was created for the purpose to teach people
how to create smart contracts on the blockchain.
please review this code on your own before using any of
the following code for production.
@aindong
aindong / prisma.ts
Created March 10, 2022 08:08
Importing Prisma Best Practice on Nodejs + Express
import { PrismaClient } from '@prisma/client';
declare global {
// allow global `var` declarations
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}
export const prisma =
global.prisma ||
@aindong
aindong / clamp_movement.gd
Created February 6, 2022 02:56
Limit the movement of sprite to screen only (CLAMP)
extends Area2D
export var speed = 400.0
var screen_size = Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready():
screen_size = get_viewport_rect().size
print(screen_size)
@aindong
aindong / move_sprite.gd
Created February 6, 2022 02:54
Move a sprite base on input
func _process(delta):
var direction = Vector2.ZERO
if Input.is_action_pressed("move_right"):
direction.x += 1
if Input.is_action_pressed("move_left"):
direction.x -= 1
if Input.is_action_pressed("move_down"):
direction.y += 1
if Input.is_action_pressed("move_up"):
direction.y -= 1
@aindong
aindong / get_screen_viewport.gd
Created February 6, 2022 02:53
Get 2d screen viewport in godot
var screen_size = Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready():
screen_size = get_viewport_rect().size
print(screen_size)
@aindong
aindong / main.dart
Created July 16, 2019 09:06
MiCard Flutter Practice
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@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 / 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": [