Skip to content

Instantly share code, notes, and snippets.

View deavial's full-sized avatar
Up to no good, probably.

Deavial deavial

Up to no good, probably.
View GitHub Profile
deavial / rx-websockets.jsx
Created September 9, 2022 18:15 — forked from sergiodxa/rx-websockets.jsx
Example possible usage of Rx for (fake) WebSocket Server
View rx-websockets.jsx
import { Observable } from 'rx';
import { EventEmitter } from 'events';
import { Map as map } from 'immutable';
// base para crear sockets
class Socket extends EventEmitter {
constructor(id) {
super(id); = id;
deavial / async-thread.js
Created September 9, 2022 18:13 — forked from sergiodxa/async-thread.js
Use WebWorkers and promises to run sync heavy functions in a worker (process) and get the result in a promise
View async-thread.js
function asyncThread(fn, ...args) {
if (!window.Worker) throw Promise.reject(
new ReferenceError(`WebWorkers aren't available.`)
const fnWorker = `
self.onmessage = function(message) {
.then(result => self.postMessage(result));
deavial / entry.server.tsx
Created September 9, 2022 18:00 — forked from sergiodxa/entry.server.tsx
Dynamically generate a PDF with Remix
View entry.server.tsx
import { renderToStream } from "@react-pdf/renderer";
import ReactDOMServer from "react-dom/server";
import { EntryContext, Headers, RemixServer, Request, Response } from "remix";
import PDF, { loader } from "./pdfs/my-pdf.server";
async function handlePDFRequest(request: Request, headers: Headers) {
// get the data for the PDF
let response = await loader({ request, context: {}, params: {} });
// if it's a response return it, this means we redirected
if (response instanceof Response) return response;
deavial / alert.js
Created October 4, 2021 20:24 — forked from farminf/alert.js
Sending PR Alerts Via Slack Using AWS Serverless and AWS CDK
View alert.js
const AWS = require("aws-sdk");
const fetch = require("node-fetch");
const crypto = require("crypto");
const slackChannel = process.env.SLACK_CHANNEL_URL;
const githubSecret = process.env.WEBHOOK_SECRET;
const verifyGitHubSignature = (req = {}, secret = "") => {
const sig = req.headers["X-Hub-Signature"];
const hmac = crypto.createHmac("sha1", secret);
const digest = Buffer.from(
View InlineEditing.js
el.set('contentEditable', true)
keydown: function(e){ if (e.key == 'enter') e.preventDefault(); },
keypress: function(e){ if (e.event.which == 0 && e.code == 13) e.preventDefault(); },
blur: function(){ var text = this.get('text'); this.set('text', text); }
View gist:68c0b134918d6aa58280f9d41d4d97fc
# List users by average and maximum session length.
SELECT person, max(client.runtime_ms), avg(client.runtime_ms)
FROM item_occurrence
# List active date ranges for each deploy.
SELECT client.javascript.code_version, min(timestamp), max(timestamp)
FROM item_occurrence
deavial / Enhance.js
Created September 13, 2017 08:35 — forked from sebmarkbage/Enhance.js
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
componentDidMount() {
this.setState({ data: 'Hello' });
render() {
deavial / JavascriptModulePatterns
Created June 3, 2016 03:41 — forked from ShMcK/JavascriptModulePatterns
Javascript (ES5) Module Patterns
View JavascriptModulePatterns
'use strict';
// 1. Revealing Module Pattern
var revModule = function (param) {
return {
// public
funk: funk
// private
deavial / SAP_CLA
Created March 19, 2016 01:09 — forked from CLAassistant/SAP_CLA
SAP Individual Contributor License Agreement
###SAP Individual Contributor License Agreement
Thank you for your interest in contributing to open source software projects (“Projects”) made available by SAP SE or its affiliates (“SAP”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to SAP in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact
You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.
**Copyright License.** You hereby grant, and agree to grant, to SAP a non-exclusive, perpetual, irrevocable, worldwid
deavial / log
Created May 21, 2014 15:57 — forked from stefanoortisi/log
View log
// usage: log('inside coolFunc', this, arguments);
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
arguments.callee = arguments.callee.caller;
if(this.console) console.log( );