Skip to content

Instantly share code, notes, and snippets.

@losinggeneration
losinggeneration / moon.xml
Created January 15, 2014 06:44
A MoonScript syntax file for Kate
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
By Harley Laue <losinggeneration@gmail.com>
Based on the CoffeeScript syntax file by Max Shawabkeh (max99x@gmail.com)
and the Lua syntax file by Bruno Massa
-->
<language name="MoonScript"
version="1.0"
@losinggeneration
losinggeneration / gist:8382292
Created January 12, 2014 08:32
Lua markdown
function markdown()
{
lua5.1 <(echo "$(cat << EOLUA
discount=require("discount")
if #arg > 0 then
for _,v in ipairs(arg) do
local lines = ""
local f = io.open(v, "r")
if not f then
io.output(io.stderr):write(string.format([[%s: No such file or directory\n]], v))
@losinggeneration
losinggeneration / scale1
Created June 30, 2020 18:04
String += within a loop issue
goos: linux
goarch: amd64
BenchmarkStringPlus-8 77480 132547 ns/op 1205014 B/op 1 allocs/op
BenchmarkStringPlusFmt-8 63650 124560 ns/op 1203372 B/op 3 allocs/op
BenchmarkStringBuilder-8 51845487 77.0 ns/op 185 B/op 0 allocs/op
BenchmarkStringBuilderFmt-8 7772652 146 ns/op 216 B/op 1 allocs/op
[
{
"name": "Full Size Orthorlinear",
"switchMount": "cherry",
"switchBrand": "kailh",
"switchType": "PG151101D64/D10",
"plate": true
},
[
{
@losinggeneration
losinggeneration / Gopkg.lock
Last active April 21, 2018 00:35
Viper PFlag nested binding
[[projects]]
name = "github.com/fsnotify/fsnotify"
packages = ["."]
revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9"
version = "v1.4.7"
[[projects]]
branch = "master"
name = "github.com/hashicorp/hcl"
packages = [".","hcl/ast","hcl/parser","hcl/printer","hcl/scanner","hcl/strconv","hcl/token","json/parser","json/scanner","json/token"]
@losinggeneration
losinggeneration / main.lua
Last active October 13, 2016 15:37
A Löve2D main.lua bootstrap file for Moonscript. This loads main.moon during development so moonc isn't required. It also has the nice side effect of automatically being overwritten when moonc is run so the game is ready to be distributed.
--[[
DO NOT MAKE CHANGES TO THIS FILE!
This file will purposefully overwritten when moonc is run. However it provides
an easy way to do Moonscript development without having to use moonc to compile
to Lua.
]]--
--[[
License (MIT)
@losinggeneration
losinggeneration / remove_old_debian_linux_kernels.sh
Created April 9, 2013 18:31
A naive script to remove old kernels from Debian
#!/bin/sh
find /boot -type f -mtime +90 -and -name "vmlinuz*" | while read i; do dpkg -S $i; done | cut -d":" -f1 | xargs dpkg -r
@losinggeneration
losinggeneration / lua_macro.zsh
Last active December 15, 2015 10:39
Lua path setting with ZSH functions. This is another reason why ZSH is awesome: macro shell scripting. This removes the need to duplicate code for each of these functions.
# useful for when you have multiple lua commands for different versions
for i in lua lua5.2 lua5.1 luajit; do
function $i()
{
# Get Lua's version
local lua_version=$(command $0 -e "print(string.sub(_VERSION, -3))")
# Append to Lua's paths using normal shell variable interpolation
LUA_PATH=$(command $0 -e "print(package.path..';$HOME/.luarocks/share/lua/$lua_version/?.lua;$HOME/.luarocks/share/lua/$lua_version/?/init.lua;$HOME/.local/share/lua/$lua_version/?.lua;$HOME/.local/share/lua/$lua_version/?/init.lua')") \
LUA_CPATH=$(command $0 -e "print(package.cpath..';$HOME/.luarocks/lib/lua/$lua_version/?.so;$HOME/.local/lib/lua/$lua_version/?.so')") \
command $0 $*
local ret_code , n_jobs = ...
ret_code = tonumber ( ret_code )
n_jobs = tonumber ( n_jobs ) or 0
-- This MUST be updated to where ljsyscall is located
package.path = "/home/harley/Source/languages/lua/ljsyscall/?.lua;" .. package.path
local ljsyscall = require "syscall"
local getenv = os.getenv
local function cmd ( c )
@losinggeneration
losinggeneration / main.c
Created December 10, 2012 17:20
libssh with & without goto for error handling
#include <stdio.h>
#include <stdlib.h>
#include <libssh/libssh.h>
int main(int argc, const char *argv[]) {
char *host = "localhost", *username = "username", *password = "password";
int port = 22, timeout = 5;
ssh_init();
atexit((void(*)())ssh_finalize);