Skip to content

Instantly share code, notes, and snippets.

View giordanocardillo's full-sized avatar
😎
Always improving

Giordano Cardillo giordanocardillo

😎
Always improving
View GitHub Profile
@giordanocardillo
giordanocardillo / 0-Codility
Last active January 29, 2018 08:26
Codility
Codility Tests
@giordanocardillo
giordanocardillo / README.md
Last active March 11, 2025 04:42
Setting nano as default editor

How to

Automatically

cat <<EOF >>~/.bash_profile
export VISUAL="nano"
export EDITOR="nano"
EOF
@giordanocardillo
giordanocardillo / install.sh
Created March 17, 2018 13:17
Install MongoDB 3.4 on Ubnutu 16.04 LTS
#!/bin/sh
MONGO_VERSION=3.4.10
# Import the Public Key used by the Ubuntu Package Manager
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
# Create a file list for mongoDB to fetch the current repository
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
# Update the Ubuntu Packages
sudo apt update
# Install MongoDB
sudo apt install mongodb-org=$MONGO_VERSION mongodb-org-server=$MONGO_VERSION mongodb-org-shell=$MONGO_VERSION mongodb-org-mongos=$MONGO_VERSION mongodb-org-tools=$MONGO_VERSION
@giordanocardillo
giordanocardillo / Dockerfile
Created April 29, 2018 11:24
Meteor Bundle Dockerfile
# Copy this Dockerfile inside application bundle directory, then build image
FROM node:8.9.4
WORKDIR /usr/src/app/myapp
COPY . .
WORKDIR /usr/src/app/myapp/programs/server
RUN set -e; \
npm i --production; \
npm i bcrypt; \
rm -rf ./npm/node_modules/bcrypt; \
cp -r ./node_modules/bcrypt ./npm/node_modules/bcrypt;
@giordanocardillo
giordanocardillo / kadira-stack.yml
Created April 29, 2018 18:17
Kadira Docker Stack
version: '3'
services:
kadira-engine:
restart_policy:
condition: on-failure
depends_on:
- mongo
image: vladgolubev/kadira-engine
ports:
@giordanocardillo
giordanocardillo / protect.js
Last active May 13, 2018 10:26
Console protect script
// Paste this at the and of your code to prevent console usage
var protect = function () {
// Disable all console logging
if(window && window.console){
window.console = {}
}
// Trigger a debugger breakpoint set
function triggerDebugger() {
(function () {}.constructor('debugger')())
// Recursive call
@giordanocardillo
giordanocardillo / string-calculator.js
Last active February 11, 2021 06:02
String Calculator Kata in JS
const calculator = (function(){
function add(numberString){
if (numberString === ''){
return 0
}
const delimiter = getDelimiter(numberString)
const formattedInput = formatInput(numberString)
return calculateSum(getNumbers(formattedInput, delimiter))
@giordanocardillo
giordanocardillo / test.js
Created May 30, 2018 12:59
JS ForEach with async wait
const asyncFn = (param) => {
return new Promise((resolve, reject) => {
setTimeout(()=>{
console.info(param)
resolve(param)
}, 1e3)
})
}
console.info('before');
@giordanocardillo
giordanocardillo / test.js
Created May 30, 2018 15:49
ForEach with Async callback
const arr = [1,2,3]
const max = arr.length -1
console.info('before')
new Promise((resolve, reject)=>{
arr.forEach((e, i)=>{
setTimeout(()=>{
console.log('Call n'+e)
if(i === max){
resolve()
@giordanocardillo
giordanocardillo / README.md
Last active July 25, 2018 16:26
Ionic 2.1.4 infinite-scroll in custom component fix

You must add the 'Content' to the viewProviders. It breaks the css margin of the root ion-content but works...

import { Content } from 'ionic-angular';

@Component({
selector: 'new-list',
templateUrl: 'list.html',
viewProviders: [Content]