Skip to content

Instantly share code, notes, and snippets.

View cyu's full-sized avatar

Calvin Yu cyu

View GitHub Profile
@cyu
cyu / submodule_strategy.rb
Created July 5, 2019 00:38 — forked from stevenscg/submodule_strategy.rb
Capistrano deploy strategy that supports git submodules (requires Capistrano v3.1.0 or later)
# 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 04:02
Patch Spree to allow partial refund entry
$(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

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 November 18, 2016 23:50
How to get a Twitter application-only bearer token#
# 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 December 5, 2013 18:39
Protocol relative URLs in Paperclip
# config/initializers/paperclip.rb
require 'paperclip/protocol_relative_url_support'
Paperclip::Attachment.send :include, Paperclip::ProtocolRelativeURLSupport
@cyu
cyu / emma_config.coffee
Created October 16, 2012 05:55
Example connect-emma server
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)
#!/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 February 5, 2011 14:07
A script that created a newspaper like UI for Google Reader (old)
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 February 5, 2011 05:00
Get wallpaper backgrounds from Flickr
#!/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 February 5, 2011 04:53
Hide sidebar in Google Reader (Old)
// ==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