Skip to content

Instantly share code, notes, and snippets.

View haliphax's full-sized avatar
💭
git clone self

haliphax

💭
git clone self
View GitHub Profile
@haliphax
haliphax / SumFile.fs
Last active February 28, 2024 18:25
Sum all of the lines in a given file which are integers
open System.IO
// sums up all of the lines in a given file
let sumFile (fileName:string) =
// wrapper for catching int conversion exceptions
let wrapper (sr:System.IO.StreamReader) =
try
int (sr.ReadLine())
with
| :? System.FormatException -> 0
@haliphax
haliphax / vtecho.py
Created February 25, 2016 21:35
Player script for textfiles.com VT100 animations
#!/usr/bin/env python2.7
"""
This script will echo each line in either stdin or a given file,
with a 1/50th of a second delay between each. This makes it
suitable for "playing" the animations found on textfiles.com:
http://artscene.textfiles.com/vt100/
Just use it like this:
@haliphax
haliphax / jquery.inview.js
Created April 20, 2016 17:11
jQuery :inview and :reached psuedo-selectors
// jQuery pseudo-selectors to figure out if an element is on-screen
$.extend($.expr[':'], {
// determines if the element is within the viewport
'inviewport': function (el) {
var $el = $(el)
, h = $el.outerHeight()
, t = $el.offset().top
, b = t + h
, s = $(document).scrollTop()
, w = $(window).height()
@haliphax
haliphax / wpx
Last active April 26, 2017 04:19
automagic WINEPREFIX script
#!/usr/bin/env bash
# Copyright (c) 2016 haliphax
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
<?php
/***
* Pull HTML source for given URL and format for output
* 2011 haliphax https://github.com/haliphax
**/
?>
<!DOCTYPE html>
<html>
<head>
<title>Format page as plain text</title>
@haliphax
haliphax / nodechat.py
Created May 25, 2018 03:50
nodechat.py band-aid version cannibalized from ircchat.py
""" Node chat script for x/84. Bastardized from ircchat.py. """
# stdlib
from collections import deque
import datetime
import re
import warnings
# 3rd party
from x84.bbs import (ScrollingEditor, getsession, echo, getterminal,
get_ini, syncterm_setfont, LineEditor)
@haliphax
haliphax / README.md
Last active August 28, 2018 17:47
Roll20 NPC spell slots bookmarklet

Roll20 NPC spell slots bookmarklet

This bookmarklet can be used to produce a clickable list of spells for an NPC chat macro. You input the spell level (0 for cantrips), the number of slots available for that level, and it will produce the markup to put into a chat macro.

As far as building the shell for the spellbook is concerned, this should get you started:

/w GM &{template:default}{{name=@{selected|character_name} Spellcasting
}}{{ DC @{selected|spell_save_dc} = +@{selected|spell_attack_bonus} to hit
}}{{ Cantrips = [@{selected|repeating_spell-cantrip_$0_spellname}](~selected|repeating_spell-cantrip_$0_spell)
@haliphax
haliphax / flatten.py
Last active February 28, 2024 18:26
Flatten irregular array
def flatten(source):
"""
Flattens an irregular array into a single dimension.
:param list source: The array to flatten
:rtype: list
:returns: The flattened array
"""
assert isinstance(source, (list, tuple)), 'Only lists and tuples are supported'
@haliphax
haliphax / WhenNewItemTemplateIsDerivedFrom.cs
Created June 10, 2019 17:15
Sitecore bucket condition for determining if a new item is made or derived from a specific template
using Sitecore.Buckets.Rules.Bucketing;
using Sitecore.Data;
using Sitecore.Data.Managers;
using Sitecore.Data.Templates;
using Sitecore.Rules.Conditions;
namespace Custom.Sitecore.Feature.Blog.BucketConditions
{
public class WhenNewItemTemplateIsDerivedFrom<T> : WhenCondition<T> where T : BucketingRuleContext
{
@haliphax
haliphax / nc-imp-pet-status-b4.user.js
Last active March 9, 2021 18:21
Nexus Clash Improved Pet Status (B4) UserScript
// ==UserScript==
// @name Nexus Clash Improved Pet Status (B4)
// @description Adds color to pet status pane based on remaining AP
// @namespace https://roadha.us
// @author haliphax
// @version 1.5
// @include https://www.nexusclash.com/modules.php?name=Game*
// @include https://nexusclash.com/modules.php?name=Game*
// @grant GM_getValue
// @grant GM.getValue