Skip to content

Instantly share code, notes, and snippets.

@t2
t2 / tailwind-colors.js
Last active February 9, 2022 16:30
Visualize your projects Tailwind CSS color pallet.
var http = require('http');
var tailwind = require('./tailwind.config.js');
http
.createServer(function (req, res) {
var html = buildHtml(req);
res.writeHead(200, {
'Content-Type': 'text/html',
'Content-Length': html.length,
const configuration = {
domain: 'https://clover.com/',
merchantId: 'private',
oauthToken: 'private'
};
const devicesUrl = configuration.domain +
"v3/merchants/" + configuration.merchantId +
"/devices?access_token=" + configuration.oauthToken;
onPhotoSourceReq: (request, callback)->
photos = []
$.getJSON('/api/v1/moments/photos', (moments)->
if moments.length > 0
photos = _.flatten(_.map(moments, (m)->
return _.map(m.photos, (p)->
return p
)
))
@t2
t2 / ssh-git-push
Last active January 8, 2020 12:13
Github & Bitbucket (SSH) - Port 22 Blocked
# vi ~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
Host bitbucket.org
Hostname altssh.bitbucket.org
Port 443
@t2
t2 / sidekiq.config
Created February 11, 2015 20:25
Sidekiq on AWS ElasticBeanstalk (64bit Amazon Linux 2014.09 v1.1.0 running Ruby 2.1 (Puma))
# Original: http://www.snip2code.com/Snippet/256399/Amazon-Elastic-Beanstalk-Sidekiq
commands:
create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/etc/rsyslog.d/11-sidekiq.conf":
mode: '000644'
content: |
EB_CONFIG_APP_LOGS=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
@t2
t2 / birthday_liker.rb
Last active September 23, 2016 14:10
Like and Comment on every 'Happy Birthday' post on your Facebook feed at once.
require 'date'
require 'koala'
class BirthdayLiker
FACEBOOK_TOKEN = 'your_oauth_key'
BIRTHDAY_WORDS = %w(birthday bday birfday birth born)
THANKS_OPTIONS = ['Thank you!', 'Thanks!', 'Appreciate it!']
DATE_TIME_FORMAT = '%Y-%m-%d'
def initialize(birthdate, opts={})
@t2
t2 / guild_metaprogramming_example.rb
Last active December 21, 2015 12:08
Simple example of using method missing to dynamically build out an object.
# Below I have a name class. It has no properties defined. I want to be able to dynamically
# build it into what I want. This allows me to not have to write code for every scenario, I can
# let the developer decide what it should include.
class Name
ALLOWED_NAME_PARTS = %w(prefix first middle last suffix)
def initialize(&block)
self.instance_eval(&block) if block_given?
end
@t2
t2 / beta_invite_rake_task.rb
Created August 21, 2013 07:08
Beta Invite Rake Task
namespace :beta_invites do
namespace :phase_one do
desc 'Send Phase 1 Beta Invites to testers.'
task :all => :environment do
BetaInvite.all.uniq{|b| b.email}.each do |invite|
unless invite.email.blank?
email_message = BetaInviteMail.invitation(invite.email)
email_message.deliver
end
end
@t2
t2 / application.html.haml
Created June 1, 2013 01:31
Possible refactor using a decorator for application layout.
!!!
%html
%head
%title= title
= stylesheet_link_tag 'application', :media => 'all'
= stylesheet_link_tag '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css'
= stylesheet_link_tag '//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css'
= javascript_include_tag 'application'
/[if lte IE 8]
<script src="excanvas.compiled.js"></script>
@t2
t2 / Grabber.rb
Last active December 16, 2015 20:10
Script to pull down images from a resource I found on Reddit
# You will need to install nokogiri and rubyzip gems
#
# gem install nokogiri
# gem install rubyzip
require 'nokogiri'
require 'open-uri'
require 'zip/zip'
IMAGES_URL = 'http://files.tinystudios.com/defaults/images/'