Skip to content

Instantly share code, notes, and snippets.

View madr's full-sized avatar
🤘
Elixir, React, Phoenix Liveview, Rust.

Anders Englöf Ytterström madr

🤘
Elixir, React, Phoenix Liveview, Rust.
View GitHub Profile
@madr
madr / gist:1337116
Created November 3, 2011 17:27
Tackle Outlook 2011 and utf-8 decoded emails
<?php
$subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
// mail( ... )
@madr
madr / gist:1423656
Created December 2, 2011 15:34
Rake target to generate favicons and apple touch icons
# example use:
# rake favicons["../img/origin.png"]
#
# Output:
# ./apple-touch-icon-114x114-precomposed.png
# ./apple-touch-icon-114x114.png
# ./apple-touch-icon-57x57-precomposed.png
# ./apple-touch-icon-57x57.png
# ./apple-touch-icon-72x72-precomposed.png
# ./apple-touch-icon-72x72.png
@madr
madr / gist:1808914
Created February 12, 2012 14:56
Valign=middle without tables, IE6+ compatible
/* @group valignfix */
/* ***************************************
valignfix, by Anders Ytterström @ madr.se
**************************************** */
/*
HTML fixture:
.valign
%div
%div
%h1
@madr
madr / gist:1808920
Created February 12, 2012 14:58
Unobtrusive Anobii badge
var BPs = {};
var AnobiiBadge = (function(){
var BADGE_URL = 'http://widgets.anobii.com/badge_result?settingId=4dd4b3916a743731';
var bodyElm = document.getElementsByTagName('body')[0];
return {
init: function(){
var script = document.createElement('script');
script.src = BADGE_URL;
script.type = 'text/javascript';
bodyElm.appendChild(script);
@madr
madr / gist:1809315
Created February 12, 2012 16:07
Weekly links to Posterous
#!/usr/bin/env ruby
require 'net/https'
require "rexml/document"
require "date"
require 'net/smtp'
# delicious
@username = "YOU"
@password = "secr3t"
@madr
madr / gist:1809354
Created February 12, 2012 16:10
Weekly links to Posterous, simplified
#!/usr/bin/env ruby
require 'net/https'
require "rexml/document"
require "date"
require 'net/smtp'
# delicious
@username = "YOU"
@password = "secr3t"
@madr
madr / gist:1931862
Created February 28, 2012 10:50
Basic front controller for single page applications
/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, curly:true, browser:true, indent:2, maxerr:50 */
/*!
front.js
(c) 2011 Anders Ytterström
front.js may be freely distributed under the MIT license.
TODO: pushState support
*/
/*
@madr
madr / gist:1931955
Created February 28, 2012 11:14
Click listener and delegator
/*!
light-weight click listener, v 1.0
Copyright (c) 2010 by madr <http://madr.se>
Licensed under the MIT license: http://en.wikipedia.org/wiki/MIT_License
*/
/*
Usage:
Alter the below snippet for your needs and put the modified snippet in a js-file or a <script> and add it to your document. If your webapp depends on libraries or other resources to load, you better keep that in mind.
*/
(function(document, undefined) {
@madr
madr / gist:1931992
Created February 28, 2012 11:20
Misc JavaScript Helpers
function adate(daysFromNow) {
var date, datestr, mm, dd;
datestr = new Date().getTime();
if (!!daysFromNow) {
datestr += (1000 * 60 * 60 * 24 * daysFromNow);
}
date = new Date(datestr);
mm = date.getMonth() + '';
if (mm.length == 1) {
mm = '0' + mm;
@madr
madr / gist:1932023
Created February 28, 2012 11:26
Useful sass mixins
/* vertical ruler using pseudo-elements */
@mixin columnseparator {
@extend .relative;
&:before {
content: '';
position: absolute;
top: 0;
width: 3px;
background: #eee;