Skip to content

Instantly share code, notes, and snippets.

View Astrochimp's full-sized avatar
🏠
Working from home

Marcello Prattico Astrochimp

🏠
Working from home
View GitHub Profile
@boucher
boucher / gist:1750375
Created February 6, 2012 07:09 — forked from siddarth/gist:1379745
Stripe PHP simple example
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
@dtx
dtx / HashMap.js
Created September 27, 2012 00:11
A simple HashMap implementation in Javascript, just something I wrote while reading DailyJS.
var HashMap = function(){
this._size = 0;
this._map = {};
}
HashMap.prototype = {
put: function(key, value){
if(!this.containsKey(key)){
this._size++;
@thomasnordlund
thomasnordlund / authRoute.js
Created November 6, 2012 16:19 — forked from xcambar/LICENSE
Authenticated routing using AngularJS
authRouteProvider.$inject = ['$routeProvider'];
function authRouteProvider ($routeProvider) {
/**
* Creates a controller bound to the route, or wraps the controller in param
* so the authentication check is run before the original controller is executed
* @param currentController
* @return {Function} The wrapper controller
*/
function redirectCtrlFactory (currentController) {
_ctrl.$inject = ['currentUser__', 'userRole__', '$location'];
@katanacrimson
katanacrimson / app.js
Created December 2, 2012 18:23
nodejs app - expressjs 3.0 + socket.io v9 + passport + redis
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
@joemccann
joemccann / ocr.js
Created January 20, 2013 00:50
Optical Character Recognition with node.js and Tesseract. Check your console for the results...
var ncr = require('nodecr')
, request = require('request')
, fs = require('fs')
, test_img = 'https://www.google.com/images/srpr/logo3w.png' // Change this to your image
// Create image name from end of URL.
// Note this will fail in loads of cases.
var imgName = test_img.split('/').pop()
// Process the image and read the text from it using Tesseract
@VRMink
VRMink / gist:5169211
Last active January 6, 2020 20:31
How to setup a private node.js web server with SSL authorization

Secure private web server with NodeJS

This article will explain how to set up a secure web server with NodeJS which only accepts connection from users with SSL certificates that you have signed. This is an efficient way to ensure that no other people are able to access the web server, without building a login system which will be significantly weaker.

I will not explain how to create a certificate authority (CA), create certificates or sign them. If you need to read up on this, have a look at this excelent article on how to do it with OpenSSL (Mac and Linux): https://help.ubuntu.com/community/OpenSSL#Practical_OpenSSL_Usage It is also possible to do this on a Mac with the keychain application, and I assume it is possible on a Windows machine aswell.

This architecture will allow you to have one web server communicating with an array of trusted clients, the web server itself can be on the public internet, that will not decrease the level of security, but it will only ser

@fideloper
fideloper / sample-app
Created May 15, 2013 20:02
Sample application Upstart script, using Forever
#!/bin/bash
# Sample App Init script for running sample app daemon
#
# chkconfig: - 98 02
#
# description: Sample Application Upstart, using Forever
APPHOME=/opt/sample-app
APPSCRIPT=app.js
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 4, 2024 21:33
A badass list of frontend development resources I collected over time.
@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t
@callumacrae
callumacrae / build-tools.md
Last active October 25, 2023 15:14
Build tools written in JavaScript