Skip to content

Instantly share code, notes, and snippets.

@twetzel
twetzel / gh-pages-deploy.md
Created February 12, 2020 09:16 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@twetzel
twetzel / gist:bc60165661975b95c4964c803f84ecec
Last active August 28, 2017 21:39 — forked from prasofty/gist:2487410
Disable remote links after click in rails 3 +
$('a[data-remote=true]').on('ajax:before', function () {
if ($(this).hasClass('ajax-loading')) {
return false;
} else {
$(this).addClass('ajax-loading', true);
}
}).on('ajax:complete', function () {
$(this).removeClass('ajax-loading');
});
@twetzel
twetzel / simple-capistrano-docker-deploy.rb
Created August 23, 2017 20:37 — forked from johnbintz/simple-capistrano-docker-deploy.rb
Simple Capistrano deploy for a Docker-managed app
# be sure to comment out the require 'capistrano/deploy' line in your Capfile!
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'my-cool-application'
# the base docker repo reference
set :name, "johns-stuff/#{fetch(:application)}"
<!-- solution 1, 117b, inspired by http://www.p01.org/releases/140bytes_music_softSynth/ -->
<button onclick="new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(1e3).join(123)).play()">Beep</button>
<!-- Solution 2, 107b, inspired by http://xem.github.io/chip8/c8.html -->
<button onclick="o=(A=new AudioContext()).createOscillator();o.connect(A.destination);o.start(0);setTimeout('o.stop(0)',500)">Boop</button>
@twetzel
twetzel / db.coffee
Last active September 5, 2015 21:39 — forked from jaigouk/db.coffee
Riot.js Todo MVC in coffeescript https://github.com/moot/riotjs
DB = (key) ->
store = window.localStorage
get: ->
JSON.parse store[key] or "{}"
put: (data) ->
store[key] = JSON.stringify(data)
// for demo: http://jsbin.com/jeqesisa/7/edit
// for detailed comments, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " this.name == 'Sam' && this.age === '12' " }}
// config/environment.js
// This is not for production. But it will get your
// console to stop screaming errors if your messing
// around with ember cli
module.exports = function(environment) {
//lots of stuff
// <Add this chunk>
@twetzel
twetzel / some_controller.rb
Created September 3, 2014 11:37
pull phraseapp translations in controller action
# ..
def pull_translations
if system('phrase pull --format=yml')
I18n.backend.reload!
redirect_to :back, notice: "Pulled translations from PhraseApp! :)"
else
redirect_to :back, alert: "Couldn't pull translations from PhraseApp! :("
end
end
@twetzel
twetzel / page.css
Last active August 29, 2015 14:06
workaround to show nested translations for phraseapp on-page editor
.no_view_translation {
display: none; position: relative;
margin: 0; padding: 0;
}
body.tranlating_phrase .no_view_translation {
display: block;
width: auto; height: auto;
opacity: .5;
}
@twetzel
twetzel / activerecord.de.yml
Created September 3, 2014 10:27
example label translation including active-record and active-model attributes
de:
attributes: &activerecord_attributes
user: &users_labels
email: "E-Mail"
name: "Name"
first_name: "Vorname"
last_name: "Nachname"
remember_me: "Angemeldet bleiben"
user:
one: "Nutzer"