Skip to content

Instantly share code, notes, and snippets.

View Arcovion's full-sized avatar

Eliott Appleford Arcovion

  • England, United Kingdom
View GitHub Profile

34 chars:

<v"g()('al')"
,<v!-"'"_
,,_>"o",^@

All of the examples print correctly: g('al') -> gal, g()()()('al') -> goooal etc.

@Arcovion
Arcovion / gist:e346eb1daa037fe32d43
Created July 11, 2014 01:36
Ruby code golf: Delimiting a number with commas

61 chars:

$><<('%f'%gets).gsub(/\d(?=\d{3}+\.)/,'\&,').sub(/\.?0+$/,'')

Handles floats, integers, signed numbers and strings. Also strips trailing zeros and avoids scientific notation.

@Arcovion
Arcovion / gist:03cfc1e3494710fad064
Last active August 29, 2015 14:02
Ruby code golf: Pangram checker

33 chars for ruby 1.9+:

p [*?A..?Z]-gets.upcase.chars==[]

34 chars another way:

p (?a..?z).grep(/[^#{gets}]/i)==[]
@Arcovion
Arcovion / gist:1cccdfa28a5e646aefe2
Created June 5, 2014 16:44
Line numbers in Rouge
<style>
.highlight table td {
padding: 5px;
}
.highlight table pre {
margin: 0;
}
</style>
<div class="highlight"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1
@Arcovion
Arcovion / config.rb
Created May 8, 2014 12:33
Middleman extension to manage multiple directories
class Middleman::Extensions::DirManager < Middleman::Extension
register :dir_manager
option :dirs, {source: 'pages', destination: '', add: [], remove: ['', 'pages']}
def manipulate_resource_list resources
[options.dirs].flatten.each do |opts|
# Remove pages if specified
opts[:remove].each do |dir|
resources.reject! do |page|
Dir.glob(normalise(dir) + '/*', File::FNM_DOTMATCH).include? page.source_file