Skip to content

Instantly share code, notes, and snippets.

View denisdefreyne's full-sized avatar

Denis Defreyne denisdefreyne

View GitHub Profile
@datanoise
datanoise / crystal-tags.cr
Last active March 5, 2021 03:24
ctags for crystal language
require "compiler/crystal/**"
require "option_parser"
include Crystal
class ToCtagsVisitor < Visitor
@filename : String
@lines : Array(String)
@io : IO
@opts : Generator
@jseppi
jseppi / Rules
Last active July 4, 2016 06:59 — forked from bburton/Rules
Default Rules and nanoc.yaml for the nanoc static site generator. The included config.rb is useful for setting up Compass configuration properties if using Compass.
#!/usr/bin/env ruby
# This Rules file is an attempt at a near zero configuration for the common
# use cases when creating a simple site with nanoc. It's meant to have
# better defaults so new users don't have to configure it much if at all.
# For the most part, it copies all files from the content folder to the
# output folder with the same name. It has the following features:
#
# * Certain predefined page extensions such as html, haml, md, markdown and
# textile are routed to "clean" URI's (see below regarding Item identifiers).
@bburton
bburton / Rules
Created January 15, 2014 16:08
Better default Rules for nanoc static site compiler (http://nanoc.ws version 3.x) that for the simple cases require little to no configuration. Files that are considered to be pages (based on a list of extensions), are appropriately filtered and routed for some common file types such as Haml, Markdown and Textile. All other text files and binary…
#!/usr/bin/env ruby
# This Rules file is an attempt at a near zero configuration for the common
# use cases when creating a simple site with nanoc. It's meant to have
# better defaults so new users don't have to configure it much if at all.
# For the most part, it copies all files from the content folder to the
# output folder with the same name. It has the following features:
#
# * Certain predefined page extensions such as html, haml, md, markdown and
# textile are routed to "clean" URI's (see below regarding Item identifiers).
@txus
txus / afk.rb
Created July 15, 2013 14:45
AFK
while true
value = rand > 0.8 ? "\e[031mF\e[0m" : "\e[032m.\e[0m"
print value
sleep rand / 2
end
@rentalcustard
rentalcustard / gist:5524668
Last active January 13, 2022 14:21
Removing all literals from Ruby

Literals are ugly. Let's remove them.

True/false:

2.0.0p0 :001 > !Date
=> false
2.0.0p0 :002 > require Date.to_s.downcase
=> true

Integers and floats:

@gpakosz
gpakosz / compass.rb
Created April 19, 2013 12:59
Better yet hacky Compass / nanoc integration.
def compass_sass_engine_options
fail "configuring Compass with 'relative_assets = true' doesn't make much sense in the context of nanoc" if Compass.configuration.relative_assets?
options = Compass.sass_engine_options
options[:load_paths].each do |x|
class << x
alias _inspect inspect
def inspect
_inspect.gsub(/:0x\h+/, '')
@headius
headius / gist:5304764
Last active December 15, 2015 18:30
Bad Ruby! No performance for you!
# $~ and $_ are frame-local, but they're set across frames and you don't know when
def foo(a, b)
p $~ # => nil
a[b] # call to String#[], b is a regexp
p $~ # => MatchData
end
foo("hello", /hel/)
@dummied
dummied / metaweblog_to_nanoc.rb
Created January 10, 2013 15:58
Hacked together metaweblog api to generate posts in nanoc, circa 2009. Only bit missing was generating/uploading the relevant content. Could have also looked at reading/writing directly to the text files, but a small sql db didn't seem like a big burden at the time.
# Erik Kastner 2008-02-16 small blog engine with XMLRPC, hAtom and S3 upload (through xlmrpc) support
require 'rubygems'
require 'sinatra'
require 'xmlrpc/marshal'
require 'active_record'
require 'aws/s3'
require 'stringex'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "sin.db")
NANOC_DIR = "/Users/cvannoy/personal/dummied/content/blog"
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: