Skip to content

Instantly share code, notes, and snippets.

Certified GitHub Pro

Lance E Sloan sloanlance

Certified GitHub Pro
Block or report user

Report or block sloanlance

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
sloanlance / three_reasons.bas
Last active Dec 10, 2018
"Three Reasons To Own a Computer" for Commodore 64, from Compute!'s Gazette (via
View three_reasons.bas
10 FORL=54272 TO 54295:POKEL,0:NEXT:POKE54296,15
20 POKE54277,8:POKE54278,255:POKE54276,23
30 F2=4
40 FORZ=1TO3:POKE54287,F2
50 FORF1=1TO200
60 POKE54273,F1:F2=F2+.01:NEXTF1:NEXTZ:POKE54278,15
sloanlance /
Created Jul 19, 2018
Python: Class member access enforcement (not encapsulation)
# From Stack Overflow question:
# Python has simple encapsulation, but it doesn't strictly enforce access to
# protected or private class members. This is one person's attempt to
# address that in a (misleadingly named) class.
# Could this be done with introspection rather than using on `self.privates` and
# `self.protected`? Follow the common Python style of naming variables `__a` and `_b`.
# Then the methods would check whether the names begin with `__` or `_` to allow or
View display_system.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
sloanlance / Jekyll & Liquid Cheatsheet
Last active May 23, 2018 — forked from magicznyleszek/
Jekyll & Liquid Cheatsheet (A fork of the gist by "magicznyleszek", FKA "smutnyleszek")
View Jekyll & Liquid Cheatsheet
See: `Jekyll & Liquid`
sloanlance /
Last active Mar 8, 2018
jq: JSONL → TSV conversion

jq: JSONL → TSV conversion

What is TSV?

TSV means "tab-separated values". I prefer this format over CSV ("comma-separated values") because it doesn't require as much quoting. Many programs that can use CSV formatted data can also use TSV, although they may need to be explicitly told of the different format if it's not detected automatically.

However, in any of the jq scripts below, "@tsv" can usually be replaced with "@csv" to get CSV output instead.

sloanlance /
Last active Apr 2, 2020
jq: JSONL ↔︎ JSON conversion

jq: JSONL ↔︎ JSON conversion


    jq -s '.' input.jsonl > output.json

    jq -c '.[]' input.json > output.jsonl
sloanlance / pseudorandom_alphabetical_string.js
Last active Feb 15, 2018
JS: pseudorandom alphabetical string
View pseudorandom_alphabetical_string.js
// "Pseudorandom", because it's not guaranteed to be truly random.
// Express a floating point random number as base 26 and remove "0." from the beginning.
// Next, to make it alphabetical, replace digits 0-9 with letters q-z.
// @returns {string} Usually 10 to 13 characters in length
Math.random().toString(26).substring(2).replace(/[0-9]/g, function (c) {return 'qrstuvwxyz'[c]});
// Alternate, non-function versions (which is more efficient?)
Math.random().toString(26).substring(2).split('').map(c => 'qrstuvwxyz'[c] || c).join(''); // split to array, replace, join to string
Math.random().toString(26).substring(2).replace(/[0-9]/g, c => 'qrstuvwxyz'[c]); // examine only characters 0-9
Math.random().toString(26).substring(2).replace(/./g, c => 'qrstuvwxyz'[c] || c); // examine all characters
sloanlance /
Created Jan 22, 2018 — forked from SpaceVoyager/
How to make a standalone iOS app with Pythonista

After you made some cool games or apps with Pythonista, you may want to make it run as a standaone app on iPad/iPhone and possibly share it on the AppStore. This how-to tells you how to do it.

What you need:

  1. Pythonista code you wrote
  2. A Mac with Xcode 7.1 installed
  3. iPhone/iPad running iOS 9


  1. Download The original PythonistaProjectTemplate described at does not work with Xcode 7. I updated it to work with Xcode 7 and added a more interesting example than the plain old Hello World thing.
  2. Unzip the file and open the project in Xcode 7.1. In project settings, change the Bundle Identifier from com.yuhangwang.pythonistaproject to something else.
sloanlance / getTimestampWithFraction.php
Created Jan 15, 2018
PHP: A replacement for the shamefully broken DateTime::getTimestamp
View getTimestampWithFraction.php
* Problem: `DateTime::getTimestamp` returns **_`int`_**! Calculations such as the following
* are incorrect if the `DateTime` object includes fractions of seconds:
* ```php
* $durationSeconds = strval($endTime->getTimestamp() - $startTimestamp);
* ```
* `DateTime::diff` can subtract properly, but only under PHP 7.1. (Curiously,
* `DateTime::getTimestamp` still returns `int` under PHP 7.1!)
sloanlance / Karabiner: Require fn for esc
Last active Dec 21, 2017
Karabiner: Require fn modifier key to activate esc key. Useful for preventing accidental esc keypresses on Macs with a Touch Bar. Doesn't affect all other modifier combinations (i.e., option + command + esc works without requiring fn, too).
View Karabiner: Require fn for esc
Please see the file in this gist.
You can’t perform that action at this time.