Skip to content

Instantly share code, notes, and snippets.

@ggoral
ggoral / watcher.py
Created July 2, 2019 15:42 — forked from alfakini/watcher.py
Filesystem events monitoring with Python [watcher.py]
import sys
import time
from watchdog.observers import Observer
from .events import ImagesEventHandler
class ImagesWatcher:
def __init__(self, src_path):
self.__src_path = src_path
self.__event_handler = ImagesEventHandler()
@ggoral
ggoral / ssl_puma.sh
Created May 20, 2017 22:17 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@ggoral
ggoral / config.ru
Created August 31, 2016 19:54 — forked from dmoser/config.ru
basic ajax/sinatra example
$:.unshift File.expand_path(File.dirname(__FILE__))
require "viz"
run Sinatra::Application
@ggoral
ggoral / gist:ec5d62ebeb24a76cbcca2f6ec8053cc2
Created May 10, 2016 19:20 — forked from victorwhy/gist:45bb5637cd3e7e879ace
How Sinatra routes PUT/PATCH and DELETE

HTML and Sinatra really only support the GET and the POST methods. In order to be able to use the PUT and DELETE methods in Sinatra, you kind of have to "trick" the form to go to the right place. Then you can name the routes the proper way - otherwise you can only really work with GET and POST.

I used the Craiglist Jr challenge for some examples. Let's look at a quick example of a POST form/method/route- in this case, we're creating a new Craigslist article:

POST form and corresponding route:

<form action="/article/new" method="post">
  --------------------------------
  YOUR FORM FIELDS HERE
#!/bin/sh
### BEGIN INIT INFO
# Provides: puma
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the puma app server
# Description: starts puma using start-stop-daemon
@ggoral
ggoral / README.md
Created September 24, 2015 20:48 — forked from Burgestrand/README.md
A ruby script to construct magnet links out of .torrent files

Magneto

It reads your torrents. Spit out magnet URIs.

Example Usage

$ ./magneto.rb magneto.rb.torrent

Results in:

/** *********************************************************
* API - Model - User
********************************************************* */
module.exports = function (sequelize, DataTypes) {
return sequelize.define('User', {
username: DataTypes.STRING,
password: DataTypes.STRING,
firstName: DataTypes.STRING,
lastName: DataTypes.STRING,
@ggoral
ggoral / Install-rbenv-ubuntu.sh
Last active August 29, 2015 14:19
Install-rbenv-ubuntu
#!/bin/bash
if [ ! -x /usr/bin/git ]
then
echo "Install git please."
exit 1
fi
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
#!/bin/sh
# Install Java-8
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer
# Install Maven-3
cd ~/Downloads/
wget http://mirror.rackcentral.com.au/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
@ggoral
ggoral / Gemfile
Created December 11, 2013 14:32 — forked from a2ikm/Gemfile
source "https://rubygems.org"
gem "sinatra"
gem "tilt-jbuilder", ">= 0.4.0", :require => "sinatra/jbuilder"
gem "hashie"