Skip to content

Instantly share code, notes, and snippets.

View cwfoo's full-sized avatar

Foo Chuan Wei cwfoo

View GitHub Profile
@cwfoo
cwfoo / scheme-coin.lisp
Created April 28, 2022 12:26 — forked from BusFactor1Inc/scheme-coin.lisp
A Common Lisp Blockchain - Scheme Coin
;;
;; scheme coin - a common lisp blockchain
;;
;; Burton Samograd
;; 2017
(load "~/quicklisp/setup.lisp")
(defconstant *coin-name* "Scheme Coin")
@cwfoo
cwfoo / eval-when-test.lisp
Created April 15, 2022 20:28 — forked from ANDRON94/eval-when-test.lisp
Explanation of how 'eval-when' works in Common Lisp
;;; explanation for LOAD *.lisp
;;; 1. Load ignores :compile-toplevel, :load-toplevel
;;; Result: NIL is returned
;;; explanation for COMPILE
;;; 1. not-compile-time(NCT)
;;; 2. ignore mode, EVAL, remains in current mode
;;; Result: print to output 'foo-compile'
;;; explanation for LOAD *.fasl
@cwfoo
cwfoo / html.lisp
Created November 16, 2021 04:38 — forked from markasoftware/html.lisp
html->string (Super simple HTML templating for Lisp)
;; Copyright (c) 2020 Mark Polyakov
;; Released under the WTFPL (Do What The Fuck You Want To Public License)
(defvar *html-void-tags* '(:area :base :br :col :embed :hr :img :input :link
:meta :param :source :track :wbr)
"String designators for self-closing/void tags.
https://html.spec.whatwg.org/multipage/syntax.html#void-elements")
(defvar *html-escapes*
'(#\> ">"
@cwfoo
cwfoo / brainfuck.lisp
Created January 14, 2021 22:56 — forked from koji-kojiro/brainfuck.lisp
brainfuck compiler written in Common Lisp (SBCL)
#!/usr/bin/sbcl --script
;;; brainfuck compiler written in Common Lisp (SBCL)
;;; author: TANI Kojiro
;;; usage: `sbcl --script brainfuck.lisp` or `chmod +x brainfuck.lisp; ./brainfuck.lisp`
(declaim ((simple-array (unsigned-byte 8) (*)) *memory*))
(defvar *memory* (make-array 30000 :element-type '(unsigned-byte 8)))
(defvar *pointer* 0)
(defvar *bf-readtable* (make-instance 'readtable))
@cwfoo
cwfoo / EntityManagerProducer.java
Created February 25, 2020 06:42 — forked from daniel-shuy/EntityManagerProducer.java
JPA + CDI : @Inject EntityManager as a @RequestScoped bean
import javax.enterprise.context.Dependent;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Dependent
public class EntityManagerProducer {
@PersistenceContext(name = "persistence-unit") // name is Persistence Unit Name configured in persistence.xml
private EntityManager entityManager;
@cwfoo
cwfoo / TB_Chat_auth.md
Created February 20, 2020 01:12 — forked from moisseev/TB_Chat_auth.md
Using Thunderbird's Chat to connect to IRC servers requiring authentication

There are two ways to authenticate on IRC server:

  1. Identify nick with NickServ;
  2. Using the PASS command in the IRC protocol (not supported in the Thunderbird UI).

If your server or bouncer requires [2], set the following preferences as string values:

messenger.account.accountN.options.serverPassword
messenger.account.accountN.options.username

How do I do this thing?

I'm not aware of how to use Google, how do I do this basic thing in Language X?

tagged coding, question

edited by Grammar Nazi (2.5M), asked by 1337z0r (2)

Answer 1 (12)

@cwfoo
cwfoo / watermark.py
Created March 18, 2018 15:57 — forked from snay2/watermark.py
How to apply a semi-transparent watermark to an image using Python
from PIL import Image, ImageDraw
def main():
# Open the original image
main = Image.open("12voltm.jpg")
# Create a new image for the watermark with an alpha layer (RGBA)
# the same size as the original image
watermark = Image.new("RGBA", main.size)
# Get an ImageDraw object so we can draw on the image
@cwfoo
cwfoo / haiku
Created March 6, 2018 23:44 — forked from friggeri/haiku
random heroku-like name generator
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",