Skip to content

Instantly share code, notes, and snippets.

Denis Defreyne ddfreyne

Block or report user

Report or block ddfreyne

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ddfreyne
ddfreyne / README.md
Last active Jan 9, 2019
Uru Chat Log Formatter (old code)
View README.md

Uru chat log formatter

This code is old and haven’t ran it in many years. Hopefully it can still be of use :)

It consists of two parts:

  • process.rhtml is the page that you’d send a HTTP POST to, with values
    • text (the text to format)
    • type (bold_and_color or bold_only)
    • color (the color to use, in BBCode, for the higlighted nicknames)
View create_dependency_from.rb
RSpec::Matchers.define :create_dependency_from do |expected|
supports_block_expectations
include RSpec::Matchers::Composable
match do |actual|
@from = expected
dependency_tracker = @from._context.dependency_tracker
dependency_store = dependency_tracker.dependency_store
View memoized_nanoc_helper.rb
require 'singleton'
require 'ddmemoize'
class MyHelper
include Singleton
DDMemoize.activate(self)
memoized def foo(item)
#
end
@ddfreyne
ddfreyne / tasks.json
Created Oct 10, 2017
Visual Studio Code configuration for Nanoc sites (stick this in .vscode/tasks.json)
View tasks.json
{
"version": "2.0.0",
"tasks": [
{
"taskName": "Setup",
"type": "shell",
"command": "bundle",
"problemMatcher": []
},
{
View digraph.rb
module NanocRust
module FFI
extend ::FFI::Library
root = File.expand_path(File.dirname(__FILE__) + '/..')
ffi_lib root + '/rust/dist/libnanoc_rust.' + ::FFI::Platform::LIBSUFFIX
#
attach_function :digraph_predecessors_of, %i[pointer string pointer], :pointer
end
@ddfreyne
ddfreyne / bypassing_ensure.md
Last active Mar 11, 2017
Bypassing Ruby’s `ensure`
View bypassing_ensure.md

Ruby’s ensure block ensures, as the name says, that no matter what exception occurs, some code will still be executed. For example:

begin
  raise 'boom'
ensure
  puts 'still executed'
end
View cache_busting_css_in_nanoc.md

Add this somewhere in lib/:

def fingerprint(pattern)
  if ENV['NANOC_ENV'] == 'dev'
    'dev'
  else
    contents = @items.find_all(pattern).map do |i|
      i.binary? ? File.read(i[:filename]) : i.raw_content
    end
@ddfreyne
ddfreyne / nanoc_ws_dependencies.txt
Created Nov 20, 2016
Finer-grained dependencies for nanoc.ws
View nanoc_ws_dependencies.txt
Legend:
r = dependency on raw content
a = dependency on attributes
c = dependency on compiled content
p = dependency on the path
item /404.dmark depends on:
[ item ] (___p) /assets/style/print.scss
[ item ] (___p) /assets/style/screen.scss
[ item ] (_a_p) /contributing.dmark
@ddfreyne
ddfreyne / preprocess.txt
Created Oct 31, 2016
Nanoc preprocessor use cases
View preprocess.txt
# Nanoc preprocessor analysis
## Apparent uses
The following apparent uses of the preprocessor show up in sites’ sources (see below):
* Read from external world into config
* From environment (e.g. `NANOC_ENV`)
* From side-effect-free command output (e.g. `nanoc --version`)
* Set attributes based on other attributes, identifier, or raw content
View mario.c
#include <stdio.h>
#include <string.h>
#include <ao/ao.h>
#include <math.h>
#define RATE 8800
////////////////////////////////////////////////////////////////////////////////
float lfo_01(float t, float speed) {
You can’t perform that action at this time.