Skip to content

Instantly share code, notes, and snippets.

@nlinn
nlinn / gist:5199733
Last active December 15, 2015 04:09
Wir wollen mit Dir Abschied feiern
Liebes blau-Team,
wir möchten uns für die tolle Zusammenarbeit in den letzten Jahren persönlich bedanken
und laden daher alte und neue Kollegen, Freelancer und Wegbegleiter ein, mit uns auf
die spannende, lehrreiche und manchmal auch anstrengende Zeit anzustoßen, die nun
hinter uns liegt.
Wir treffen uns an einem für blau vertrauten Ort
im 13. Stock (Max-Brauer-Allee 277, Ecke Schulterblatt)
@henrik
henrik / marshalling_wasabi.rb
Last active December 11, 2015 19:29
Got a script using Savon 2 with the e-conomic SOAP API (a 3 MB WSDL) down from around 30 seconds to around 2 seconds by marshalling the Wasabi WSDL parser. Consider this a proof-of-concept.
# For Wasabi 3.0.0.
# Marshals WSDL for a huge speedup with large files.
# A 3 MB WSDL went from around 30 to 2 seconds.
# Marshalling: 3.1 MB -> 629 KB.
# Zipping: 629 KB -> 59 KB.
module Wasabi
class Parser
alias_method :old_parse, :parse

Researchers investigating the Rails parameter parsing vulnerability discovered that the same or similar vulnerable code had made its way into multiple other libraries. If your application uses these libraries to process untrusted data, it may still be vulnerable even if you have upgraded Rails. Check your Gemfile and Gemfile.lock for vulnerable versions of the following libraries.

Directly vulnerable libraries

rails

Vulnerable: <= 3.2.10, <= 3.1.9, <= 3.0.18, <= 2.3.14

Fixed: 3.2.11, 3.1.10, 3.0.19, 2.3.15

multi_xml

@mislav
mislav / procs-vs-lambda.md
Last active March 26, 2021 18:34
Jim Weirich on the differences between procs and lambdas in Ruby

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

@brentjanderson
brentjanderson / adapter.js
Last active October 23, 2019 19:12
NOTE: Not updated since early 2013 - likely will not work with modern EmberData. Ember.JS, ember-data, and socket.io adapter. Not as primitive as the initial version and it supports object creation/deletion/etc. Does not support bulk updates like the first one just to keep it simple. Does support ember-data revision 11 and does support queries/f…
/*jshint browser:true */
/*global DS:true, io:true, App:true */
(function() {
'use strict';
// Initializer for Models
window.Models = {};
console.warn("Don't pollute the global namespace with Models!");
@ryanb
ryanb / issues_with_modules.md
Created November 29, 2012 22:38
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article &lt; ActiveRecord::Base
@peterc
peterc / backwards.txt
Created November 26, 2012 23:08
Reading
I'm a Rubyist with a lot of admiration for Python. Both languages are
similar (in the grand scheme of things) and each has huge pros and cons.
Python does not click for me in the same way as Ruby does not
click for perhaps the majority of programmer-kind. German doesn't click
for me either and 100m+ people speak that ;-) But I recently saw an
example of WHY Python taxes my Ruby brain a little.
I found some code at http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/:
@jimweirich
jimweirich / soap.txt
Created November 22, 2012 09:17
Results of an Informal Twitter Survey on the State of the Art for Ruby SOAP Clients
Today I ran a quick twitter poll asking: "What is the state of the art
in Ruby SOAP clients".
Savon (http://savonrb.com/) was by far the big winner with 29
recommendations.
Surprisingly Soap4r actually got 6 votes, but most were accompanied by
comments like "the last time I used SOAP". It was also the only entry
that got negative votes (3) with comments like "soap4r is broken and
crap by the way".
require "timeout"
module WaitSteps
extend RSpec::Matchers::DSL
matcher :become_true do
match do |block|
begin
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = block.call
@thenoseman
thenoseman / RubyExecuteLineWithMarker.vim
Created November 19, 2012 20:35
Executes the current ruby line when there is a # => marker at the end replacing it with the evaled result
" Executes the current ruby line when there is a # =>
" marker at the end replacing it with the evaled
" result
function! RubyExecuteLineWithMarker()
ruby << EOF
marker = '# =>'
buffer = VIM::Buffer.current
if buffer.line.match(/#{marker}/)
result = marker + ' ' + eval(buffer.line, binding).inspect
buffer.line = buffer.line.sub(/#{marker}.*/, result).chomp