Skip to content

Instantly share code, notes, and snippets.

@tompave
tompave / nginx.conf
Last active August 15, 2022 10:18
commented nginx.conf for Ruby on Rails
# A commented nginx configuration file for Ruby on Rails
#
# Author: Tommaso Pavese
# tommaso@pavese.me
# http://tommaso.pavese.me
#
# License: http://www.wtfpl.net/
#
#
# Tested with:
#define ENDPOINT_URL @"http://www.myawesomeserver.com/data/images"
// elsewhere: we will need this to send the request asynchronously
self.httpQueue = [[NSOperationQueue alloc] init];
/**
* upload method
*/
- (void)uploadImage:(UIImage*)image withImageName:(NSString*)imageName andParams:(NSDictionary*)paramsDict
@tompave
tompave / simple_redirect_server.rb
Last active December 21, 2015 07:59
A simple ruby HTTP server that listens on 127.0.0.1:80 and redirects all requests to a specific URL.
#! /usr/bin/env ruby
require 'webrick'
require 'uri'
TARGET_URL = URI.parse "http://tommaso.pavese.me/back_to_work/"
redirect_callback = Proc.new do |request, response|
response.set_redirect WEBrick::HTTPStatus::TemporaryRedirect, TARGET_URL
@tompave
tompave / rebooter.rb
Last active December 16, 2015 00:09
A simple implementation of a Ruby program that: works with a continuous event loop, is managed through UNIX signals, stops and reboots in response to file system changes (but that can be easily customized).
#! /usr/bin/env ruby
=begin
How to launch
$ chmod 700 rebooter.rb
$ ./rebooter.rb
It will create two files (will delete them on SIGTERM and SIGINT)
./rebooter.pid
./rebooter.control