Skip to content

Instantly share code, notes, and snippets.

View lagagain's full-sized avatar

lagagain lagagain

View GitHub Profile
@lagagain
lagagain / README.md
Last active February 14, 2023 11:56
[practice] [Common Lisp] hello CFFI (Common Lisp + C)

This is a practice project to test Common Lisp + C with CFFI.

CFFI is a protocal for common lisp, and most popular impl like sbcl,ccl,cmucl,ecl and abcl have to this. So We can eazy to access C code from Common Lisp.

Env need

just only write for Linux(Unix) and need a lisp impl with cffi package. I pratice it with sbcl. You can install it with Roswell, or you can also ues more friendly env - cl-repl which also can install by roswell.

  • OS: Linux(Unix)
  • A Common lisp impl with cffi
@lagagain
lagagain / c-printf.lisp
Created December 11, 2018 11:51
[practice] [Common Lisp] CFFI - c-printf example (Common Lisp)
(require :cffi)
(defpackage my-example
(:use :cl :cffi))
(in-package my-example)
;; example: direct call
(foreign-funcall "printf" :string (format nil "%s: %d~%") ;; need change ~% to \0 in c.(end for string)
:string "Hello"
@lagagain
lagagain / main.c
Last active August 15, 2022 06:43
[practice] Lua interact with C
#include "lua.h"
#include "lauxlib.h"
#include<stdio.h>
#include<stdlib.h>
int l_bar0(lua_State *L){
printf("----------- in the bar0 ---------------\n");
printf("----------- out the bar0 ---------------\n\n");
return 0;
@lagagain
lagagain / maybe.js
Last active February 18, 2021 13:50
[javascript] Maybe / Box
function wrap(value){
switch(typeof value){
case 'number':
return new Number(value)
case 'string':
return new String(value)
case 'boolean':
return new Boolean(value)
case 'symbol':
@lagagain
lagagain / readme.md
Last active February 7, 2021 22:39
var/let/global 變數差異

無關鍵字賦值、var宣告、let宣告最大的差別在於生存區域的不同。

無關鍵字賦值 這意味著全域變數的宣告,當然你在全域範圍使用var/let宣告也是全域的。只是無關鍵字可能引發意外的情況,像是你預期變數應該是函數區域的:

function printG(){
  g = 1
  console.log(`printG: `, g)
}
@lagagain
lagagain / callme-1.js
Last active January 31, 2021 01:28
callme
call.exec = true;
call.toc = true;
call(callme, 1);
function callme(i) {
if (i < 0) return i;
console.log(i);
@lagagain
lagagain / .spacemacs
Last active January 2, 2021 06:06
spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@lagagain
lagagain / ted_plugin.js
Created October 31, 2020 12:12
TED plugin
let block_keeper = document.querySelector("div.bg\\:white:nth-child(1) > div:nth-child(1) > div:nth-child(1)");
let video_region = block_keeper.firstChild;
block_keeper.style.height = "400px";
video_region.style.width = "700px";
video_region.style.position = "fixed";
video_region.style.zIndex = 1;
class Repeatable{
static RUN = 0;
static BREAK = -1;
static CONTINUE = 1;
constructor(env = {}){
this.i = 0;
this.env = env;
this._env = {...env};
this.status = Repeatable.RUN;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const config = {
mode: 'development',
entry:{
index: "./src/index.js",
},
output:{