Skip to content

Instantly share code, notes, and snippets.

@julianfresco
julianfresco / Dev log: getting react-select, react-hook-form and react-query to play well with react v18.x and chakra-ui.md
Last active March 30, 2023 22:52
Dev log: getting react-select, react-hook-form and react-query to play well with react v18.x and chakra-ui
@julianfresco
julianfresco / LinkedList.js
Last active May 18, 2018 00:44
CS Fundamentals - LinkedList
class Node {
constructor(value){
this.value = value
this.next = null
}
setNext(next){
this.next = next
}
getNext(){
@julianfresco
julianfresco / corsTLDWhitelist.middleware.js
Last active August 31, 2017 00:16
corsTLDWhitelist - This Express.js middleware "whitelists" a few desired TLDs, allowing the server to dynamically accept CORS requests and not accept others via the "*" wildcard.
/**
* corsTLDWhitelist
* This Express.js middleware "whitelists" a few desired TLDs, allowing the server
* to dynamically accept CORS requests and not accept others via the "*" wildcard.
* See also: https://stackoverflow.com/a/32481816/1799146
*/
export const corsTLDWhitelist = function(req, res, next) {
const tldWhitelist = ['example.com', 'github.com']
const origin = req.headers.origin || ''
@julianfresco
julianfresco / my.controller.js
Last active March 30, 2023 17:45
Restricted access HLS video streaming with node.js and express.js router
'use strict';
var fs = require('fs');
var config = require('../../config'); // developer-defined configs (Ex: config.video.localPath = "server/storage/")
/** Serves HLS videos to user */
exports.serveHLSVideo = function(req, res){
var appRoot = (__dirname + '/../../../'),
filePath = appRoot + config.video.localPath + req.params[0];
@julianfresco
julianfresco / spinner.css
Created February 9, 2017 08:40
Spinner effect on loading icons
/* Spin effect */
@-moz-keyframes spin {
0%{-moz-transform:rotate(0deg)}
100%{-moz-transform:rotate(359deg)}
}
@-webkit-keyframes spin{
0%{-webkit-transform:rotate(0deg)}
100%{-webkit-transform:rotate(359deg)}
}
@julianfresco
julianfresco / MyVSCodeSetup.md
Last active December 17, 2017 20:11
How I get up and running with VS Code

Setup for VS Code

  1. Download and Install VS Code Move to Applications folder

  2. Install ESLint at cli with npm npm install -g eslint Now you can add a .eslintrc.json file to the root of your projects... Here's a good one to start with:

@julianfresco
julianfresco / cluster.js
Created October 25, 2016 22:07
NodeJS Cluster module - disconnect without lingering processes
'use strict';
/** [INFO] this file covers 2 aspects of using cluster module (tested Node v4.x LTS)
* 1 - Running multiple types of child processes
* 2 - Graceful termination of a clustered app using SIGTERM
*/
var cluster = require('cluster');
var processName = 'app-name ['+ (process.env.type || 'main') + '-process:' + process.pid + ']'; // give the process a name (for logging)