Skip to content

Instantly share code, notes, and snippets.

@panzi
panzi / portable_endian.h
Last active April 18, 2024 20:59
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, Mac OS X, and QNX. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put …
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active March 29, 2024 19:56
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active March 27, 2024 06:36
A badass list of frontend development resources I collected over time.
@pete
pete / 0-README
Last active February 10, 2024 07:12
Various implementations of the 'cat' command, for comparison.
I turned this gist into a "real" repository. It is here: http://github.com/pete/cats .
Here, placed side-by-side for comparison, are GNU's implementation of
cat, Plan 9's implementation, Busybox's implementation, and NetBSD's
implementation, Seventh Edition Unix (1979), and 4.3BSD.
For good measure (and because I suppose I am now committed to collecting
cats) also included are Second Edition Unix (in assembly) and Inferno's
implementation (in Limbo) for good measure.
@sent-hil
sent-hil / pictures.markdown
Created August 24, 2012 02:18
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@Snaipe
Snaipe / malloc_article.md
Last active June 6, 2022 10:10
malloc_article

Please note that the article is now on my website, and even though I am still working on it, any feedback is appreciated. Thanks for reading !

On the Quest of recoding malloc(3)

Back when I did not know anything about programing and started to learn C, I was first introduced to pointers (and other dreaded horrors that made me curl into a corner and cry) and dynamic memory in general.

I was baffled, troubled, yet fascinated by the basic explanation on how memory worked, and started to dread the time where I would need to manually create my char arrays for each and every sentences of my program; right before learning about string literals and feeling like an idiot.

It was then where I was learning about memory allocation and came upon a function that I would call for long the "magic function" : malloc. Magic, because at that point I didn't know how it worked, let alone knew anything about memory other that it was a "chain of boxes for numbers".

The objective here is to find all SegmentNotFoundException type corruption and remove it (as we don't have a valid backup)

Before running any of the below steps we created an index.json file (see the file below) which contains only the index definitions of the corrupted indexes.

  1. This generates the file indexing-results\index-definities.json
java -Xmx8g -jar oak-run-1.8.12.jar index --fds-path=crx-quickstart\repository\datastore crx-quickstart\repository\segmentstore --index-definitions
  1. From that file we copied only the definitions we needed and created index.json (file attached here )

The objective here is to find all SegmentNotFoundException type corruption and remove it (as we don't have a valid backup)

Before running any of the below steps we created an index.json file (see the file below) which contains only the index definitions of the corrupted indexes.

  1. This generates the file indexing-results\index-definities.json
java -Xmx8g -jar oak-run-1.8.12.jar index --fds-path=crx-quickstart\repository\datastore crx-quickstart\repository\segmentstore --index-definitions
  1. From that file we copied only the definitions we needed and created index.json (file attached here )
@ryanlunka
ryanlunka / LinkTransformer.java
Created April 8, 2013 12:35
A Sling Rewriter Transformer that replaces all ".html" extensions in links within an HREF attribute of a requested page with "/".
package com.citytechinc.rewriter.linkchecker;
import java.io.IOException;
import org.apache.cocoon.xml.sax.AbstractSAXPipe;
import org.apache.sling.rewriter.ProcessingComponentConfiguration;
import org.apache.sling.rewriter.ProcessingContext;
import org.apache.sling.rewriter.Transformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;