Skip to content

Instantly share code, notes, and snippets.

View calderaro's full-sized avatar

Angel Calderaro calderaro

View GitHub Profile
// C++ bit . save it in an example.cpp file
#include "emscripten.h"
extern "C" {
inline const char* cstr(const std::string& message) {
char * cstr = new char [message.length()+1];
std::strcpy (cstr, message.c_str());
return cstr;
}
EMSCRIPTEN_KEEPALIVE
const char* getAMessage() {
@calderaro
calderaro / gif_test.cpp
Created May 6, 2021 16:42 — forked from suzumura-ss/gif_test.cpp
gif-lib basic example.
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include <gif_lib.h>
bool gif_write(const char* fileName)
{
int error;
@calderaro
calderaro / jwtRS256.sh
Created July 6, 2020 23:04 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@calderaro
calderaro / fileHandler.ts
Created September 21, 2019 17:35 — forked from jasonbyrne/fileHandler.ts
Firebase Functions + Express file uploader handler
/* Firebase Functions messes with your request and will wreck your day because none of the
* traditional upload handlers with Express will work.
*
* Credit: https://stackoverflow.com/questions/47242340/how-to-perform-an-http-file-upload-using-express-on-cloud-functions-for-firebase
*/
const Busboy = require('busboy');
const allowedMethods: string[] = ['POST', 'PUT'];
export class FileUpload {
@calderaro
calderaro / app.js
Created September 11, 2017 02:58 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@calderaro
calderaro / limitLoop.js
Created August 14, 2017 05:13 — forked from addyosmani/limitLoop.js
Limit the frame-rate being targeted with requestAnimationFrame
/*
limitLoop.js - limit the frame-rate when using requestAnimation frame
Released under an MIT license.
When to use it?
----------------
A consistent frame-rate can be better than a janky experience only
occasionally hitting 60fps. Use this trick to target a specific frame-
rate (e.g 30fps, 48fps) until browsers better tackle this problem
@calderaro
calderaro / mp3.js
Created January 9, 2017 06:20 — forked from dtrce/mp3.js
streaming mp3 using nodejs
var http = require('http'),
fileSystem = require('fs'),
path = require('path')
util = require('util');
http.createServer(function(request, response) {
var filePath = 'path_to_file.mp3';
var stat = fileSystem.statSync(filePath);
response.writeHead(200, {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
canvas {
border: 1px solid black
}
@calderaro
calderaro / socket.io-emit-broadcast-usage.js
Created November 13, 2016 03:11 — forked from markogresak/socket.io-emit-broadcast-usage.js
Different destination groups for socket.io emit and broadcast functions
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@calderaro
calderaro / index.html
Created August 4, 2016 02:04 — forked from anonymous/index.html
JS Bin Coding Challenge #30: Phyllotaxis // source http://jsbin.com/hezidi
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Coding Challenge #30: Phyllotaxis">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
canvas {
border: black 1px solid;