Skip to content

Instantly share code, notes, and snippets.

View vparaskevas's full-sized avatar

Vasileios Paraskevas vparaskevas

View GitHub Profile
@msmfsd
msmfsd / flattenDeep.js
Last active July 16, 2018 08:53
Flatten a n-dimensional nested Javascript array
/*
* Flatten deeply nested array without external library like Immutable
* Simplified ES6 version of lodash flattenDeep functionality
* Reference: https://lodash.com/docs#flattenDeep
* Requirements: Latest Chrome/FF browser or ES6 transpiler like Babel
*/
const INFINITY = 1 / 0
/*
* Utility flatten array function
@luruke
luruke / smashingmagazine.js
Last active January 17, 2025 09:55
Source code of the demo "Improving User Flow Through Page Transitions" on Smashing Magazine.
/*
https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/
You can copy paste this code in your console on smashingmagazine.com
in order to have cross-fade transition when change page.
*/
var cache = {};
function loadPage(url) {
if (cache[url]) {
@anvk
anvk / promises_reduce.js
Last active September 8, 2024 15:10
Sequential execution of Promises using reduce()
function asyncFunc(e) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(e), e * 1000);
});
}
const arr = [1, 2, 3];
let final = [];
function workMyCollection(arr) {
@gaearon
gaearon / connect.js
Last active April 19, 2025 04:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@twolfson
twolfson / README.md
Last active August 1, 2023 10:45
Node.js job queue evaluation

We are building a Node.js service which will need asynchronous support for tasks like sending emails. Here's our evaluation:

@SuperPaintman
SuperPaintman / npm-f3-install.sh
Last active April 14, 2025 18:18
NPM install for low RAM machins. And "npm install ... killed" problem
#!/bin/bash
#
# Author: SuperPaintman <[email protected]>
#
###
# Constants
###
RETVAL=0
@cedricmagne
cedricmagne / change_definer.sh
Last active December 2, 2020 23:45
Change TRIGGERS DEFINER in MySQL
##
## Create mysql triggers dump
## We add DROP TRIGGER IF EXISTS with option --add-drop-trigger
## This option is supported only by mysqldump as supplied with MySQL Cluster. It is not available when using MySQL Server 5.5.
## If you don't need password dont use -p option.
##
mysqldump -u <USERNANME> -p --routines --add-drop-trigger --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql
##
## Change old DEFINER with sed command
@jonobr1
jonobr1 / google-sheet-to-json.js
Last active April 26, 2024 15:41
A node.js script to convert a Google Sheet into a JSON object
/**
* Simple Node.js script to turn a specific page on a Google Sheet
* into a JSON object for the main purpose of HTML Templating.
*
* @author jonobr1 / http://jonobr1.com
*
*/
var https = require('https');
var path = require('path');
@gitllermopalafox
gitllermopalafox / toymd.js
Created December 30, 2015 19:57
Function to add 'toYMD()' method to a Date object to get the format 'yyyy-mm-dd' (Mysql date format)
// http://stackoverflow.com/a/2280117/918072
// Function to add 'toYMD()' method to a Date object to get the format 'yyyy-mm-dd'
(function() {
Date.prototype.toYMD = Date_toYMD;
function Date_toYMD() {
var year, month, day;
year = String(this.getFullYear());
month = String(this.getMonth() + 1);
if (month.length == 1) {
month = "0" + month;
@laterbreh
laterbreh / Express 4 and Socket.io: Passing socket.io to routes - app.js
Last active August 15, 2023 13:58
Express 4 and Socket.io: Passing socket.io to routes.
var app = express();
app.io = require('socket.io')();
var routes = require('./routes/index')(app.io);
app.use('/', routes);