Skip to content

Instantly share code, notes, and snippets.

@AlbertoBasalo
AlbertoBasalo / store.ts
Created October 19, 2022 09:41
A generic class to manage state in an asynchronous way.
import { BehaviorSubject, distinctUntilChanged, map, Observable } from "rxjs";
/**
* A generic class to manage state in an asynchronous way.
*/
class Store<T> {
/**
* @private field to store and notify state changes
* BehaviorSubject is a special type of Observable
* that keeps hold of the current value
@jkresner
jkresner / Global.asax
Created October 30, 2012 20:20
Asp .net Mvc 4 Proxy Server/Controller (For help with Cross Domain Request)
public class WebApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
RouteTable.Routes.MapRoute("HttpProxy", "proxy/{*path}", new { controller = "Proxy", action = "Http" })
}
}
@shobhitg
shobhitg / server.js
Last active March 12, 2022 12:03
File upload example using busboy with express
var path = require('path');
var fs = require('fs');
var os = require('os');
var express = require('express');
var app = express();
var Busboy = require('busboy');
app.get('/', function (req, res) {
res.send('<html><head></head><body>\
<form method="POST" enctype="multipart/form-data">\
@adilbaig
adilbaig / setup-rabbitmq-cluster.sh
Created January 3, 2015 16:15
A complete bash script to setup a RabbitMQ cluster from scratch. Takes user-defined servers at run time.
#!/bin/bash
set -e
# This script is part of my blog post :
# http://thoughtsimproved.wordpress.com/2015/01/03/tech-recipe-setup-a-rabbitmq-cluster-on-ubuntu/
# It sets up a RabbitMQ cluster by connecting to user-provided master and slave servers
# and ringing them up to a cluster on the fly.
# RabbitMQ Clustering is described in detail here :
@jpravetz
jpravetz / product_generator.rb
Created December 2, 2011 21:24
Jekyll generator to read json data file and generate product and ingredient pages
#------------------------------------------------------------------------
# encoding: utf-8
# @(#)product_generator.rb 1.00 29-Nov-2011 16:38
#
# Copyright (c) 2011 Jim Pravetz. All Rights Reserved.
# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
#
# Description: A generator that creates product, products and
# ingredients pages for jekyll sites. Uses a JSON data
# file as the database file from which to read and
@ptgamr
ptgamr / flow-uploader.js
Last active September 17, 2019 13:38
Flowjs, ResumableJs NodeJS backend
'use strict';
const fs = Promise.promisifyAll(require('fs'));
const path = require('path');
const crypto = require('crypto');
const CronJob = require('cron').CronJob;
module.exports = class FlowUploader {
constructor(tempDir, uploadDir, maxFileSize, fileParameterName) {
this.tempDir = tempDir || './tmp';