Skip to content

Instantly share code, notes, and snippets.

View andreasonny83's full-sized avatar
:octocat:
<Coding />

Andrea Z. andreasonny83

:octocat:
<Coding />
View GitHub Profile
@andreasonny83
andreasonny83 / class-singleton.js
Last active February 17, 2019 22:15
Singleton Pattern
/**
* The singleton pattern is a pattern used to restrict an object to a single instance.
* A singleton creates an instance of an object if that object does not exist.
* If it exists it returns the existing instance.
*/
class Car {
constructor(model, year, miles) {
if(Car.exists){
return Car.instance
@andreasonny83
andreasonny83 / vim.md
Last active February 9, 2019 10:59
VIM

Convert to HEX

:%!xxd
@andreasonny83
andreasonny83 / conditiona- value.js
Last active March 19, 2019 12:09
Conditional Object key
// Conditional value
const a = {
...(someCondition && {b: 5})
}
// Remove key from object
const postData = {
token: 'secret-token',
publicKey: 'public is safe',
@andreasonny83
andreasonny83 / handler.js
Last active September 17, 2018 08:11
sendMail
// Copyright (c) 2018 AndreaSonny <[email protected]> (https://github.com/andreasonny83)
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
'use strict';
const AWS = require('aws-sdk');
const ses = new AWS.SES();
{
"name": "package-name",
"version": "0.0.0",
"description": "package-name short description",
"main": "lib/cli/index.js",
"bin": {
"package-name": "./bin/index.js"
},
"scripts": {
"test": "jest --watchAll"
Array.prototype.mySum = function(callback) {
const vals = this;
const res = [];
for (var i = 0; i < vals.length; i++) {
res.push(callback(this[i]));
}
return res;
@andreasonny83
andreasonny83 / script.sh
Created October 19, 2017 14:04
Rename *.dev.ts to .ts
#!/bin/bash
# Find and rename all the modules files according to the target environment
env=${1-"dev"}
dir="src/app/components"
find $dir -name "*.$env.ts" -type f | while read file
do
base=$(basename $file)
@andreasonny83
andreasonny83 / .gitignore
Last active April 26, 2025 07:12
Gitignore template for JavaScript projects
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Runtime data
pids
*.pid
@andreasonny83
andreasonny83 / README.md
Last active February 17, 2025 22:08
Readme template

npm version code style: prettier

Project Name

Write a project description

Prerequisites

This project requires NodeJS (version 8 or later) and NPM.

@andreasonny83
andreasonny83 / Bash-Scripts.bash
Last active March 26, 2020 10:49
Find and delete bunch of files from terminal
find app/ -name '*.map' -exec sh -c 'rm "{}" ' \; # Remove all the .map files inside app/
find . -name node_modules -exec rm -rf {} \; # Remove all node_modules from inside current folder and subfolders
ssh-add -L # Print Git ssh credentials
ssh-add ~/.ssh/id_rsa # Activate SSH credentials
OSZAR »