Skip to content

Instantly share code, notes, and snippets.

@dansteingart
dansteingart / Spawner.js
Created November 1, 2012 01:09
Keeping Tabs On Multiple Spawned Processes in NodeJS
//First make placeholders for results as globals
results = {}
processes = {}
//Now Spawn Processes within code you need, where index is an identifier
spawn_list[index] = spawn(/*file here*/)
processes[index] = spawn_list[index].pid
results[processes[index]] = {}
results[processes[index]]['index'] = index //funny looking but important
results[processes[index]]['stdout'] = ""
@suprememoocow
suprememoocow / winston-logrotate.js
Last active May 11, 2019 01:19
A function for reopening a winston File logging transport post logrotation on a HUP signal. To send a HUP to your node service, use the postrotate configuration option from logrotate. `postrotate kill -HUP ‘cat /var/run/mynodeservice.pid‘`
function reopenTransportOnHupSignal(fileTransport) {
process.on('SIGHUP', function() {
var fullname = path.join(fileTransport.dirname, fileTransport._getFile(false));
function reopen() {
if (fileTransport._stream) {
fileTransport._stream.end();
fileTransport._stream.destroySoon();
}
@4np
4np / ImageCaptureManager.swift
Created August 1, 2016 11:37
Example code to grab a still image (photo) from a mac's FaceTime camera
//
// ImageCaptureManager.swift
// ImageCapture
//
// Created by Jeroen Wesbeek on 29/07/16.
// Copyright © 2016 Jeroen Wesbeek. All rights reserved.
//
import Foundation
import AVFoundation
@rezigned
rezigned / README.md
Last active August 19, 2021 22:31
Simple deploy script

A simple script for deploy from git repository.

How it works

Assume we have the following project structures

$PROJECT_NAME:

Project name. This could be anything. for example sample

@willrstern
willrstern / node-ubuntu-upstart-service.md
Last active August 17, 2023 10:15
Run Node.js App as Ubuntu Upstart Service

###The Issue With Forever Forever is great for running node services, with a minor setback: the word "forever" doesn't apply to system reboots.

###The solution, run node apps as a system service logged in as root

vim /etc/init/node-app.conf

Contents for node-app.conf

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@abicky
abicky / gist:3052980
Created July 5, 2012 11:00
Create HTMLImageElement from HTMLCanvasElement and HTMLCanvasElement from HTMLImageElement
import "js/web.jsx";
class Util {
static function image2Canvas(image : HTMLImageElement) : HTMLCanvasElement {
var document = dom.window.document;
var canvas = document.createElement("canvas") as HTMLCanvasElement;
canvas.width = image.width;
canvas.height = image.height;
var ctx = canvas.getContext("2d") as CanvasRenderingContext2D;
ctx.drawImage(image, 0, 0);
@matthewlehner
matthewlehner / autopgsqlbackup
Created July 11, 2012 16:10
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <axelseaa@amadmax.com>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@JosefJezek
JosefJezek / eps-to-svg.md
Last active March 19, 2024 07:48
EPS to SVG Conversion using Inkscape

EPS to SVG using Inkscape Gittip

Author: Josef Jezek

# Install Inkscape on Ubuntu
sudo apt-get install inkscape
@bertspaan
bertspaan / README.md
Created January 2, 2014 15:28
Python script to convert DBF database file to CSV