This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function eval_data(string) | |
local chunk, err = loadstring(string) | |
if not chunk then error(err) end | |
local result = {} | |
setfenv(chunk, result) | |
chunk() | |
return result | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyUniqifier | |
include Snowflake::Base | |
# "Strategies" are method definitions that start with "try" and will be | |
# tried in the order you create them in your uniqifier class. | |
def try_using_name | |
@record.name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These benchmarks process a template that uses most of Haml's features. | |
(1) Parsed, compiled and rendered | |
(2) Compiled and rendered | |
(3) Rendered | |
Stable branch: | |
user system total real | |
ugly (1) 1.120000 0.010000 1.130000 ( 1.132223) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log stable..rails3 --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n",add,subs,loc }' - | |
added lines: 13821 removed lines: 16327 total lines: -2506 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "babosa" | |
require "babosa/utf8/proxy" | |
bad_string = "whatever" | |
puts Babosa::UTF8::DumbProxy.tidy_bytes bad_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
foo | |
</p> | |
<textarea> | |
hello world</textarea> | |
<p> | |
hello world | |
</p> | |
<textarea>hello!</textarea> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# | |
# Copyright (c) 2012 Norman Clarke | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of | |
# this software and associated documentation files (the "Software"), to deal in | |
# the Software without restriction, including without limitation the rights to | |
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
# the Software, and to permit persons to whom the Software is furnished to do so, | |
# subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# | |
# Encode any codepoint outside the ASCII printable range to an HTML character | |
# reference (https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_reference_overview). | |
def encode(string) | |
string.each_codepoint.inject("") do |buffer, cp| | |
cp = "&#x#{cp.to_s(16)};" unless cp >= 0x20 && cp <= 0x7E | |
buffer << cp | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user system total real | |
(1) erb 0.360000 0.000000 0.360000 ( 0.355804) | |
(1) erubis 0.300000 0.000000 0.300000 ( 0.305106) | |
(1) fast erubis 0.300000 0.000000 0.300000 ( 0.304546) | |
(1) slim 3.030000 0.010000 3.040000 ( 3.036167) | |
(1) haml 1.990000 0.010000 2.000000 ( 2.012734) | |
(1) haml ugly 1.870000 0.000000 1.870000 ( 1.873722) | |
(2) erb 0.130000 0.000000 0.130000 ( 0.126759) | |
(2) erubis 0.090000 0.000000 0.090000 ( 0.094110) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
compat_env v$(_VERSION) - Lua 5.1/5.2 environment compatibility functions | |
SYNOPSIS | |
-- Get load/loadfile compatibility functions only if using 5.1. | |
local CL = pcall(load, '') and _G or require 'compat_env' | |
local load = CL.load | |
local loadfile = CL.loadfile |