Skip to content

Instantly share code, notes, and snippets.

@Aethelflaed
Aethelflaed / stderr
Created January 15, 2018 00:55
go get github.com/mkchoi212/fac stderr
# github.com/mkchoi212/fac/vendor/github.com/alecthomas/chroma/lexers
../../../../go/src/github.com/mkchoi212/fac/vendor/github.com/alecthomas/chroma/lexers/c.go:46:21: error: reference to undefined name ‘Name’
{`[a-zA-Z_]\w*`, Name, nil},
^
../../../../go/src/github.com/mkchoi212/fac/vendor/github.com/alecthomas/chroma/lexers/capnproto.go:23:15: error: reference to undefined name ‘Name’
{`[\w.]+`, Name, nil},
^
../../../../go/src/github.com/mkchoi212/fac/vendor/github.com/alecthomas/chroma/lexers/ceylon.go:35:21: error: reference to undefined name ‘Name’
{`[a-zA-Z_]\w*`, Name, nil},
^
@Aethelflaed
Aethelflaed / Gemfile
Created October 3, 2015 08:51
scalingo mongo backup command
source 'https://rubygems.org'
ruby '2.0.0'
gem 'thor'
@Aethelflaed
Aethelflaed / 0readme.md
Last active August 29, 2015 14:19
Rails ActiveJob CronJob

I had to create some recurring jobs, so I decided to implement a simple CronJob module to work this that.

The CronJob module creates an after_perform callback to reschedule the job at the next_occurence, with the same arguments.

I used https://github.com/siebertm/parse-cron to parse the cron expression.

class Foo
def self.macros(&block)
mod = Module.new
mod.module_eval do
ANSWER = 42
end
self.const_set(:Macros, mod)
Macros.module_eval do
module_eval &block
end
@Aethelflaed
Aethelflaed / gist:3f5ea91b0ba9314cab24
Created January 15, 2015 14:21
ActiveJob's assert_enqueued_with at comparison
I use this method instead of ActiveJob's original version to assert for enqueued job with given parameters / options.
The main point of this patch is to fix the float to float comparison with the at attribute by using an epsilon which can also be provided.
With the original version, it is impossible to test if a job is enqueued at a specified time.
I also added the wait attribute, which correspond more to my use of ActiveJob.
@Aethelflaed
Aethelflaed / gist:6d8c30511f0a2d731fde
Created August 20, 2014 13:50
linear C array to 2D std::vector
#include <iostream>
#include <vector>
template<typename T>
struct myIterator : public std::iterator<std::input_iterator_tag, T*>
{
myIterator(T* data) :
data(data)
{}
T* data;