Skip to content

Instantly share code, notes, and snippets.

@mcianni
mcianni / template-creator.js
Last active April 26, 2024 17:38 — forked from shivasurya/template-creator.js
AWS SES Email Template Create/Update Script Wrapper
const minify = require("html-minifier").minify;
const fs = require("fs");
const { SESClient, CreateTemplateCommand, UpdateTemplateCommand } = require('@aws-sdk/client-ses');
const sesClient = new SESClient({
region: "us-east-2",
credentials: {
accessKeyId: "XXXXXXXXXXXXXXXXXXX",
secretAccessKey: "XXXXXXXXXXXXXXXXXXXX"
},
# This code is based directly on the Text gem implementation.
# Copyright (c) 2006-2013 Paul Battley, Michael Neumann, Tim Fletcher.
#
# Returns a value representing the "cost" of transforming str1 into str2.
# https://github.com/rails/rails/blob/c994a893c18c0456fd2a30efe4debfc2b18e2508/railties/lib/rails/command/behavior.rb
def levenshtein_distance(str1, str2)
s = str1
t = str2
n = s.length
@mcianni
mcianni / NSDate+RandomDate.h
Last active December 21, 2015 17:24 — forked from Abizern/NSDate+RandomDate.h
Category on NSDate to return a random date in the same year as itself.
//
// NSDate+RandomDate.h
//
//
#import <Foundation/Foundation.h>
@interface NSDate (RandomDate)
- (NSDate *)randomDateInYearOfDate;
@mcianni
mcianni / UIColorFromRGB
Last active September 22, 2015 17:29
UIColorFromRGB
#define UIColorFromRGB(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
blue:((float)((rgbValue & 0x0000FF) >> 0))/255.0 \
alpha:1.0]
module MyGem
class Railtie < Rails::Railtie
initializer "mygem,configure_rails_initializer" do
ApplicationController.before_action( whatever )
end
end
end
@mcianni
mcianni / rbenv-patch
Last active August 29, 2015 14:13 — forked from philou/rbenv-patch
#!/bin/sh
mkdir /tmp/ruby-build-patch
cd /tmp/ruby-build-patch
# download and patch the ruby sources
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar xzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
curl https://raw.github.com/wayneeseguin/rvm/master/patches/ruby/1.9.3/p125/gcdata.patch | patch -p1
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
#default screens
screen -t shell1 0
screen -t shell2 1
screen -t shell3 2
screen -t shell4 3
@mcianni
mcianni / NSBezierPath+Length.h
Last active November 21, 2015 04:34
Category on NSBezierPath to approximate the length of a curve
//
// NSBezierPath+Length.h
//
// Created by mcianni on 10/14/12.
//
#import <Cocoa/Cocoa.h>
@interface NSBezierPath (Length)
- (double)length;