Skip to content

Instantly share code, notes, and snippets.

@wejrowski
wejrowski / block-to-partial
Created August 17, 2011 22:10
Passing Blocks to Rails partials
<%
#
# I originally needed to create a sidebar partial that had a div area where I could place custom links into. Finally found it.
# When I was trying to figure this out before and realized I needed to pass the view into :layout, rather than just using render 'layout'. Not sure why the block can't be passed otherwise but nonetheless...
#
# For explanation of options see
# http://guides.rubyonrails.org/layouts_and_rendering.html#options-for-render
#
%>
@wejrowski
wejrowski / css_urlstrip.rb
Last active December 15, 2015 01:59
CSS image parser
urls = ""
DATA.each do |l|
img = l[/url\([^)]*\)/]
urls << "<img src=#{img.gsub(/url\(([^)]*)\)/, '\1')} /><hr />\n" if img
end
f = File.open("urltest.html", "w") {|file| file.truncate(0) } # Clear file contents
f = File.open("urltest.html", "w")
f.write urls
f.close
@wejrowski
wejrowski / rails_tests_in_isolation.rb
Created August 21, 2013 23:42
Run all rails tests in isolation
require 'benchmark'
require 'socket'
ENV["RAILS_ENV"] = "test"
# Add test folder to load path
$: << './test'
puts Benchmark.measure{
# Assuming test_helper requires config/environment
@wejrowski
wejrowski / gist:6499960
Created September 9, 2013 18:59
link_wrap_if
# Wrap given block with link if..
def link_wrap_if(apply_link, url, opts={}, &block)
if apply_link
link_to capture(&block), url, opts
else
capture(&block)
end
end

Remote working

Germany specifics

Germany is 9 hours ahead (12am in AZ = 9am in Germany).

  • Available/awake times for me would be 12am-1:30pm az time (9am-10:30pm Germany)
  • Work 75% of time in morning/afternoon
  • Work/save 6-7pm (9-10am AZ time) for general standup and catch up at our normal time
@wejrowski
wejrowski / rspec-guides.markdown
Last active August 29, 2015 13:58
Rspec guides notes

General guides

  • Use describe blocks for objects and methods ("given" scenarios)
  • Use context blocks for "when" scenarios
  • Avoid spec descriptions longer than 40 characters. Split into contexts if longer.
  • Prefer expect syntax
  • Use before blocks at the lowest scope necessary
    • e.g. start within it blocks, then move into describe, then only if necessary for all tests put outside of those.
  • Use validation tests and place them at the top of the describe block
@wejrowski
wejrowski / willen-zum-leben
Last active August 29, 2015 14:11
Die Begründung des Optimismus aus dem Willen zum Leben
Zwei Dinge hat das Denken zu leisten: uns aus der naiven zur vertiefen Welt-
und Lebensbejahung zu füren und uns von ethischen Regungen zu einer
denknotwendigen Ethic gelangen zu lassen.
Vertiefe Welt- und Lebensbejahung besteht darin, dass wir den Willen haben,
unser Leben und alles durch uns irgendwie beeinflussbare Sein zu erhalten und
auf seinen höchsten Wert zu bringen. Sie verlangt von uns, dass wir alle
Ideale der materiellen und geistigen Vervollkommnung des Menschen, der
Gesellschaft und der Menschheit denken und uns durch sie zu stetem Wirken und
stetem Hoffen bestimmen lassen. Sie erlaubt uns nicht, uns auf uns selber
@wejrowski
wejrowski / gist:ac4594ce5d4d6e3357ba
Created January 29, 2015 01:33
Gmail api Javascript client execution
/*
Gmail Client (ideas)
Usage:
var gmailClient = newGmailClient(myAccessToken);
var response = gmailClient.execute({
url: "users/me/messages",
headers: {},
@wejrowski
wejrowski / gist:0e7d096151e0ca02a020
Created February 12, 2015 17:40
VIM - remove all multiline comments
:%s/\/\*\{-1}\_.\{-}\*\///g
@wejrowski
wejrowski / gist:cbf92b33db85d31eff86
Last active January 28, 2019 12:47
Jasmine specs - custom console reporter
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>console test</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css">
<script src="lib/jasmine-2.2.0/jasmine.js"></script>