Skip to content

Instantly share code, notes, and snippets.

View davalapar's full-sized avatar
🦁
rawr

@davalapar davalapar

🦁
rawr
View GitHub Profile
@davalapar
davalapar / config-haproxy.sh
Created December 7, 2018 07:03 — forked from jsermeno/config-haproxy.sh
Node.js server and Web Sockets on Amazon EC2 with Express.js and Socket.IO - http://catchvar.com/nodejs-server-and-web-sockets-on-amazon-ec2-w
# HAProxy config
mkdir /etc/haproxy
cat > /etc/haproxy/haproxy.cfg << EOF
global
maxconn 4096
defaults
mode http
@davalapar
davalapar / haproxy_websocket_40K_connections_config
Created December 7, 2018 07:04
HAProxy Websocket 40K Connections
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Global settings
@davalapar
davalapar / ioredis_example.js
Created December 8, 2018 21:40 — forked from forkfork/ioredis_example.js
Example of using Redis Streams with Javascript/ioredis
var Redis = require('ioredis');
var redis = new Redis({
host: "nodesydney.wiftycloud.com",
password: "7884b8baaa49fbcb48f17ad2a146"
});
async function main() {
// write an event to stream 'events', setting 'key1' to 'value1'
await redis.sendCommand(
@davalapar
davalapar / asd
Created December 10, 2018 01:59
asd
https://github.com/facebook/react/issues/12397#issuecomment-445620981
@davalapar
davalapar / gist:582d256a3f46d03566eb8de9e841cf7c
Created December 14, 2018 22:49 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561
/*
* How to delete items from an Array in JavaScript, an exhaustive guide
*/
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]
@davalapar
davalapar / TimedComponent.jsx
Last active December 29, 2018 21:09
TimedComponent.jsx
import React from 'react';
import PropTypes from 'prop-types';
class TimedComponent extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
@davalapar
davalapar / uuid.js
Created January 3, 2019 07:22 — forked from bugventure/uuid.js
UUID regex matching in node.js
function createUUID() {
return uuid.v4();
}
// version 4
// createUUID.regex = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$';
createUUID.regex = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$';
createUUID.is = function (str) {
return new RegExp(createUUID.regex).test(str);
class Dreadlocks {
constructor() {
this.mapLock = new Map();
this.arrayQueue = [];
}
lock(items) {
const dread = this;
return new Promise((resolve) => {
if (items.every(item => dread.mapLock.has(item) === false) === true) {