Skip to content

Instantly share code, notes, and snippets.

View vanics's full-sized avatar

Icaro Pacheco vanics

View GitHub Profile
@vanics
vanics / firebase_copy.js
Created November 20, 2016 07:15 — forked from katowulf/firebase_copy.js
Move or copy a Firebase path to a new location
function copyFbRecord(oldRef, newRef) {
oldRef.once('value', function(snap) {
newRef.set( snap.value(), function(error) {
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
}
@vanics
vanics / nginx.default.conf
Created December 5, 2017 21:37 — forked from sumardi/nginx.default.conf
Install PHP-FPM, Nginx & MySQL on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and PHP-FPM
sudo yum install -y nginx php-fpm
# Install PHP extensions
sudo yum install -y php-devel php-mysql php-pdo \
php-pear php-mbstring php-cli php-odbc \
@vanics
vanics / install-redis.sh
Created January 16, 2018 18:30 — forked from FUT/install-redis.sh
Install Redis on EC2
1. Install Linux updates, set time zones, followed by GCC and Make
sudo yum -y update
sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \
/etc/localtime
sudo yum -y install gcc make
2. Download, Untar and Make Redis 2.8 (check here http://redis.io/download)
@vanics
vanics / kandypot-node.js
Created January 16, 2018 19:45 — forked from mort/kandypot-node.js
Node.js + Redis pubsub + Websockets for kandypot.com.
// Really trivial. On new writes to the redis db, we push messages to a websocket channel
var sys = require("sys"), redis = require('./lib/redis-client'), ws = require("./lib/ws");
var pubsub = redis.createClient();
var clients = new Array();
ws.createServer(function (websocket) {
websocket.addListener("connect", function (resource) {
sys.debug("connect: " + resource);
client_id = resource.match(/apps\/([A-Za-z]+)\/timeline$/)[1];
@vanics
vanics / nginx-tuning.md
Created January 18, 2018 00:43 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@vanics
vanics / GridLayout.swift
Created January 27, 2018 06:54 — forked from smswz/GridLayout.swift
A simple custom grid UICollectionViewLayout
// MIT License
//
// Copyright (c) 2016 stable|kernel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@vanics
vanics / backup-mongodb-to-s3.sh
Created June 18, 2018 00:20 — forked from caraboides/backup-mongodb-to-s3.sh
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
import Parse from 'parse/node'
import { afterEach, describe, it } from 'mocha'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { resetParse, getAdminUser } from '../../../test/parseHelper'
import errors from '../../utils/errors'
chai.use(chaiAsPromised)
const assert = chai.assert
@vanics
vanics / WastingTimeOnStackOverflowTests.swift
Created June 25, 2018 05:41 — forked from masonmark/WastingTimeOnStackOverflowTests.swift
check whether array index is valid in Swift
// WastingTimeOnStackOverflowTests.swift Created by mason on 2016-09-18.
import XCTest
/// Measures performance of two different ways of checking whether an index is valid
/// for a given array (the variable "a" is an array of 1,000,000 unique strings, and
/// "val" is the index to be checked):
///
/// a.indices.contains(val)
/// vs:
@vanics
vanics / docker-cleanup-resources.md
Created June 30, 2018 18:33 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm