Skip to content

Instantly share code, notes, and snippets.

View Wilfred's full-sized avatar

Wilfred Hughes Wilfred

View GitHub Profile
@Wilfred
Wilfred / _README.md
Last active January 26, 2016 21:16
Example of LLVM's opt changing behaviour

Running opt can change behaviour!

The following files should be equivalent:

$ echo 1337 | lli with_zeroing.ll 
1337: 7 191
$ echo 1337 | lli without_zeroing.ll
1337: 7 191

However, running them through opt:

@Wilfred
Wilfred / commit.diff
Created January 12, 2016 09:38
Marking python.el as emacs core
commit baa81b1c8666676b9be6f39ff0020e82e7ee791d
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Sun Nov 29 20:28:28 2015 -0500
* externals-list: Add seq and python as :core packages
* .gitignore: Add packages/{seq,python}.
* packages/seq: Remove.
diff --git a/.gitignore b/.gitignore
@Wilfred
Wilfred / iterators.rs
Created May 29, 2015 23:09
Adding methods to Iterator
trait Greet {
fn say_hello(&self) -> ();
}
impl Greet for Iterator {
fn say_hello(&self) {
println!("hello from an iterator!");
}
}

Template composition with inclusion

Every template language I have seen provides some mechanism for one template to include another, thus supporting the reuse of repeated elements like headers and footers. The included templates are called partials in Mustache parlance:

<!-- home.hbs -->
<html>
<body>
  {{> header}}
  <p> HOME </p>
  {{> footer}}
@Wilfred
Wilfred / main.c
Created January 21, 2015 23:24
Unexpected clang build warning
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alloca.h>
void eval_program(char *program) {
int program_len = strlen(program);
int data_index = 0, instruction_index = 0;
@Wilfred
Wilfred / sourcegraph_feedback.md
Last active August 29, 2015 14:10
Sourcegraph feedback

So, I've played with Sourcegraph, and I love the concept. I love the idea of being able to explore usage of functions and jumping to the original version.

I'm a Python programmer who likes Django, so I chose render_to_response as a function to try. It's a function I've used plenty and it's pure-python, so I assume it must be indexed.

https://sourcegraph.com/search?q=render_to_response shows the django-nonrel fork, but not the official django sources.

@Wilfred
Wilfred / julia_syntax_test.jl
Last active June 19, 2019 19:33
Corner cases for Julia syntax highlighting
## Julia syntax highlighting test.
# This file is designed to test various corner cases of Julia
# syntax highlighting.
## Simple function definitions.
# Expected: `function` should be highlighted, as should `foo_bar!`.
function foo_bar!(x,y)
x + y + 1
end
;; http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00962.html
;; eval this buffer and then start modifying the data in the table below.
;;
;; ------------
;; Alpha | 50
;; Beta | 35
;; Gamma | 64
;; Delta | 20
;; Epsilon | 80
;;

Macros Crash Course

Firstly, a macro is evaluated at compile-time, not runtime.

;; Define a function and macro that both
;; return the current time.
(defun get-current-time-fn ()
  (second (current-time)))

(defmacro get-current-time-mac ()

(defun get-faces (pos)
"Get the font faces at POS."
(remq nil
(list
(get-char-property pos 'read-face-name)
(get-char-property pos 'face)
(plist-get (text-properties-at pos) 'face))))