// | |
// | |
// Widon’t for React Native | |
// Simply uses Unicode \u00a0 instead of | |
// | |
// via http://webservices.blog.gustavus.edu/2007/03/20/shaun-inmans-widont-ported-to-javascript/ | |
export const widont = (text) => text.replace(/([^\s])\s+([^\s]+)\s*$/, '$1\u00a0$2') |
// A script to click each download button on this page: https://soundcloud.com/user48736353001/sets/all | |
// run it in the Developer Console in Chrome with the page open. | |
// Worked for me! ¯\_(ツ)_/¯ | |
// I still can't figure out how Metal Beat was recorded. It's INSANE. | |
list = document.getElementsByClassName('sc-button-download') | |
[].forEach.call(list, function(el) { | |
var evt = document.createEvent("MouseEvents") | |
evt.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null) | |
el.dispatchEvent(evt) | |
}) |
# replace file basename with a UUID when uploaded | |
# e.g.: avatar.jpg becomes 41bf830f-80cf-4efe-ad90-3b29bc6708b5.jpg | |
# but don't regenerate a UUID each time file url is accessed | |
class User < ActiveRecord::Base | |
has_attached_file :avatar, path: ":basename.:extension" | |
before_validation { set_avatar_file_name } | |
def set_avatar_file_name | |
# replace any NEW filename with a UUID |
Once you have Imgix setup to pull in images from your server, you'll want to tell Rails which assets to serve via Imgix and which to serve directly.
Something like the following in config/environments/production.rb
will help:
config.action_controller.asset_host = Proc.new { |source|
if source.ends_with?('.jpg') || source.ends_with?('.gif') || source.ends_with?('.png')
# the image host
A spoonerism is “an error in speech or deliberate play on words in which corresponding consonants, vowels, or morphemes are switched (see metathesis) between two words in a phrase”.
Please help me compile a list of actual artists (e.g.: released music, maybe even toured) whose names are permutations of the names of other artists or celebrities.
- Berry Weight
- Bupsin Jieber
- Com Truise
- Edit Murphy
- Gnarls Barkley
- Hoodie Allen
Vagrant 1.6 has a really nice feature which allows you to run a docker environment from any machine that can run Vagrant (even a Mac)
Behind the scenes, Vagrant creates a host VM which runs the docker containers.
The "gotcha" is: Vagrant won't automatically forward ports all the way back from the container->vagrant host VM->your mac. You have to do that step manually, by configuring your own host VM for Vagrant to use for hosting docker containers with. That host VM is told what ports to open.
Here's how I set up a local Wordpress development testing container.
# via http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect | |
# http://mathworld.wolfram.com/Line-LineIntersection.html | |
getLineIntersection = (x1, y1, x2, y2, x3, y3, x4, y4) -> | |
s1_x = x2 - x1 | |
s1_y = y2 - y1 | |
s2_x = x4 - x3 | |
s2_y = y4 - y3 | |
s = (-s1_y * (x1 - x3) + s1_x * (y1 - y3)) / (-s2_x * s1_y + s1_x * s2_y) | |
t = (s2_x * (y1 - y3) - s2_y * (x1 - x3)) / (-s2_x * s1_y + s1_x * s2_y) |
The best way to do this is probably via docker volumes. For dokku, check out dokku-persistent-storage
But here's a quick hack using netcat anyway.
Assuming we've found the container ID (e.g.: via docker ps
):
$ CID=f7a29d6dc8e4
# token.rb | |
# A minimal re-usable module for "token" slugs on ActiveRecord models (AKA shortcodes, tiny urls) | |
# | |
# USAGE | |
# | |
# class Project < ActiveRecord::Base | |
# include Token | |
# end | |
# | |
# see also: |