Skip to content

Instantly share code, notes, and snippets.

View davalapar's full-sized avatar
🦁
rawr

@davalapar davalapar

🦁
rawr
View GitHub Profile
console.groupWithTrace = (name, fn) => {
console.group(name);
fn();
console.groupCollapsed();
console.trace(name);
console.groupEnd();
console.groupEnd();
};
function add(x, y) {
@davalapar
davalapar / ssecheck.cpp
Created March 6, 2019 09:02 — forked from hi2p-perim/ssecheck.cpp
Check SSE/AVX instruction support.
/*
Check SSE/AVX support.
This application can detect the instruction support of
SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4a, SSE5, and AVX.
*/
#include <iostream>
#ifdef _MSC_VER
#include <intrin.h>
#endif
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) {
@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);
@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 / 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 / asd
Created December 10, 2018 01:59
asd
https://github.com/facebook/react/issues/12397#issuecomment-445620981
@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(