Skip to content

Instantly share code, notes, and snippets.

Cole Lawrence colelawrence

Block or report user

Report or block colelawrence

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
@colelawrence
colelawrence / scroll-into-view.js
Last active May 31, 2019
Scroll into view assistant for triggering animations and stuff
View scroll-into-view.js
const log = console.log.bind(console);
const elts = [].slice.call(document.getElementsByClassName("siv"));
elts.forEach(elt => elt.classList.add("siv-enabled"));
elts.forEach(elt => log(elt, { offset: getOffset(elt) }));
onScroll(window, (scrollX, scrollY) => {
elts.forEach(elt => {
const top = getOffset(elt).top;
@colelawrence
colelawrence / on-scroll.js
Created May 31, 2019
Passive onscroll event listener
View on-scroll.js
onScroll(window, (scrollX, scrollY) => {
log({ scrollX, scrollY })
})
function onScroll(target: HTMLElement, fn) {
const onscroll = (_evt) => fn(target.scrollX, target.scrollY);
if (supportsPassive()) {
target.addEventListener("scroll", onscroll, { passive: true })
} else {
@colelawrence
colelawrence / speech-recognition.lua
Created Dec 2, 2018
unknown realtalk sample -- not sure if this would work with current realtalk system, just playing around...
View speech-recognition.lua
-- Voice recognizer
When /person/ speaking is heard /speech/:
-- word { confidence, lowercase, pauses_after }
local words = identify(speech)
When (person) was asked if they meant /option index/ of /possible_choices/,
/yes_or_no/ as (nlp_yes_no(words)) is (not_nil):
if yes_or_no then
-- yes, so execute choice
local choice = possible_choices[index]
@colelawrence
colelawrence / randAlphanum.go
Created Aug 8, 2018
Random alpha-numeric rust and golang
View randAlphanum.go
func randAlphanum() byte {
// >>> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~<<<
// lowercase 97...122 = 26
// uppercase 65...90 = 26
// numerals 48...57 = 10
// lowercase 0...25, + 97
// uppercase 26...51, + 39
// numerals 52...61, - 4
var val = rand.Intn(62)
if val >= 52 {
View keybase.md

Keybase proof

I hereby claim:

  • I am colelawrence on github.
  • I am colelawr (https://keybase.io/colelawr) on keybase.
  • I have a public key whose fingerprint is 8370 0CDE B75E 31F7 7605 4CF5 0D82 40E5 138C 1DB1

To claim this, I am signing this object:

@colelawrence
colelawrence / GetStarted1_Script.fsx
Created Mar 28, 2017
Practicing F-Sharp, very similar to Elixir concepts.
View GetStarted1_Script.fsx
#load "GetStarted1.fs"
open GetStarted1
// https://fsharpforfunandprofit.com/posts/control-flow-expressions/
// https://docs.microsoft.com/en-us/dotnet/articles/fsharp/tour#pipelines-and-composition
// Pattern matching examples
let a,b = 1,2
type Person = {First:string; Last:string}
View 2017-01-20 Computer Systems.md

What makes up the CPU?

Anticipate looking up videos about console emulation to find these terms in that context.

  • ALU

  • CU

  • CPU

    • Internal memory (cache)
View change-case.ts
// kebab => capitallization
// open-up => OpenUp
// -a => A
function kebabToCaps(str) {
return String(str).replace(/(?:\-|^)(\w)?/g, (match, letter) => {
return letter ? letter.toUpperCase() : ''
})
}
@colelawrence
colelawrence / ch3-line-info.exs
Last active Sep 28, 2016
Practice - Chapter 3 - Elixir in Action
View ch3-line-info.exs
defmodule LineInfo do
@spec lines_lengths!(String.t) :: Stream.t
def lines_lengths! filepath do
File.stream!(filepath)
|> Stream.map(&String.replace(&1, "\n", ""))
|> Stream.map(&{&1, String.length(&1)})
|> Stream.with_index
end
defp get_val {{_, val}, _} do
@colelawrence
colelawrence / .nvidia-settings-rc
Last active Aug 25, 2016
Setting up Linux Mint
View .nvidia-settings-rc
#
# /home/colelawrence/.nvidia-settings-rc
#
# Configuration file for nvidia-settings - the NVIDIA X Server Settings utility
# Generated on Sun Aug 7 13:17:23 2016
#
# ConfigProperties:
RcFileLocale = C
You can’t perform that action at this time.