Skip to content

Instantly share code, notes, and snippets.

@alexspeller
alexspeller / base64encode.js.coffee
Last active December 21, 2015 04:38
Ember Table Extensions
# So, this is pretty horrible. If we just encode using btoa, any UTF-8 chars cause an error.
# If we use either of the workarounds on MDN[1], the £ sign is encoded wrong. I suspect
# Excel totally sucking at encodings is the reason why. So, the workaround is, to use
# the MDN workaround on chars with values > 255, and allow chars 0-255 to be encoded
# as is with btoa. Note that if you use either of the workarounds on MDN, chars
# 128-255 will be encoded as UTF-8, which includeds the £ sign. This will cause excel
# to choke on these chars. Excel will still choke on chars > 255, but at least the £
# sign works now...
# [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding
@bantic
bantic / bucket_sync_service.rb
Created November 15, 2012 19:47
ruby class to copy from one aws s3 bucket to another
require 'aws/s3' # gem name is 'aws-sdk'
class BucketSyncService
attr_reader :from_bucket, :to_bucket, :logger
attr_accessor :debug
DEFAULT_ACL = :public_read
# from_credentials and to_credentials are both hashes with these keys:
# * :aws_access_key_id
@ZenCocoon
ZenCocoon / _zepto-jquery.html.erb
Created August 11, 2012 17:43
Zepto + jQuery on CDN + local support. Ready for Rails 3.1+ with asset pipeline
<script>
document.write('<script src=//' + ('__proto__' in {} ? 'cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/zepto' : 'ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery') + '.min.js><\/script>')
</script>
<script>
if ('__proto__' in {})
window.Zepto || document.write('<script src="assets/libs/zepto.min.js"><\/script>')
else
window.jQuery || document.write('<script src="assets/libs/jquery.min.js"><\/script>')
</script>
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active April 2, 2024 20:18
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@mikebannister
mikebannister / gist:1216893
Created September 14, 2011 15:34
Rails engine w/ Rspec

NOTE!!!!!!!!! Ended up in trouble going down this path. Followed Rails 3 in Action method instead

generate

rails plugin new importable --dummy-path=spec/dummy --full --mountable && cd importable

in .gitignore change references to test/dummy to spec/dummy (rails bug¿)

spec/dummy/db/*.sqlite3

spec/dummy/log/*.log

@jkamenik
jkamenik / proxy.rb
Created August 17, 2011 13:01
Sinatra Proxy
res = Net::HTTP.start(<server>,<port>) do |http|
http.get <url>
end
res.body
@soupmatt
soupmatt / zzz_pow.conf
Created July 1, 2011 13:51
Apache reverse proxy config for pow
<VirtualHost *:80>
ServerName pow
ServerAlias *.dev
ServerAlias *.xip.io
ProxyPass / http://localhost:20559/
ProxyPassReverse / http://localhost:20559/
ProxyPreserveHost On
</VirtualHost>
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end