Skip to content

Instantly share code, notes, and snippets.

View cipharius's full-sized avatar

Valts Liepiņš cipharius

View GitHub Profile
@cipharius
cipharius / inputActions.nim
Created December 8, 2017 07:46
Keyboard input actions for SDL2 on Nim
import strutils
import sdl2
type
ListenerPtr = proc (action: Action) {.closure.}
Action* = ref object
active: bool
kind: string
keysyms: seq[cint]
@cipharius
cipharius / rbxForumFetcher.py
Created December 7, 2017 16:03
Script for fetching roblox forum posts
import requests
from bs4 import BeautifulSoup
from time import sleep
forumID = 32
# Get the required form content
request = requests.get("https://forum.roblox.com/Forum/ShowForum.aspx?ForumID={}".format(forumID))
soup = BeautifulSoup(request.text, "html.parser")
@cipharius
cipharius / translate-to-josh.nim
Last active November 26, 2017 23:33
Algorithms to translate ASCII message to JoshScript code
import algorithm
import strutils
proc splitChars(str: string): seq[char] =
result = @[]
for ch in str:
add result, ch
proc translateSimple(text: string): string =
## Translates ASCII to JoshScript
@cipharius
cipharius / polish-notation.lua
Last active November 22, 2017 01:18
Polish notation parser in Lua
-- Operations definitions
local operations = {
["+"] = {
Arguments = 2,
Operation = function(a, b) return a + b end
},
["-"] = {
Arguments = 2,
Operation = function(a, b) return a - b end
},
@cipharius
cipharius / Vector2.lua
Last active November 17, 2017 06:58
2D Vector implementation in Lua
local Vector2 = {}
function Vector2.new(x, y)
local mt = {}
local unit,magnitude
x = x or 0
y = y or 0
function mt:__index(i)
@cipharius
cipharius / json-sort.el
Last active June 26, 2018 17:52
Emacs JSON sort
(require 'json)
(defun sort-json (point)
"Sort JSON-like structure surrounding the point."
(interactive "d")
(let ((object-begin (nth 1 (syntax-ppss point)))
(begin-point (point)))
(when object-begin
(goto-char object-begin)
(forward-list)