Skip to content

Instantly share code, notes, and snippets.

View letoh's full-sized avatar
💭
I may be slow to respond.

letoh letoh

💭
I may be slow to respond.
View GitHub Profile
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active November 8, 2024 20:02
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

anonymous
anonymous / SIMPL_ASM4
Created January 18, 2017 18:05
SIMPL in MSP430 assembly language 582 bytes -
;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file
;-------------------------------------------------------------------------------
.def RESET ; Export program entry-point to
; make it known to linker.
@xor-gate
xor-gate / 01README.md
Last active March 11, 2024 12:05
Semhosting

QEMU Cortex-m3 with semihosting

@chambart
chambart / packed_fields_gadt.ml
Last active April 3, 2023 02:00
Packed fields in integers
type zero = unit
type 'a succ = unit -> 'a
type one = zero succ
type 'a plus_1 = 'a succ
type 'a plus_2 = 'a plus_1 plus_1
type 'a plus_4 = 'a plus_2 plus_2
type 'a plus_8 = 'a plus_4 plus_4
@yantonov
yantonov / install-ghc-ubuntu.md
Last active June 11, 2020 09:20
How to install latest GHC from source + latest stack + cabal + cabal-install on ubuntu

How to install GHC from source + latest stack + cabal + cabal-install on ubuntu

for your convinience this instuction is available as:
gist
git repo

preferred way install stack than install ghc

stack (package manager and build tool, preferrered way to manage dependencies)

# settings
@ethan5422
ethan5422 / eshell-insert-last-word.el
Last active January 4, 2016 08:09
eshell-insert-last-word
(defun eshell-last-argument (n m)
(let* ((input (substring-no-properties
(eshell-previous-input-string (1- m))))
(parse (with-temp-buffer
(insert input)
(nth (1- n) (reverse (eshell-parse-arguments
(point-min) (point-max)))))))
(eval parse)))
(defun eshell-insert-last-word (n)
@edalorzo
edalorzo / Example.java
Created February 17, 2013 15:01
Java Infinite Streams
package codemasters.lambda.learn.streams;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.function.Supplier;
import java.util.function.Consumer;
import java.util.function.Predicate;
@audreyt
audreyt / posa.mkdn
Last active November 28, 2022 21:24
EtherCalc.tw

從 SocialCalc 到 EtherCalc

先前在《開源應用程式架構》 一書中,我介紹了 SocialCalc 這個在瀏覽器中運行的試算表編輯器,以取代伺服器為中心的 WikiCalc 架構。SocialCalc 在瀏覽器中執行所有的運算,只有在載入和儲存試算表時才會使用伺服器。

追求效能是 Socialtext 團隊在 2006 年時設計 SocialCalc 的主要目的。重點在於:在 JavaScript 環境下執行客戶端運算,儘管在當年的速度僅有伺服器端 Perl 運算的十分之一,但仍然勝過 AJAX 來回傳輸資料造成的網路延遲:


WikiCalc 與 SocialCalc 架構比較

******
anonymous
anonymous / gist:3174213
Created July 25, 2012 03:34
(defvar rcirc-max-message-length 420
"Messages longer than this value will be split.")
(defun rcirc-send-message (process target message &optional noticep silent)
"Send TARGET associated with PROCESS a privmsg with text MESSAGE.
If NOTICEP is non-nil, send a notice instead of privmsg.
If SILENT is non-nil, do not print the message in any irc buffer."
;; max message length is 512 including CRLF
(let* ((response (if noticep "NOTICE" "PRIVMSG"))
(oversize (> (length message) rcirc-max-message-length))
@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})