Skip to content

Instantly share code, notes, and snippets.

@eikes
eikes / gist:5a64b661022c756bd6522ed94770e2a6
Created July 4, 2016 14:02
List of Ruby on Rails Timezone names and their alias
["Africa/Algiers", "West Central Africa"],
["Africa/Cairo", "Cairo"],
["Africa/Casablanca", "Casablanca"],
["Africa/Harare", "Harare"],
["Africa/Johannesburg", "Pretoria"],
["Africa/Monrovia", "Monrovia"],
["Africa/Nairobi", "Nairobi"],
["America/Argentina/Buenos_Aires", "Buenos Aires"],
["America/Bogota", "Bogota"],
["America/Caracas", "Caracas"],
@eikes
eikes / run phoenix on amazon linux.sh
Created December 28, 2015 22:29
run phoenix on amazon linux
# app deps
sudo yum install git
# erlang deps
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel
# erlang
wget http://www.erlang.org/download/otp_src_18.1.tar.gz
tar -zxvf otp_src_18.1.tar.gz
@eikes
eikes / .__mini_rails__
Last active March 15, 2023 13:27
Single file rails app
__mini_rails__
@eikes
eikes / getTimezone.js
Created February 15, 2012 14:39
Get or estimate browsers timezone name in JavaScript
var d = new Date();
var usertime = d.toLocaleString();
// Some browsers / OSs provide the timezone name in their local string:
var tzsregex = /\b(ACDT|ACST|ACT|ADT|AEDT|AEST|AFT|AKDT|AKST|AMST|AMT|ART|AST|AWDT|AWST|AZOST|AZT|BDT|BIOT|BIT|BOT|BRT|BST|BTT|CAT|CCT|CDT|CEDT|CEST|CET|CHADT|CHAST|CIST|CKT|CLST|CLT|COST|COT|CST|CT|CVT|CXT|CHST|DFT|EAST|EAT|ECT|EDT|EEDT|EEST|EET|EST|FJT|FKST|FKT|GALT|GET|GFT|GILT|GIT|GMT|GST|GYT|HADT|HAEC|HAST|HKT|HMT|HST|ICT|IDT|IRKT|IRST|IST|JST|KRAT|KST|LHST|LINT|MART|MAGT|MDT|MET|MEST|MIT|MSD|MSK|MST|MUT|MYT|NDT|NFT|NPT|NST|NT|NZDT|NZST|OMST|PDT|PETT|PHOT|PKT|PST|RET|SAMT|SAST|SBT|SCT|SGT|SLT|SST|TAHT|THA|UYST|UYT|VET|VLAT|WAT|WEDT|WEST|WET|WST|YAKT|YEKT)\b/gi;
// In other browsers the timezone needs to be estimated based on the offset:
var timezonenames = {"UTC+0":"GMT","UTC+1":"CET","UTC+2":"EET","UTC+3":"EEDT","UTC+3.5":"IRST","UTC+4":"MSD","UTC+4.5":"AFT","UTC+5":"PKT","UTC+5.5":"IST","UTC+6":"BST","UTC+6.5":"MST","UTC+7":"THA","UTC+8":"AWST","UTC+9":"AWDT","UTC+9.5":"ACST"
@eikes
eikes / getElementsByClassName.polyfill.js
Created April 4, 2012 08:04
Polyfill for getElementsByClassName
// Add a getElementsByClassName function if the browser doesn't have one
// Limitation: only works with one class name
// Copyright: Eike Send http://eike.se/nd
// License: MIT License
if (!document.getElementsByClassName) {
document.getElementsByClassName = function(search) {
var d = document, elements, pattern, i, results = [];
if (d.querySelectorAll) { // IE8
return d.querySelectorAll("." + search);
@eikes
eikes / .block
Last active July 2, 2020 14:45 — forked from mbostock/.block
South up map
license: gpl-3.0
@eikes
eikes / jquery.uncheckable_radio.js
Created March 11, 2014 11:42
jQuery plugin to allow unchecking radio buttons
(function ($) {
$.fn.uncheckableRadio = function () {
return this.each(function () {
var radio = this,
label = $('label[for="' + radio.id + '"]');
if (label.length === 0) {
label = $(radio).closest("label");
}
var label_radio = label.add(radio);
label_radio.mousedown(function () {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eikes
eikes / imgpreload.js
Created October 20, 2012 23:23
JavaScript image preloader with callback
/*
* Copyright (C) 2012 Eike Send
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
{% block collection_widget %}
{% spaceless %}
<div class="collection">
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form) }}
<ul>
{% for prototype in form %}