Skip to content

Instantly share code, notes, and snippets.

View momolog's full-sized avatar

Alexander Presber momolog

View GitHub Profile
@momolog
momolog / hoverchange html
Last active August 29, 2015 13:56
Change a link content on over
<a href="target" data-hovertext="Hover Text">
Normal Text
</a>
@momolog
momolog / markup
Last active August 29, 2015 13:57
pure CSS show / hide
<div id="container" class="outline outline-big toggle-on-hover-switch">
<b>.toggle-on-hover-switch</b>
<div id="out" class="outline toggle-on-hover-hide">
<b>.toggle-on-hover-hide</b><br/>
I disappear.
I disappear.
I disappear.
I disappear.
</div>
<div id="in" class="outline toggle-on-hover-show">
#!/usr/bin/env ruby
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-l", "--localdb DBNAME", "local DB name") do |ldb|
options[:local_db_name] = ldb
@momolog
momolog / broken
Created September 1, 2014 13:13
broken input for wkhtml2pdf
<html>
<body>
<img src="http://example.com/test.jpg?332534" />
</body>
</html>
@momolog
momolog / test.html
Created September 24, 2014 11:58
wkhtmltopdf and packery
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" charset="utf-8" src="packery.pkgd.min.js"></script>
<script type="text/javascript" charset="utf-8">
window.onload = function(){
var debug = document.querySelector('#debugger');
debug.innerHTML += "<h1>Hello</h1>";
debug.innerHTML += Packery;
@momolog
momolog / setCustomValidity.coffee
Created September 29, 2014 09:32
How to set a custom validation message for HTML5 form inputs
$ ->
if Modernizr.input.pattern
$(document).bind 'change', (e) ->
$el = $(e.target)
$el[0].setCustomValidity ''
if $el[0] in document.querySelectorAll(':invalid')
if message = $el.data('invalidmessage')
$el[0].setCustomValidity message
@momolog
momolog / gpb
Created March 13, 2015 11:11
~/bin/gpb
#!/usr/bin/env ruby
## git-publish-branch: a simple script to ease the unnecessarily complex
## task of "publishing" a branch, i.e., taking a local branch, creating a
## reference to it on a remote repo, and setting up the local branch to
## track the remote one, all in one go. you can even delete that remote
## reference.
##
## Usage: git publish-branch [-d] <branch> [repository]
##
<html>
<head>
<script data-main="index" src="require.js"></script>
</head>
<body></body>
</html>
require 'rubygems'
require 'right_aws'
aws_access_key_id = 'YOUR AMAZON ACCESS KEY'
aws_secret_access_key = 'YOUR AMAZON SECRET ACCESS KEY'
source_bucket = 'SOURCE BUCKET NAME'
target_bucket = 'TARGET BUCKET NAME'
prefixes = [PATH_PREFIX1, PATH_PREFIX2, ...]
s3 = RightAws::S3Interface.new(aws_access_key_id, aws_secret_access_key)
@momolog
momolog / delayed_singleton.rb
Created September 24, 2015 13:36
Delayed Job Singleton
module DelayedSingleton
# this first checks whether the same job has already been enqueued.
# if not, it enqueues it to run in one minute
def enqueue_singleton job, at = 1.minute.from_now
unless Delayed::Job.where(:handler => job.to_yaml).any?
Rails.logger.warn "enqueuing singleton job #{job.class.name}"
Delayed::Job.enqueue(job, run_at: at.getutc )
end
end