Skip to content

Instantly share code, notes, and snippets.

View mxlje's full-sized avatar
🌩️

Max Lielje mxlje

🌩️
View GitHub Profile
@mxlje
mxlje / config.vcl
Created June 9, 2014 10:26
varnish remove tracking cookies
if (req.http.Cookie) {
set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *__utm.=[^;]+;? *", "\1"); # removes all cookies named __utm? (utma, utmb...) - tracking thing
if (req.http.Cookie == "") {
remove req.http.Cookie;
}
}
@mxlje
mxlje / outline.sass
Created May 5, 2014 06:32
The most important Sass Mixin.
@mixin outline($color: red)
outline: 1px solid $color
<h1>The Document Outline in HTML - When to use a heading tag for a heading?</h1>
<p><strong> On a lot of websites, especially the ones with ready made templates, we see that the heading tags <code>&lt;h1&gt;</code> to <code>&lt;h6&gt;</code> are used incorrectly. This happens as the differention between style and markup is not considered in the right way. </strong></p>
<p>To make a nice looking website, you need only two files:</p>
<ol>
<li>an HTML Document for the structure</li>
<li>a CSS File for the styling</li>
</ol>
organizer = Organizer.create(
email: "a@b.com",
company_name: "Example Company",
password_digest: "$2a$10$qQQws7Kb2IG1qfqp4OgdZ.dtKicGew79HZkWUO0gzaerhkC6/3OuC"
)
Event.create(
name: "Awesome Event",
description: "Lorem Ipsum",
organizer: organizer,

Keybase proof

I hereby claim:

  • I am mxlje on github.
  • I am mxlje (https://keybase.io/mxlje) on keybase.
  • I have a public key whose fingerprint is 2ADF A1D9 FDC5 5C54 1DCE 1356 A039 EA57 86C1 43E2

To claim this, I am signing this object:

@mxlje
mxlje / footnotes.rb
Last active December 31, 2015 02:28
footnotes
class Redcarpet::Render::HTML
def footnote_ref(number)
@article_id ||= [*('a'..'z'),*('0'..'9')].shuffle[0,4].join
fn_ref = "<sup id='fnref-#{@article_id}-#{number}'>"
fn_ref << "<a href='#fn-#{@article_id}-#{number}' rel='footnote'>"
fn_ref << "#{number}</a></sup>"
end
def footnote_def(content, number)
# Checks status code of multiple URLs and prints them
require "mechanize"
urls = [
'http://maxlielje.co'
]
@agent = Mechanize.new
@mxlje
mxlje / one_line_server
Last active December 20, 2015 06:39
One liner ruby webserver
# run this in the terminal
# via http://ruby5.envylabs.com/episodes/419-episode-383-july-2-2013
ruby -run -e httpd . -p 5000
@mxlje
mxlje / string.rb
Created July 12, 2013 10:02
Ruby method for cleaning URL strings for display
class String
# remove protocol, www, and trailing slash from URL string
def to_clean_url
u = self
if u.start_with?('http://www.')
u = u[11..-1]
elsif u.start_with?('https://www.')
u = u[12..-1]
@mxlje
mxlje / sinatra-datamapper.rb
Created May 29, 2013 22:12
playing around with Sinatra & DataMapper
require 'sinatra'
require 'data_mapper'
require 'json'
# Authentication
# use Rack::Auth::Basic, "Restricted Area" do |username, password|
# username == 'admin' and password == 'admin'
# end
# set json as content type for all requests