This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A(x1|y1) und B(x2|y2) = Touch start | |
// C(x3|y3) und D(x4|y3) = Current touch point | |
// Vektor AB | |
var AB_x = x2 - x1; | |
var AB_y = y2 - y1; | |
// Vektor CD | |
var CD_x = x4 - x3; | |
var CD_y = y4 - y3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
# brew-services(1) - Easily start and stop formulas via launchctl | |
# =============================================================== | |
# | |
# ## SYNOPSIS | |
# | |
# [<sudo>] `brew services` `list`<br> | |
# [<sudo>] `brew services` `restart` <formula><br> | |
# [<sudo>] `brew services` `start` <formula> [<plist>]<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HANDLE hClient = NULL; | |
PWLAN_INTERFACE_INFO_LIST pIntfList = NULL; | |
DWORD negotiatedVersion = 0; | |
DWORD res = 0; | |
int i = 0; | |
// get handle | |
res = WlanOpenHandle(WLAN_API_VERSION, NULL, &negotiatedVersion, &hClient); | |
if (res != ERROR_SUCCESS) { | |
if (hClient != NULL) WlanCloseHandle(hClient, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LINK_ONLY = { | |
:elements => %w{a}, | |
:attributes => { | |
'a' => %w{href} | |
}, | |
:add_attributes => { | |
'a' => { 'rel' => 'external nofollow' } | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TelHelper | |
# Erstellt einen <a href="tel:..."> link. | |
def tel_to(telephone_number, name = nil, html_options = {}) | |
href = html_escape telephone_number.to_s.strip.sub(/\A\+/, '00').gsub(/(\(.+\))/, '').gsub(/[^\d]/, '') | |
content_tag "a", name || telephone_number, html_options.stringify_keys.merge("href" => "tel:#{href}".html_safe) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -w | |
require 'rubygems' | |
require 'optparse' | |
require 'rack' | |
# setup options | |
options = { :Port => 4000, :Host => "0.0.0.0" } | |
opt_parser = OptionParser.new do |opts| | |
opts.banner = "Usage: serveme [-p PORT] [-h HOST] [-s thin|webrick|...]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'nokogiri' | |
puts "Platform: #{RUBY_PLATFORM}" | |
puts "Nokogiri: #{Nokogiri::VERSION}" | |
xml = <<XML | |
<foo:bar> | |
<some>value</some> | |
<other>1234</other> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"took" : 45, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 4, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Provides the ability to unscope associations, this solves problems described in | |
# http://stackoverflow.com/questions/1540645/how-to-disable-default-scope-for-a-belongs-to/11012633#11012633 | |
# | |
# Examples | |
# | |
# class Document < ActiveRecord::Base | |
# default_scope where(deleted: false) | |
# end | |
# | |
# class Comment < ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#compdef rbfu | |
local curcontext="$curcontext" state line _rubies _rubies_dir ret=1 | |
_arguments -w -S \ | |
'(-)--help[show usage and exit]: :->noargs' \ | |
'1: :->versions' \ | |
'*::: :->args' && ret=0 | |
case $state in |