Skip to content

Instantly share code, notes, and snippets.

Muescha muescha

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 / 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
class Hash
class << self
def from_xml(xml_io)
result = Nokogiri::XML(xml_io)
return { => xml_node_to_hash(result.root)}
ParkinT / Rakefile
Last active Oct 7, 2015
RubyMotion Rakefile - improved workflow
View Rakefile
# -*- coding: utf-8 -*-
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 =\{([^\}]+)\}/) { "(?<#{$1}>\\S+)" })
(match = regex.match(string)) ? Hash[] : {}
p get_values "Alice is 23 years old", "{name} is {age} years old" #=> {"name"=>"Alice", "age"=>"23"}
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
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 / 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]
Entity.enum_property.options[:flags] #=> [:a, :b, :c]
# or
Entity.enum_property.flag_option.values #=> [:a, :b, :c]
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 mod_fcgid.c>
AddHandler fcgid-script .fcgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
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*
// @version 1
// @grant GM_setValue
// @grant GM_getValue
// @require
// @require
// ==/UserScript==
seanlilmateus / gist:3187192
Last active Sep 2, 2016
How to use Obj-C with MacRuby/Rubymotion
View gist:3187192

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }
You can’t perform that action at this time.