Skip to content

Instantly share code, notes, and snippets.

Avatar

Calvin Yu cyu

View GitHub Profile
@cyu
cyu / submodule_strategy.rb
Created Jul 5, 2019 — forked from stevenscg/submodule_strategy.rb
Capistrano deploy strategy that supports git submodules (requires Capistrano v3.1.0 or later)
View submodule_strategy.rb
# this include won't work for some reason:
# include Capistrano::Git::DefaultStrategy
module SubmoduleStrategy
# check for a .git directory
def test
test! " [ -d #{repo_path}/.git ] "
end
@cyu
cyu / return_item_selection.js
Created May 31, 2019
Patch Spree to allow partial refund entry
View return_item_selection.js
$(document).ready(function () {
var formFields = $("[data-hook='admin_customer_return_form_fields'], [data-hook='admin_return_authorization_form_fields']")
function checkAddItemBox () {
$(this).closest('tr').find('input.add-item').attr('checked', 'checked')
updateSuggestedAmount()
}
function updateSuggestedAmount (resetRefundAmount) {
var totalPretaxRefund = 0
View keybase.md

Keybase proof

I hereby claim:

  • I am cyu on github.
  • I am cyu (https://keybase.io/cyu) on keybase.
  • I have a public key whose fingerprint is BC74 C49D 6E89 DCE5 B3F6 910F B10F FBC0 158A 7475

To claim this, I am signing this object:

@cyu
cyu / twitter_application_only_token.rb
Last active Nov 18, 2016
How to get a Twitter application-only bearer token#
View twitter_application_only_token.rb
# https://dev.twitter.com/docs/auth/application-only-auth
require 'open-uri'
require "base64"
require 'net/http'
require 'json'
CONSUMER_KEY = 'MY_CONSUMER_KEY'
CONSUMER_SECRET = 'MY_CONSUMER_SECRET'
@cyu
cyu / paperclip.rb
Created Dec 5, 2013
Protocol relative URLs in Paperclip
View paperclip.rb
# config/initializers/paperclip.rb
require 'paperclip/protocol_relative_url_support'
Paperclip::Attachment.send :include, Paperclip::ProtocolRelativeURLSupport
@cyu
cyu / emma_config.coffee
Created Oct 16, 2012
Example connect-emma server
View emma_config.coffee
emmaConfig =
namespaces:
deals: # deal pics optimized for mobile
urlTemplate: 'http://cloud.scoutmob.com/upload/images/deals/$1/original.$extension'
cacheExpiration: 14 * 24 * 60 * 60 # 14 days
processImage: (gm) -> gm.quality(60)
View gmlw.py
#!/usr/bin/env python
#
# This is a modified version of the Gmail Loader application which can be
# here: http://www.marklyon.org/gmail/download.htm
#
# CHANGES:
# * Changed the default SMTP server to smtp.gmail.com (the original one seems
# to be no longer active).
# * Added support for SMTP authentication.
# * Added port number argument for GMail SMTP server.
@cyu
cyu / readerfp.js
Created Feb 5, 2011
A script that created a newspaper like UI for Google Reader (old)
View readerfp.js
var FP_HOST = "http://codeeg.com/readerfp";
var d = '<html>';
d += '<head>';
d += '<link href="' + FP_HOST + '/fp.css" type="text/css" rel="stylesheet"/>';
d += '</head>';
d += '<body>';
d += '<a name="top"/>';
d += '<div id="header"><h1>Google Reader FP</h1>';
d += '<a href="javascript:FP.reload()">Refresh</a>';
d += '</div>';
@cyu
cyu / chg-background.rb
Created Feb 5, 2011
Get wallpaper backgrounds from Flickr
View chg-background.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'flickr'
require 'ftools'
require 'yaml'
API_KEY = "flickr_api_key"
SHARED_SECRET = "flickr_shared_secret"
@cyu
cyu / google_reader_toggle_sidebar.user.js
Created Feb 5, 2011
Hide sidebar in Google Reader (Old)
View google_reader_toggle_sidebar.user.js
// ==UserScript==
// @name Google Reader Toggle Sidebar
// @author Calvin Yu
// @namespace http://blog.codeeg.com/google-reader-enhanced
// @description Enhancements to Google Reader UI
// @license Creative Commons Attribution License
// @version 0.1
// @include http://www.google.com/reader/view/*
// @released 2006-10-01
// @updated 2006-10-01