Skip to content

Instantly share code, notes, and snippets.

@apotonick
apotonick / fuck-erb.rb
Last active October 8, 2018 22:29
Fucking Fuck Fuckers ERB and Fuck Rails And Fuck Haml And Fuck Their Fucking Fuck Hacks
## Smple
<pre>
"@output_buffer = output_buffer || ActionView::OutputBuffer.new;@output_buffer.safe_append='Word.\n\n'.freeze;@output_buffer.append= link_to \"/rails/sucks\" do @output_buffer.safe_append='\n hallo\n'.freeze; end \n@output_buffer.safe_append='\n'.freeze;@output_buffer.to_s"
</pre>
ActionView::Template::Handlers::Erubis.new "<%= form_for Object.new do %>\n <%= link do %>hallo<% end %> \n<% end %>"
```ruby
<snippet>
<content><![CDATA[
{% highlight ruby %}
${1:this}
{% endhighlight %}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>high</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
<snippet>
<content><![CDATA[
puts "@@@@@ #{${1:what}.inspect}"${2}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>puts</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.ruby</scope>
</snippet>
@apotonick
apotonick / wishlist.rb
Last active November 21, 2018 07:19
My Ruby Wishlist
# Ruby Wishlist
## Removals
* finalize! method for classes
* Remove constant_finding/loading at runtime, it always breaks.
## Module.freeze
Remove the ability to dynamically change code at runtime
@apotonick
apotonick / benchmark.rb
Created September 19, 2014 03:10
Send vs. Method
require 'benchmark'
definition = {:title => "Lunch"}
class DecoratorWithMethod
def initialize(definition)
@definition = definition
end
def [](value)
@definition[value]
@apotonick
apotonick / spec.rb
Last active August 29, 2015 14:03
Ideas for spec DSL
describe "#inherit!" do
# this would usually go in a before block and let and totally obfuscate what i wanna do:
# also, this would be run once while the it blocks below are isolated.
parent = Definitions.new([title, length])
child = Definitions.new([stars])
child.inherit!(parent)
# make sure parent's definitions were cloned.
# i'm fine with those it {} blocks:
it { child.must_equal([stars, title, length]) }
@apotonick
apotonick / gist:b131ec0698e11e4e1a8f
Created May 5, 2014 02:40
Ideas For Asset Pipeline
staging:
"default host"
:http_asset_host: 'cdn%d.microminimus.com'
:https_asset_host: 'cdn-microminimus.pantherssl.com'
"local host"
host: /
only: fonts.css
development:
:http_asset_host: 'cdn%d.microminimus.com'
@apotonick
apotonick / backup-home.sh
Created May 2, 2014 23:06
Backup scripts
rsync -av . /media/nick/5EAD-07D0/NICK --exclude=*.cache/* --exclude=*.thumb*/* --exclude=*.rvm/* --modify-window=3601
@apotonick
apotonick / assertion.rb
Last active July 5, 2017 05:54
MiniTest.infect_an_assertion
MiniTest::Assertions.class_eval do
def assert_equal(subject, expected)
subject == expected
end
end
Array.infect_an_assertion :assert_hash, :must_be_hash, :do_not_flip
@apotonick
apotonick / Problem.rb
Last active August 29, 2015 13:56
Inheritable Module Class Methods
# Here's the original problem:
module Feature
module ClassMethods
def feature
end
end
def self.included(includer)
includer.extend ClassMethods