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 / hide_adress_bar.js
Created September 13, 2013 11:14
Hide adress bar on iphone/android
// Hide adress bar on iphone/android
$(function() {
function hideURLbar() {
if (window.location.hash.indexOf('#') == -1) {
window.scrollTo(0, 1);
}
};
if (navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('Android') != -1) {
addEventListener("load", function() {
setTimeout(hideURLbar, 0);
@dommmel
dommmel / Info.plist
Created October 10, 2013 10:44
Dial tel:// and sip:// links on your snom phone
<!-- add this to the dict node -->
<key>CFBundleIdentifier</key>
<string>com.apple.AppleScript.SnomDialer</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>SnomDialer</string>
<key>CFBundleURLSchemes</key>
-- Addressbook to SNOM export
-- Be sure to open Contacts app before running this script
set resultText to ""
set currentLine to ""
set numPhones to 0
tell application id "com.apple.AddressBook"
set the clipboard to people's vcard
-- Find the maximum number of phone numbers
repeat with x from 1 to the count of people
@dommmel
dommmel / gravatar.coffee
Created October 17, 2013 13:11
Retrieve Gravatar indenticon for a given email address via javascript. You need to include a md5 library (like http://www.myersdaily.org/joseph/javascript/md5-text.html)
# get the url of an emails gravatar image
#
# default_image can either be an image url or one of the following: mm, identicon, monsterid, wavatar, retro, blank
# (See https://de.gravatar.com/site/implement/images/ for all options)
#
# Example usage:
# get_gravatar_image_url("example@example.com", 80, "retro")
get_gravatar_image_url = (hashed_email, size=80, default_image="mm", force_default=false) ->
size = (if (size >= 1 and size <= 2048) then size else 80)
@dommmel
dommmel / miner.rb
Created January 24, 2014 14:55
Stripe-CTF Level-1
require 'digest/sha1'
@ctf_username = "user-8lmmcgvw"
def addToLedger
user_in_ledger = false
File.open("LEDGER.txt").each_line do |line|
if line.match(/^#{@ctf_username}:/)
user_in_ledger = true
end
@dommmel
dommmel / hide_payment-gateway_unless_customer_has_tag.rb
Last active December 12, 2017 14:48
Shopify Script to enable payment gateway only for customer with a certain tag
PAYMENT_GATEWAY_NAME = 'Invoice'
CUSTOMER_TAG = 'VIP'
customer = Input.cart.customer
remove_gateway = (customer.nil? or !customer.tags.include?(CUSTOMER_TAG))
if remove_gateway
Output.payment_gateways = Input.payment_gateways.delete_if do |payment_gateway|
payment_gateway.name == PAYMENT_GATEWAY_NAME
end
@dommmel
dommmel / mamp_function
Last active March 24, 2018 20:10 — forked from jonathanstark/mamp_function
Serve the current directory with MAMP from the command line
function mamp() {
#
# Default location of the apache conf file for MAMP
CONF_FILE="/Applications/MAMP/conf/apache/httpd.conf"
#
# Fish existing doc root out of conf file
LINE=$(cat $CONF_FILE | grep "^DocumentRoot")
QUOTED_STRING=${LINE/DocumentRoot /}
OLD_DOC_ROOT=${QUOTED_STRING//\"/}
#
@dommmel
dommmel / static_server.js
Last active August 1, 2018 13:29 — 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.
#!/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 / celluloid_pool.rb
Last active August 15, 2018 12:39
Parallelizing long running requests with celluloid
require 'celluloid'
require "benchmark"
require 'open-uri'
delay_seconds = [4,4,4,4,4,4]
BASE_URL = "http://slowapi.com/delay"
class Crawler
include Celluloid
def read(delay)
@dommmel
dommmel / capture_screenshot.js
Created January 8, 2013 10:00
Script to take full page screenshots using phantomJs via CasperJs. Run via ```casperjs 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();