Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Toggler based on nicknames
// @namespace GHC
// @version 0.2
// @description to get rid of bullshits and tldrs
// @match http://danyk.cz/kniha/kniha.php*
// @require http://code.jquery.com/jquery-2.1.0.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.0/jquery.cookie.js
// @copyright 2014+, Goheeca
// ==/UserScript==
@Goheeca
Goheeca / setpath.bat
Created February 20, 2015 21:37
Executor which is setting the path variable from the file for a command (for Windows)
@echo off
setlocal enabledelayedexpansion
set PATH=
if not "%~1" == "" (
for /f "Tokens=* Delims=" %%x in (%1) do (
if [!PATH!] == [] (
set PATH=!PATH!%%x
) else (
set PATH=!PATH!;%%x
@Goheeca
Goheeca / finite.py
Last active March 13, 2019 18:19
Shamir's Secret Sharing Scheme
from fractions import Fraction
import random
from itertools import zip_longest
class Field(object):
def __init__(self):
self.characteristic = None
def __call__(self, value):
@Goheeca
Goheeca / threads.lisp
Last active November 17, 2019 18:35
Bordeaux Threads test
(require :asdf)
(require :bordeaux-threads)
(defun color-formatter (color)
(format nil "~a[~am~~?~a[m" #\Esc color #\Esc)) ; The formatter function wants a simple-string.
(defun message (color i thread)
(let ((color-format (color-formatter color))
(thread-name (bt:thread-name thread)))
(format t "~&Hello for the ~? time from the ~? thread.~%"
@Goheeca
Goheeca / braille-pixels.lisp
Last active November 17, 2019 18:36
Braille pixels images using cl-charms (@ SBCL)
#!/usr/bin/sbcl --script
#|
Usage
=====
$ ./braille-pixels.lisp [path]
Main
====
@Goheeca
Goheeca / shared.lisp
Last active November 17, 2019 18:45
Multiprocess multithreaded computation with SBCL
#!/usr/bin/sbcl --script
(require :sb-posix)
(require :sb-bsd-sockets)
;;; Globals
;; IPC
(defvar *pid* nil)
(defvar *socket-path* "/tmp/socket")
(defvar *socket* nil)
;; MT
@Goheeca
Goheeca / ambiguous.pyjs
Last active November 17, 2019 18:52
Common Lisp ≡ ⊤
#||| Python or JS that is the question. |#
#|| Let's define a JS function, provided we're in JS. |#
#+moody-js"
function fact(n) {
if (n == 0) return 1
else return n * fact(n - 1)
}
"
@Goheeca
Goheeca / pausable-thread.lisp
Last active February 21, 2021 10:06
Pausable Threads
#!/usr/bin/sbcl --script
(load "~/.sbclrc")
(ql:quickload '("bordeaux-threads") :silent t)
(defun color-formatter (color)
(format nil "~a[~am~~?~a[m" #\Esc color #\Esc))
(defvar *output-lock* (bt:make-lock "OUTPUT LOCK"))
(defmacro safe-format (stream fmt &rest args)
@Goheeca
Goheeca / RefinedTest.hs
Last active November 29, 2021 19:04
refined library issue
#!/usr/bin/env stack
-- stack --resolver lts-18.5 script --package template-haskell --package refined
{-# LANGUAGE TemplateHaskell, TypeApplications #-}
import Refined
import Data.Either
import RefinedTestDefinitions
refinedTypeAppliedTest :: RefinedTest Int
@Goheeca
Goheeca / Main.hs
Last active November 30, 2021 22:19
reflection + template haskell issue
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Reificator
main :: IO ()
main = pure $$(guardTH (operationTest 11 7 4) [|| () ||])