Skip to content

Instantly share code, notes, and snippets.

@siefca
siefca / ccache-66.patch
Created April 19, 2024 13:01
CCACHE-66
From c7beb5c57d51c33747c0d1331ef25787a24779be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Wilk?= <siefca@gnu.org>
Date: Fri, 19 Apr 2024 14:52:00 +0200
Subject: [PATCH] CCACHE-66: Improved equality checks for keywords
---
src/main/clojure/clojure/core/cache.clj | 6 +++---
src/main/clojure/clojure/core/cache/wrapped.clj | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
@siefca
siefca / streq.c
Last active August 5, 2021 11:09
streq
#include <string.h>
#undef streq
#ifndef STREQ
# define STREQ streq
#endif
int
STREQ (const char *p1, const char *p2)
@siefca
siefca / outof.clj
Created July 23, 2021 23:35
Outof function, reverse of into
(defn outof
([] [])
([of] of)
([of what]
(if (instance? clojure.lang.IEditableCollection of)
(with-meta (persistent! (reduce disj! (transient of) what)) (meta of))
(reduce disj of what)))
([of xform what]
(if (instance? clojure.lang.IEditableCollection of)
(with-meta (persistent! (transduce xform disj! (transient of) what)) (meta of))
@siefca
siefca / errors.clj
Last active February 4, 2021 10:15
Short-circuiting Clojure errors with exceptions
(defrecord XError [reason message response])
(def default-messages
{:blabla "This is blabla"
:unknown "Unknown error"
:empty "Empty response"})
(defn new-error
"Forms an error response when something goes wrong."
([reason response]
@siefca
siefca / eneltron-example.clj
Created October 19, 2015 19:45
Eneltron's Tokenizer – example usage
(require 'eneltron.tokens)
(eneltron.tokens/initialize-tokenizer)
(def tekst "Siała baba mak. Nie wiedziała jak. Raz, dwa – oraz – 4.")
(time (def wynik (eneltron.tokens/tokenize tekst)))
; => "Elapsed time: 0.230337 msecs"
(apply print
(map #(str (apply str (next (str (:token-class (meta %1))))) " ->" \tab \tab (apply str %1) \newline)
<?php
function mytheme_alpha_preprocess_node(&$vars) {
$node = $vars['node'];
if (isset($vars['field_topic'][0]['tid'])) {
$parents = taxonomy_get_parents($vars['field_topic'][0]['tid']);
$top_parent = array_shift($parents);
$vars['topic'] = field_view_value('node', $node, 'field_topic', array(
'tid' => $top_parent->tid, 'label' => 'hidden'));
@siefca
siefca / robot.js
Created December 4, 2012 12:43 — forked from fabiopimentel/robot.js
[CAELUM TEAM]Megatron
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.clone();
# Enabling order for Radiant extensions migration.
#
# -------------------------------------------------
# Modify environment.rb by putting this AFTER the line with 'config.extensions':
if ENV.has_key?('CONFIG_EXTENSIONS')
::PENDING_EXTENSIONS = config.extensions.clone
config.extensions = ENV['CONFIG_EXTENSIONS'].split(/[\,\ \:]+/).map{ |x| x.strip.to_sym }
end
def self.attr_inheritable(*variables)
variables.each do |v|
module_eval %{
def self.#{v}
@#{v} = superclass.#{v} if !instance_variable_defined?(:@#{v}) && superclass.respond_to?(:#{v})
return @#{v}
end
}
end
end
# Author:: Paweł Wilk (mailto:pw@gnu.org)
# Copyright:: Copyright (c) 2009 Paweł Wilk
# License:: LGPL
#
# This module is intended to be used as extension
# (class level mixin) for classes using some buffers
# that may be altered by calling certain methods.
#
# It automates resetting of buffers by installing