Skip to content

Instantly share code, notes, and snippets.

View seanbehan's full-sized avatar

Sean Behan seanbehan

View GitHub Profile
@seanbehan
seanbehan / clear-sidekiq-jobs.sh
Created January 28, 2023 15:58 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@seanbehan
seanbehan / gist:2935f8b4df956f8693eabdc5c715a526
Created November 15, 2022 02:18 — forked from ekayxu/gist:5743138
Make Flask support regular expressions in its URL routing
#http://stackoverflow.com/questions/5870188/does-flask-support-regular-expressions-in-its-url-routing
#Even though Armin beat me to the punch with an accepted answer I thought I'd show an abbreviated example of how I implemented a regex matcher in Flask just in case anyone wants a working example of how this could be done.
from flask import Flask
from werkzeug.routing import BaseConverter
app = Flask(__name__)
class RegexConverter(BaseConverter):
def __init__(self, url_map, *items):
class TenantAwareManager(Manager):
def get_queryset(self):
tenant_id = current_tenant_id()
# If the manager was built from a queryset using
# SomeQuerySet.as_manager() or SomeManager.from_queryset(),
# we want to use that queryset instead of TenantAwareQuerySet.
if self._queryset_class != QuerySet:
return super().get_queryset().filter(tenant__id=tenant_id)
@seanbehan
seanbehan / node-walk.js
Created November 19, 2018 23:23 — forked from lovasoa/node-walk.es6
Walk through a directory recursively in node.js.
var fs = require("fs"),
path = require("path");
function walk(dir, callback) {
fs.readdir(dir, function(err, files) {
if (err) throw err;
files.forEach(function(file) {
var filepath = path.join(dir, file);
fs.stat(filepath, function(err,stats) {
if (stats.isDirectory()) {
//
// LoadingOverlay.swift
// app
//
// Created by Igor de Oliveira Sa on 25/03/15.
// Copyright (c) 2015 Igor de Oliveira Sa. All rights reserved.
//
// Usage:
//
// # Show Overlay
@seanbehan
seanbehan / craiglist-apa.py
Created April 24, 2016 16:28 — forked from anonymous/craiglist-apa.py
parse craigslist apartments in vermont
from lxml.html import fromstring as html, tostring as tos
from requests import get
import xmltodict
import json
results = []
URL = 'http://vermont.craigslist.org/search/apa'
for el in html(get(URL).text).xpath("//p[@class='row']"):
results.append(xmltodict.parse(tos(el)))
#!/usr/bin/env python
# encoding: utf-8
"""
utc_to_local.py
Example of converting UTC to local time using python-dateutil.
https://pypi.python.org/pypi/python-dateutil
"""
from datetime import datetime
@seanbehan
seanbehan / slurp.rkt
Last active August 29, 2015 14:25 — forked from gatlin/slurp.rkt
#lang racket
(require db)
(require "utils.rkt")
; open a connection to our database
(define (call-with-conn db proc)
(let ([conn (sqlite3-connect #:database db
#:mode 'read/write)])
(proc conn)))
#!/usr/bin/env ruby
# Please read http://otobrglez.opalab.com for more information about this code.
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end

install php

with mysql pgsql intl support

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl

set php timezone in php ini

date.timezone = Europe/Vienna