Skip to content

Instantly share code, notes, and snippets.

View phoenisx's full-sized avatar
🏔️
busy working, will continue OSS contributions later.

Subroto phoenisx

🏔️
busy working, will continue OSS contributions later.
View GitHub Profile
@phoenisx
phoenisx / types.ts
Last active September 23, 2021 05:08
Advance Typescript snippets for reference
/**
* Following is a selector that helps to dynamically create a type from existing constants
* This can be really helpful to create type patterns which works flawlessly with JS dynamic behaviour
* and reduce the amount of code required to add specific code for each type separately
*
* Ref: https://www.typescriptlang.org/docs/handbook/2/mapped-types.html
*/
export enum SUPPORTED_HEROES {
SPIDER = "spiderman",
SUPER = "superman",
@phoenisx
phoenisx / commands.sh
Last active July 7, 2023 18:56
Collection of useful Shell commands
# This helps to generate gif from any video file.
ffmpeg -i example.mov -ss 0 \
-vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
-loop 0 output.gif
# To stitch multiple videos together
# Ref: https://stackoverflow.com/a/7582140/2849127
ffmpeg -i big.avi -vf "movie=small0.avi [small0]; [in][small0] overlay=10:10 [tmp];\
movie=small1.avi [small1]; [tmp][small1] overlay=30:10 [out]" out.avi
@phoenisx
phoenisx / cpp.sublime-build
Last active August 9, 2022 08:16
Sublime Text 3 CPP Basic Setup (on Mac).
{
"cmd": ["g++", "-Wall", "-ansi", "$file_name", "-o", "${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"shell": false,
"variants": [
{
"name": "Run",
"shell": false,
@phoenisx
phoenisx / nodeCache.js
Created October 5, 2018 05:23
Some Useful Compose Functions for day-to-day uses
/**
* A DOM Node Caching Compose Function, that can be used in a Classes for Old Legacy Codes
* that didn't use any UI Frameworks, like React
*
* @param {HTMLElement} ref - A parent reference that will be used to query, to fetch inner nodes
* DEFAULT: `document`
*/
nodeCache = (ref = document) => {
const node = ref;
const cache = {};
@phoenisx
phoenisx / getTranslateYFromMatrix.js
Created August 24, 2018 05:57
Helps to get translate values from a matrix string, from `window.getComputedStyle`
/**
* Returns null if the Transform is not pre-calculated as a matrix string...
* else returns the translateY in Pixels...
*
* @param matrix: `window.getComputedStyle({ELEMENT}).getPropertyValue('transform')`
*
* Example: matrix = 'matrix(1, 0, 0, 1, 101.2, 186)' // [4]: translateX, [5]: translateY
*/
getTranslateYFromMatrix = (matrix) => {
const match = matrix.match(/\((.*)\)/)[1];
@phoenisx
phoenisx / package.json
Created December 3, 2017 13:58
Angular AOT Build with @ngtools/webapck, STEP II
{
"scripts": {
"start:prod:test": "npm-run-all clean build:prod:test change:hbs",
}
}
@phoenisx
phoenisx / bootstrap.aot.ts
Created December 3, 2017 13:49
Angular AOT STEP 1
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
// After `ngc` command is run this ngfactory file gets generated...
// So Following error is useless...
import { AppModuleNgFactory } from '../build/src/app/app.module.ngfactory';
declare var IS_PROD_TEST: boolean;
declare var environment;
@phoenisx
phoenisx / webpack.config.js
Created June 12, 2017 16:00
Basic set- up for Webpack Config with Proxy and Plugins
var webpack = require('webpack');
var path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const config = require('./config')
const extractText = new ExtractTextPlugin({
filename: "[name].css"
})
@phoenisx
phoenisx / google_calls.py
Created February 13, 2017 04:39
A Simple Pinging API, to make calls to Google Geolocation API per second
#!/usr/bin/python
###############################################################################################
#
# Basic Pinging API, to make calls to Google Geolocation API per second
# Uses Ratelimiting, for limiting the calls to one second only...
#
# * This app, uses a `.json` file [calls.json], for getting Lat/Lons, that needs to be
# reversegeocoded using the Google API...
# * Uses Formatter, to format String, as required...