Skip to content

Instantly share code, notes, and snippets.

Avatar

Tobias tordans

View GitHub Profile
@tordans
tordans / google_static_map_helper.rb
Created Oct 17, 2011
Rails Helper to create Google Static Map-Images. Used in StayScout.de
View google_static_map_helper.rb
module GoogleStaticMapHelper
# Creates an image tag for a static google map
# Learn more: http://code.google.com/intl/de-DE/apis/maps/documentation/staticmaps/
# Code inspired by BillyIII's gmap2ozi http://github.com/BillyIII/gmap2ozi/tree/master
# TODO: Helper so ändern, dass er ein array von Adressen aufnimmt, die dann als Marker angezeigt werden. Alternativ müssen es aber Koordinaten sein...
def static_google_map_image_tag(markers, options = {})
options.symbolize_keys!
url = "http://maps.google.com/maps/api/staticmap"
@tordans
tordans / place-url-bookmarklet.js
Created Aug 19, 2011
Bookmarklet: Get a clean, shareable Google Maps Place URL on every Google Maps Place-Page
View place-url-bookmarklet.js
/**
* How to install:
* 1. Open the Firefox or Chrome and Add a new Bookmark-Dialogue
* 2. Copy the line of JS from below and provide whatever name and shortcut-tags you whant
*
* How to use and test it:
* 1. Search for a place in Google Maps, click on the title to get to the place's details page. This is where google could just place a clean place-url in your browser bar but doen't.
* 2. Click the bookmarklet and the Page reloads so you get a clean google place URL in your browser-bar.
* 3. Jump to your browserbar with cmd+L (strg+L) and press strg+c to copy the clean URL.
**/
@tordans
tordans / redirect-secondary-domains.php
Created Aug 15, 2011
Script to track secondary domain redirects.
View redirect-secondary-domains.php
<?php
// Usage:
// - Configure your secondary domain to open this file/folder.
// - The file will redirect to your primary domain with tracking prameters (Google Analytics used below)
// - Optional: Use those tracking parameters in your primary domain's index-file to set an additional tracking-snippet. See example for details. This step is necessary for stayscout since we use eTracker which does not support campaign-tracking by URL but only by calling a script after the page has been rendered.
// Example:
// http://staiscout.de -> redirects to https://stayscout.de/?utm_source=tippfehlerdomain&utm_medium=staiscout-de and adds this JS+jQuery-code at the end of the body-tag for etracker:
// <!-- Tippfehlerdomain-Tracking -->
// <script type='text/javascript'>
@tordans
tordans / gist:1101290
Created Jul 23, 2011
iPhone Simulator starten via Terminal
View gist:1101290
# Start iPhone Simulator
/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator
# Start iPhone Simulator with Performance-Debugging on
# See Paul Irish's Talk http://www.youtube.com/watch?v=q_O9_C2ZjoA#at=830 for details
CA_COLOR_OPAQUE=1 /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator
@tordans
tordans / data-extractor.html
Created Mar 17, 2011
Quick and dirty JavaScript that exports station-data. Find the final dataset at http://goo.gl/iDo0N
View data-extractor.html
<html>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<h1>Find the final data at http://goo.gl/iDo0N</h1>
<table>
<tr>
<td>Station_ID</td><td>Site_ID</td><td>Site_Name_JP</td><td>Site_Name_EN</td><td>Prefecture_ID</td><td>Prefecture_Name_JP</td><td>Prefecture_Name_EN</td><td>Station</td><td>Station_Name_JP</td><td>-</td><td>Station_Name_EN</td><td>Latitude</td><td>Longitude</td>
View ApplyAxureTableStyleToAllTables.bas
Sub ApplyTableStyle()
'
' ApplyTableStyle Makro
' Weist die ausgewählte Tabellenformatvorlage zu.
' More: http://uxzentrisch.de/tipps-fuer-axure-konzepte/
'
' THX @ http://www.wordbanter.com/showthread.php?t=142309
'
Dim t As Table
@tordans
tordans / application_helper.rb
Created Sep 27, 2010
Eine pragmatische Lösung für das Übersetzungsproblem der Rails Methode distance_of_time_in_words(). Im Deutschen wird je nach Satzbau eine andere Ausgabe benötigt.
View application_helper.rb
# ---
# Code gehört in app/helpers/application_helper.rb (oder einen anderen Helper…)
# ---
# Ausgabe: "Vor mehr als 5 Monaten"/"Vor etwa einem Jahr" — statt "Dauer: mehr als 5 Monate"/"Dauer: etwa 1 Jahr", wie es die Originalfunktion liefert
# Original-File: actionpack/lib/action_view/helpers/date_helper.rb, line 63
# Dokumenation: http://apidock.com/rails/v2.3.8/ActionView/Helpers/DateHelper/distance_of_time_in_words
# Changelog: I18n.with_options-Scope geändert auf "distance_in_words_gebeugt"
def distance_of_time_in_words_gebeugt(from_time, to_time = 0, include_seconds = false, options = {})
from_time = from_time.to_time if from_time.respond_to?(:to_time)
You can’t perform that action at this time.