Skip to content

Instantly share code, notes, and snippets.

Michael muescha

  • Cologne, Germany
Block or report user

Report or block muescha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View super.rb
# [] - Eqauls to
# ^ - Not equals to
# =~ - LIKE
# >, >=, <, <= works as expected
#
# Examples :
#
# Item.where(:colour['Red'], :quanity > 10, :price <= 200)
# Post.where(:comments_count >= 1, :taggings_count < 5)
# User.where(:country ^ 'US') # Non american users
@dimus
dimus / Hash.from_xml using Nokogiri
Created Mar 17, 2010
Adding Hash.from_xml method using Nokogiri
View Hash.from_xml using Nokogiri
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
return { result.root.name.to_sym => xml_node_to_hash(result.root)}
@ParkinT
ParkinT / Rakefile
Last active Oct 7, 2015
RubyMotion Rakefile - improved workflow
View Rakefile
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
# custom rake tasks
require '../raketasks/gemerator.rb'
desc "Open latest crash log"
task :log do
app = Motion::Project::App.config
View gist:3832504
#!/usr/bin/env ruby
def get_values(string, expression)
regex = Regexp.new(expression.gsub(/\{([^\}]+)\}/) { "(?<#{$1}>\\S+)" })
(match = regex.match(string)) ? Hash[match.names.zip(match.captures)] : {}
end
p get_values "Alice is 23 years old", "{name} is {age} years old" #=> {"name"=>"Alice", "age"=>"23"}
@niloc132
niloc132 / Sample.gwt.xml
Created Oct 17, 2012
Make more premutations for both small builds and bigger builds with full stack traces. Just add debug=true to the querystring of app's url, reproduce the issue, and read the trace!
View Sample.gwt.xml
<set-property name="compiler.emulatedStack" value="true, false" />
<property-provider name="compiler.emulatedStack">
<![CDATA[return (location.search.indexOf("debug=true") != -1) ? "true" : "false";]]>
</property-provider>
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true" />
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true" />
@dnshl
dnshl / Rakefile
Created Nov 21, 2012
Rake Task with XMLFormatter for cucumber and XSLT Document
View Rakefile
require 'gherkin/parser/parser'
require 'gherkin/formatter/json_formatter'
require 'stringio'
require "active_support/core_ext/hash/conversions"
require 'nokogiri'
class XMLFormatter < Gherkin::Formatter::JSONFormatter
def done
@io.write(@feature_hashes.to_xml)
end
View gist:416e172d879304af04ad

Updating rbenv Ruby to use newer OpenSSL versions

rbenv/ruby-build don’t use Homebrew-installed versions of OpenSSL — instead, they on OS X's built-in ancient version.

This can throw OpenSSL::SSL::SSLErrors when talking to websites that enforce newer SSL/TLS protocols and ciphersuites.


1: Dependencies

@carlhoerberg
carlhoerberg / gist:976228
Created May 17, 2011
How to list DataMapper enum options
View gist:976228
class Entity
include DataMapper::Resource
property :enum_property, Enum[:a, :b, :c]
end
Entity.enum_property.options[:flags] #=> [:a, :b, :c]
# or
Entity.enum_property.flag_option.values #=> [:a, :b, :c]
@MicahChalmer
MicahChalmer / .htaccess
Last active May 1, 2016
Scripts to set up Ruby 1.9.3 on a DreamHost shared hosting account via rbenv and ruby-build, and run a Rack app with it via FastCGI.
View .htaccess
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>
Options +FollowSymLinks +ExecCGI
RewriteEngine On
@Sawascwoolf
Sawascwoolf / webWincPartnernetChart.user.js
Created Jul 19, 2016
Zeigt die Einnahmen des Partnernetberichts "Tracking-ID Kurzbericht" in einer Grafik an
View webWincPartnernetChart.user.js
// ==UserScript==
// @name webWincPartnernetChart
// @namespace webWinc
// @include https://partnernet.amazon.de/*
// @version 1
// @grant GM_setValue
// @grant GM_getValue
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// @require https://code.highcharts.com/stock/highstock.js
// ==/UserScript==
You can’t perform that action at this time.