Skip to content

Instantly share code, notes, and snippets.

View dinedal's full-sized avatar
👾

Paul Bergeron dinedal

👾
View GitHub Profile
import re
class Trie():
"""Regex::Trie in Python. Creates a Trie out of a list of words. The trie can be exported to a Regex pattern.
The corresponding Regex should match much faster than a simple Regex union."""
def __init__(self):
self.data = {}
@dinedal
dinedal / chronicle.rake
Created February 17, 2012 19:33
Chronicle Migration Script
namespace :chronicle do
desc "Rename Store tags in Chronicle after Accounts integration"
task :migrate_for_accounts, [:client_id] => :environment do |t, args|
client = Client.find(args.client_id)
vitrue_id = client.vitrue_id_for_account.to_s
stores = client.stores
stores.find_each do |store|
old_tag = "s:#{store.id}"
new_tag = "s:#{store.vitrue_id_for_resource}"
# ChronicleClient::Tabs::TagRename.rename(old_tag, new_tag, vitrue_id)
@dinedal
dinedal / send_request.coffee
Created November 7, 2011 22:17
Sample code to send request to Chronicle
http = require 'http'
util= require 'util'
options = {
host: 'api.staging.cloud.vitrue.com',
port: 80,
path: '/chronicle/1/',
method: 'GET',
disable_ssl_peer_verification: true,
timeout: 200
#!/usr/bin/env ruby
queue_length = `/opt/redis-2.2.2/bin/redis-cli zcard q:jobs:total_report:inactive`
begin
if queue_length.to_i > 50000
puts "status ok there are #{queue_length.to_i} jobs"
elsif queue_length > 10000
puts "status warn there are #{queue_length.to_i} jobs"
else
puts "status err there are #{queue_length.to_i} jobs"