Skip to content

Instantly share code, notes, and snippets.

View stmtk1's full-sized avatar

Motoki saito stmtk1

View GitHub Profile
classDiagram
  class session {
    +uuid id
    +uuid user_id
    +datetime expire
    +boolean valid
  }
  class user {
 +uuid id
my_fact(0, 1).
my_fact(N, P) :- N > 0, M is N - 1, my_fact(M, Q), P is Q * N.
my_sum([], 0).
my_sum([H|R], S) :- my_sum(R, S1), S is S1 + H.
insert(0, E, L, [E|L]).
insert(At, E, [H|L1], [H|L2]) :- At1 is At - 1, insert(At1, E, L1, L2).
my_length([], 0).
/* Script for -pie -z combreloc -z separate-code -z relro -z now */
/* Copyright (C) 2014-2020 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
"elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu"); SEARCH_DIR("=/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu64"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("=/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("=/usr/x86_64-linux-gnu/lib");
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
function Square(props) {
return (
<button className="square" onClick={() => props.onClick()}>
{props.value}
</button>
);
function* primes(n) {
const container = []
yield 2;
container.push(2);
for(let i = 3; i <= n; i += 2) {
let is_prime = true;
for(p of container) {
if(i % p == 0) {
is_prime = false;
#!/bin/zsh
g++ `llvm-config --cxxflags --ldflags --libs --system-libs` main.cpp -o test
@str1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
define i32 @main(i32, i8**) #0 {
%3 = alloca i32, align 4
store i32 0, i32* %3, align 4
%4 = load i32, i32* %3, align 4
%5 = add nsw i32 2, %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str1, i32 0, i32 0), i32 %5)
ret i32 0
}
s --> np, verb; np, verb, np; np, verb, np.
np --> det, noun; noun; prep, np; adj, noun; det, adj, noun.
det --> [the]; [a].
noun --> [dog]; [cat]; [tea].
verb --> [drink]; [have]; [create]; [take].
prep --> [of]; [in]; [at].
adj --> [nice]; [hard]; [soft].
% coloring
adjacent(1, 2).
adjacent(1, 3).
adjacent(1, 4).
adjacent(1, 5).
adjacent(2, 1).
adjacent(2, 3).
adjacent(2, 4).
adjacent(3, 1).
module Main where
import System.Random
import Control.Monad.State.Strict
main = do
putStrLn $ evalState ((loop 100) =<< genCell 100) (mkStdGen 1)
newtype Cell = Cell { unwrapCell :: [Bool] }