Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
That worked!

Dominik dommmel

💭
That worked!
View GitHub Profile
@dommmel
dommmel / static_server.js
Last active Aug 1, 2018 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
View static_server.js
#!/usr/bin/env node
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
@dommmel
dommmel / import_into_couchdb.sh
Created Dec 16, 2011
import json files into mongo/couch
View import_into_couchdb.sh
#!/bin/bash
COUCH_DB="http://127.0.0.1:5984/what_ever"
JSON_FOLDER="./jsonFiles/*"
TMP_FILE="/tmp/_couchdb_import.json"
for file in $JSON_FOLDER
do
echo '{"docs":' > $TMP_FILE
cat $file >> $TMP_FILE
View FacebookCategories_de.txt
Album
Amateurmannschaft
Anwendungsseite
Arzneimittel
Attraktionen/Unternehmungen
Ausbildung
Ausflüge/Sehenswürdigkeiten
Automobil
Autor
Autos
@dommmel
dommmel / facebook_batch_api.rb
Created Jun 27, 2012
Takes an array of facebook graph object ids and assembles them into one batch request
View facebook_batch_api.rb
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 Aug 17, 2012
Track clicks with Google Analytics and Mixpanel
View link_tracking.coffee
@dommmel
dommmel / gist:3623754
Created Sep 4, 2012
Twitter Bootstrap Shopify Navbar
View gist:3623754
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top" id="bs_top-menu">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@dommmel
dommmel / localize_greeting.coffee
Created Sep 18, 2012
Localize your greeting message with javascript
View localize_greeting.coffee
##################################################################
# #
# 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 Oct 21, 2012
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.
View create_gallery.rb
@dommmel
dommmel / capture_screenshot.js
Created Jan 8, 2013
Script to take full page screenshots using phantomJs via CasperJs. Run via ```casperjs capture_screenshot.js```
View capture_screenshot.js
var casper = require('casper').create({
viewportSize: {width: 950, height: 950}
});
casper.start('http://www.google.com/', function() {
this.captureSelector('/tmp/pp.png', 'body');
});
casper.run();
View task_scheduler.rb
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