Skip to content

Instantly share code, notes, and snippets.

View muescha's full-sized avatar

Muescha muescha

View GitHub Profile
# [] - 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
@ParkinT
ParkinT / Rakefile
Last active October 7, 2015 07:18
RubyMotion Rakefile - improved workflow
# -*- 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
#!/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"}
@dnshl
dnshl / Rakefile
Created November 21, 2012 15:27
Rake Task with XMLFormatter for cucumber and XSLT Document
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

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 09:59
How to list DataMapper enum options
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 16:49
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.
<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 July 19, 2016 16:46
Zeigt die Einnahmen des Partnernetberichts "Tracking-ID Kurzbericht" in einer Grafik an
// ==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==
@david-mark
david-mark / gist:3279190
Created August 6, 2012 22:47
Sencha Touch Still Sucks

Was asked to look at this thing again; only reviewed the JS portion. Last I checked, the CSS was similarly reality-challenged. Graphics are nice, but are tantamount to the paint job on a used car. Under the hood, this thing is all junk. It's hard to imagine the innards of any Web or mobile device-based application would end up like this, which raises the question of whether the authors have ever written such applications (or any amount of meaningful JS).

/**
 * @class Ext
 * @singleton

There (still) are no "classes" or "singletons" in JS (starting off on the wrong foot by mangling JS terms).

@kiliankoe
kiliankoe / MapView.swift
Created September 30, 2019 20:10
3D MapKit Views
import SwiftUI
struct MapView: UIViewRepresentable {
var coordinate: CLLocationCoordinate2D
func makeUIView(context: Context) -> MKMapView {
MKMapView(frame: .zero)
}
func updateUIView(_ view: MKMapView, context: Context) {