Skip to content

Instantly share code, notes, and snippets.

View freegenie's full-sized avatar

Fabrizio Regini freegenie

View GitHub Profile
@mperham
mperham / gist:7d763bdc42465caf17c7
Last active August 29, 2015 14:02
Rule execution

I want to build a system which uses rules. These rules will change hourly (i.e. "this rule is effective from 2pm to 6pm"). The rules must support arbitrarily complex logic on just 2-3 pre-defined variables and result in a boolean:

item.a > 10 && item.b == 0 || item.category == FOOTWEAR

These rules will be executed hundreds of times per second so I can't afford the overhead of plain old eval. I want to reload the current effective ruleset from the database hourly, precompile each rule's logic string and execute it via the quickest method possible. It might look something like this:

class Rule
@welshstew
welshstew / activemq-jmssender.groovy
Created September 12, 2014 04:09
send jms messages to activemq with a neat groovy script
@Grab(group='org.apache.activemq',module = 'activemq-all', version='5.8.0')
import org.apache.activemq.ActiveMQConnectionFactory
import javax.jms.*
def brokerUrl = 'tcp://localhost:61616'
def queue = 'the.soapoverjms.service'
def soapAction = 'urn:sixtree:soapoverjms:dosomething'
def reader = new BufferedReader(new InputStreamReader(System.in))
@iamdbc
iamdbc / logrotate-puma-rails
Last active September 20, 2023 14:57
logrotate for puma on rails
# file location: /etc/logrotate.d
/home/deploy/app/your-app/shared/log/*.log {
daily
missingok
rotate 14
compress
delaycompress
dateext
notifempty
@r00takaspin
r00takaspin / puma.service
Created May 11, 2018 15:29
Run puma web server with RVM from systemd
[Unit]
Description=Puma HTTP Server
After=network.target
# Uncomment for socket activation (see below)
# Requires=puma.socket
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple