Skip to content

Instantly share code, notes, and snippets.

@n-s-k
n-s-k / OOP_F2003_Part_1.md
Last active January 20, 2025 10:40
Object-Oriented Programming in Fortran 2003 Part 1: Code Reusability
@shgeta
shgeta / shell_bin_hex_decimal.md
Last active December 14, 2023 11:55
shell でバイナリを扱う。進数変換する。osx

shell でバイナリを扱う。進数変換する。osx

概要

shell でバイナリを扱う。進数変換する。 なるべく分かりやすい単純なコードで。

決め事

コードを単純にするために決め事を使う

  • hexの指定は大文字で 例 ok: 0A, FF, 1A ( ng: 0a, ff, fa )

進数変換

  • HEXの指定は大文字で
@codedot
codedot / lambda.in
Last active September 29, 2023 08:37
Implementation of closed reduction with read-back mechanism using Interaction Nets Compiler
${
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *var(int fresh);
char *append(char *format, char *buf, char *str);
#define ABST(BUF, STR) append("%s%s: ", (BUF), (STR))
#define APPL(BUF, STR) append("%s%s ", (BUF), (STR))
anonymous
anonymous / sample2.c
Created April 25, 2014 03:42
sample 2
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
static void bout(char *msg) __attribute__((noreturn));
static int calc_expr(void);
static int calc_term(void);
static int calc_factor(void);
anonymous
anonymous / sample1.c
Created April 25, 2014 03:41
sample 1
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
static void bout(char *msg) __attribute__((noreturn));
static int calc_expr(int val, int op);
static int calc_term(int val, int op);
static int calc_factor(void);
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active April 19, 2025 05:13
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.

@ormaaj
ormaaj / reftest.bash
Last active March 30, 2021 13:39
Broken namerefs.
#!/usr/bin/env bash
# Only ksh93 has "real" C++-like references (called namerefs). They can be used
# as reference parameters for passing data structures like arrays in and out of
# functions. Bash 4.3+ and mksh also have a nameref feature, but unlike ksh93,
# which has three different kinds of nameref, bash supports just two of these
# and mksh only one (the for-loop type won't be illustrated here). It is the
# "dynamic" kind of nameref that is supported by all three, which is mostly
# just sugar for Bash's old "${!var}" behavior (ksh93 also uses this kind when
# a nameref doesn't refer to a positional parameter).
@flada-auxv
flada-auxv / grand_theft_wumps.lisp
Created March 19, 2013 20:35
Land of Lisp 第8章
(load "graph_util")
(defparameter *congestion-city-nodes* nil)
(defparameter *congestion-city-edges* nil)
(defparameter *visited-nodes* nil)
(defparameter *node-num* 30)
(defparameter *edge-num* 45)
(defparameter *worm-num* 3)
(defparameter *cop-odds* 15)
@chadbrewbaker
chadbrewbaker / Roman.rb
Created January 15, 2013 23:05
Iowa Ruby Brigade kata showing Roman numeral computation is a monoid.
# Roman Numeral Evaluation is a Monoid
# Chad Brewbaker | Software Engineer | Telligen.org
# [email protected]
# Initial release January 15, 2013
class RomanMonoid
attr_accessor :prefix, :prefix_size, :suffix, :suffix_size, :suffix_credit, :sum, :homo
def initialize(val)
@certik
certik / a.f90
Created January 23, 2012 21:32
transfer() example
program a
use types, only: dp
use compute, only: init, register_func, run, eq, destroy, get_context
use my_data_type, only: my_data, type2data, data2type
type(eq), pointer :: d
type(my_data), target :: data1, data2
data1%a11 = 0
data1%a12 = -1