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 / poker_combo_ranks.csv
Created January 6, 2023 04:57
Poker combo ranks
rank combo
1 AA
2 KK
3 QQ
4 AKs
5 JJ
6 AQs
7 KQs
8 AJs
9 KJs
.aaa
.aarp
.abarth
.abb
.abbott
.abbvie
.abc
.able
.abogado
.abudhabi
@seanbehan
seanbehan / app.py
Last active November 20, 2022 17:31
Create a multi site Flask application using Blueprints. This app will match hostname to serve a distinct application.
# set up /etc/hosts
# 127.0.0.1 site1.loc site2.loc
from flask import (
Flask
)
import site1, site2
app = Flask(__name__)
@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 / Desktop Uploader Ideas.md
Created July 2, 2019 00:47
Desktop Uploader Ideas
  • Menu bar animated status icon, showing upload progress

  • Tray/opened app icon (with badge showing upload progress)

  • Share from Finder/File Explorer

  • Search for folder

  • Add new folder

  • Sync a folder (would be kind of cool)

  • Show file sizes in preview

  • animate progress bars in desktop uploader

function Hello(props){
let msg
if(props.name==="World"){
msg = <b>Hello Earth</b>
} else {
msg = <i>{props.name}</i>
}
return (
<div>
@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()) {
@seanbehan
seanbehan / url-params-extension.swift
Created September 23, 2018 20:11
parse url params in swift with an extension
extension URL {
// Usage:
// URL(string:"http://.../?x=1&y=2").params()
func params() -> [String:Any] {
var dict = [String:Any]()
if let components = URLComponents(url: self, resolvingAgainstBaseURL: false) {
if let queryItems = components.queryItems {
for item in queryItems {