Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
class Env:
def __init__(self, bindings, parent=None):
self.bindings = bindings
self.parent = parent
@staticmethod
def init_env():
@carrotflakes
carrotflakes / echo-bot.lisp
Created April 10, 2019 13:07
echo bot on twitter in Common Lisp
(ql:quickload :chirp)
(setf chirp:*oauth-api-key* "Put"
chirp:*oauth-api-secret* "your"
chirp:*oauth-access-token* "credencials"
chirp:*oauth-access-secret* "here!")
(print (chirp:account/verify-credentials))
(defun status-text-without-mention (status)
@carrotflakes
carrotflakes / app.lisp
Last active April 20, 2019 08:32
fail-safe ningle app with woo server
(ql:quickload '(:ningle :clack))
(defvar *app* (make-instance 'ningle:<app>))
(setf (ningle:route *app* "/")
"Hello :)")
(setf (ningle:route *app* "/error")
(lambda (params)
(declare (ignore params))
const commands = {
add: {
do(state, action) {
return {
num: state.num + action.x
};
},
undo(state, action) {
return {
num: state.num - action.x
/*
* Dual-fisheye 形式の動画を横長の動画にして出力するプログラム
*
* コンパイル:
* $ g++ convert_dfe.cpp `pkg-config opencv --cflags --libs` -std=c++11 -O3 -o convert_dfe
*
* 使い方:
* $ convert_dfe 入力動画パス 出力動画パス
*/
@carrotflakes
carrotflakes / make_movie.rs
Last active August 25, 2023 09:01
Generate a movie by Rust with FFmpeg.
use std::io::Write;
use std::process::{Command, Stdio};
fn make_frame(width: usize, height: usize, time: usize) -> Vec<u8> {
let mut frame = Vec::with_capacity(4 * width * height);
for y in 0..height {
for x in 0..width {
frame.push((x % 256) as u8);
frame.push((y % 256) as u8);
frame.push((time % 256) as u8);
@carrotflakes
carrotflakes / 28.js
Created August 27, 2019 13:22
28 the virtual machine
// Basic instructions
const NOP = 0;
const MOVE = 5;
const MOVE_2_1 = 6;
const STORE_TO_M0 = 10;
const STORE_TO_M1 = 11;
const STORE_TO_C1 = 12;
const SET_MC1_ROOT = 15;
const SET_C1_ROOT = 16;
const RESOLVE = 20;
% 知識
food("中華料理").
food("フランス料理").
food("イタリア料理").
place("新宿").
place("渋谷").
place("池袋").
restaurant("川香苑 本店", "中華料理", "新宿", 3000).
nextto(X, Y, List) :- iright(X, Y, List).
nextto(X, Y, List) :- iright(Y, X, List).
iright(Left, Right, [Left, Right | _]).
iright(Left, Right, [_ | Rest]) :- iright(Left, Right, Rest).
zebra(H, W, Z) :-
H = [house(norwegian, _, _, _, _), _, house(_, _, _, milk, _), _, _],
member(house(englishman, _, _, _, red), H),
member(house(spaniard, dog, _, _, _), H),
member(house(_, _, _, coffee, green), H),
member(house(ukrainian, _, _, tea, _), H),
@carrotflakes
carrotflakes / main.rs
Last active November 29, 2019 16:37
[WIP] A Lisp implementation in Rust =>https://github.com/carrotflakes/gluten
use std::rc::Rc;
use std::cell::RefCell;
use std::str::Chars;
type R<T> = Rc<RefCell<T>>;
#[derive(Debug, Clone)]
enum V {
Symbol(String),
Int(i64),