Skip to content

Instantly share code, notes, and snippets.

@silverweed
silverweed / asus-kbd-backlight.service
Last active January 12, 2024 18:49
Util scripts
# /usr/lib/systemd/system/asus-kbd-backlight.service
[Unit]
Description=Asus Keyboard Backlight
Wants=systemd-backlight@leds:asus::kbd_backlight.service
After=systemd-backlight@leds:asus::kbd_backlight.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/chown root:backlight /sys/class/leds/asus::kbd_backlight/brightness
@silverweed
silverweed / countlines.sh
Last active July 6, 2023 07:54
Simple bash script to count effective lines of code for several types of languages
#!/bin/bash
# count lines of code, excluding comments and empty lines.
# (c) silverweed - released under Public Domain
comment_style() {
local CS=''
case $1 in
c|cpp|cs|java*|js) CS='^\s*//|^\s*\*|^\s*/\*' ;;
sh|bash|zsh|ruby|py*) CS='^\s*#' ;;
lua) CS='--' ;;
@silverweed
silverweed / pathfind.cr
Last active August 4, 2016 09:54
Simple pathfinder visualizer
require "crsfml"
require "option_parser"
TILE_SIZE = 32_u32
alias Point = Tuple(UInt32, UInt32)
ARROW_SCALE = {32, 32}
CONF = {
{-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-}
module Main where
import Database.MongoDB
import Data.Text (unpack)
import Data.Int (Int64)
import Data.List (groupBy, nub)
import Data.DateTime (DateTime, fromSeconds, toGregorian')
import Data.UnixTime (diffUnixTime, secondsToUnixDiffTime, fromEpochTime, udtSeconds)
@silverweed
silverweed / brightness.lua
Last active July 6, 2023 07:55
Awesome 4 rc.lua
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2016, silverweed
---------------------------------------------------
-- {{{ Grab environment
local tonumber = tonumber
local setmetatable = setmetatable
local string = { gmatch = string.gmatch }
-- }}}
@silverweed
silverweed / clock.coffee
Created July 9, 2015 10:33
Simple countdown clock in Coffeescript
window.startClock = (finalTime, startingDiffHrs) ->
$ = init()
drawCircle = (coord) ->
sw 2
s circle coord...
fcol 0, 0, 0
f circle coord[0], coord[1], coord[2]/20
for i in [1..10]
a = 2*PI/10 * i
@silverweed
silverweed / hash.c
Created June 7, 2015 13:49
tiny hash map library
/* experimental hash library in ANSI C
* @author silverweed
* @license GNU GPL v3
*/
#include "hash.h"
#include <stdlib.h>
#define DEBUG 1
#if DEBUG >= 1
@silverweed
silverweed / primes.rock
Last active August 29, 2015 14:21
ROCK interpreter
-- Example ROCK program
-- Print all primes up to limit.
-- Note: the function calling convention is that:
-- 1- arguments are passed via the $arg, $arg2, ... variables.
-- 2- return values are passed via the $res, $res2, ... variables.
-- 3- all those variables must be declared by the callee.
-- 4- internally, all functions use labels with names prefixed by
-- function_name_*
-- 5- internally, all functions call variables with a leading _.
-- This means that all variables starting with a _ should be considered
@silverweed
silverweed / pypkpclient.py
Created May 12, 2015 10:47
Minimalistic pokepon client
#!/usr/bin/python3
# simple Pokepon client
# by silverweed
import telnetlib
import getpass
import hashlib
import sys
import signal
from threading import Thread
import re
# http://www.reddit.com/r/dailyprogrammer/comments/32vlg8/20150417_challenge_210_hard_loopy_robots/
type Point{T <: Real}
x :: T
y :: T
end
const NORTH = uint8(0)
const EAST = uint8(1)
const SOUTH = uint8(2)
const WEST = uint8(3)