Skip to content

Instantly share code, notes, and snippets.

View dommmel's full-sized avatar
💭
That worked!

Dominik dommmel

💭
That worked!
View GitHub Profile
@dommmel
dommmel / FacebookCategories_de.txt
Created April 5, 2012 09:03
List of Facebook Categories (obtained via https://gist.github.com/2173940)
Album
Amateurmannschaft
Anwendungsseite
Arzneimittel
Attraktionen/Unternehmungen
Ausbildung
Ausflüge/Sehenswürdigkeiten
Automobil
Autor
Autos
@dommmel
dommmel / facebook_batch_api.rb
Created June 27, 2012 16:24
Takes an array of facebook graph object ids and assembles them into one batch request
def fb_batch_request(id_array, access_token)
raise "Array to long (>20)" if id_array.length > 20
queries = id_array.map { |id| {:method => 'GET', :relative_url => "#{id}"} }
route = "https://graph.facebook.com/?access_token=#{access_token}&batch=#{URI.encode(queries.to_json)}"
HTTParty.post(route)
end
@dommmel
dommmel / link_tracking.coffee
Created August 17, 2012 12:02
Track clicks with Google Analytics and Mixpanel
@dommmel
dommmel / localize_greeting.coffee
Created September 18, 2012 13:43
Localize your greeting message with javascript
##################################################################
# #
# Copyright (C) 2012 Dommmel <dommmel@gmail.com> #
# This code is released under WTFPL, version 2.0. #
# #
##################################################################
# Usage:
# <span id="sayhi">привет</span>
# <script>
@dommmel
dommmel / create_gallery.rb
Created October 21, 2012 15:18
Turns a folder of images into an html gallery (optimized for mobile safari). Useful for previewing designs of mobile websites. Just put the generated gallery into dropbox and mail the link to the index.html file to the client.
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new
if Rails.env.production?
scheduler.every '10m' do
require "net/http"
require "uri"
Net::HTTP.get_response(URI.parse(ENV["HOSTNAME"]))
end
end
<!DOCTYPE html>
<html><head></head>
<!-- Standard Facebook Initialization -->
<body>
<div id="fb-root"></div>
<button>Loading...</button>
<script>
@dommmel
dommmel / generate_favicon.sh
Created March 12, 2013 17:39
Generate multi-resolution favicon with imagemagick
convert logo-solo.png -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
-delete 0 -transparent white -colors 256 favicon.ico
@dommmel
dommmel / random_refresh.js
Created June 4, 2013 10:11
refresh page on random intervals
function doSomething() {
open(location.href, 'refreshingWindow');
}
(function loop() {
var rand = Math.round(Math.random() * (10000)) + 1000;
setTimeout(function() {
doSomething();
loop();
}, rand);
@dommmel
dommmel / jquery.smoothscroll.js
Created July 4, 2013 09:35
jQuery smooth scroll to anchor
// use it like this: <a class="scroll" href="#destination1">Destination 1</a>
// <section id="destination1">Lore ipsum</section>
$(".scroll").click(function(event){
event.preventDefault();
//calculate destination place
var dest=0;
if($(this.hash).offset().top > $(document).height()-$(window).height()){
dest=$(document).height()-$(window).height();
}else{