Skip to content

Instantly share code, notes, and snippets.

View shapr's full-sized avatar
🏃
VENTRE À TERRE

Shae Erisson shapr

🏃
VENTRE À TERRE
View GitHub Profile
fn solution(s: &str) -> Vec<String> {
let mut pile_of_strings = Vec::new();
let slice: &[char] = &s.chars().collect::<Vec<_>>()[..];
for piece in slice.chunks(2) {
if piece.len() > 1 {
pile_of_strings.push(piece.iter().collect());
} else {
// let squished : &str = &[piece,&['_']].concat();
pile_of_strings.push(&[piece, &['_']].concat().iter().collect());
module Splitty where
splitty :: String -> [String]
splitty [] = []
splitty [c] = [[c, '_']]
splitty (a : b : cs) = [[a, b]] <> splitty cs
@shapr
shapr / org-idle-timer.el
Created May 16, 2022 20:12
org idle timer popup agenda
;; timer variable
(defvar idle-timer-show-org-agenda-timer nil)
;; start function
(defun se/idle-timer-show-org-agenda-start ()
(interactive)
(when (timerp idle-timer-show-org-agenda-timer)
(cancel-timer idle-timer-show-org-agenda-timer))
(setq idle-timer-show-org-agenda-timer
(run-with-idle-timer (* 30 60) 1 #'org-agenda-list)))
import time
import board
import pwmio
led = pwmio.PWMOut(board.A1, frequency=5000, duty_cycle=0)
while True:
for i in range(100):
# PWM LED up and down
if i < 50:
@shapr
shapr / adafruit_httpserver.py
Created May 12, 2022 03:03
add parameter parsing to adafruit httpserver
# SPDX-FileCopyrightText: Copyright (c) 2022 Dan Halbert for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`adafruit_httpserver`
================================================================================
Simple HTTP Server for CircuitPython
@shapr
shapr / code.py
Last active May 16, 2022 03:33
adafruit funhouse with httpserver for setting fibonacci 256 colors
# SPDX-FileCopyrightText: 2022 Dan Halbert for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
from secrets import secrets # pylint: disable=no-name-in-module
from rainbowio import colorwheel
import binascii
import board
import microcontroller
module Demo where
-- notice many of these don't have type signatures.
-- Haskell is smart enough figure out 99% of the type signatures for you.
-- any type signatures here are just to add clarity.
-- number
somenumber = 1
-- string
@shapr
shapr / hpc.torrent.eventlog.txt
Created April 19, 2022 17:46
ghc-eventlog-socket output sent to ghc-events inc
This file has been truncated, but you can view the full file.
Up to date
320205218: cap 0: running thread 14
320219671: cap 0: stopping thread 14 (thread yielding)
320220960: cap 0: running thread 14
320226864: cap 0: stopping thread 14 (making a foreign call)
320270050: cap 0: requesting parallel GC
322755595: cap 0: starting GC
322765713: cap 0: GC working
322927933: cap 0: GC idle
322931427: cap 0: GC working
@shapr
shapr / runner.nix
Created April 16, 2022 22:33
define, build, and load docker container via nix?
virtualisation.oci-containers = {
backend = "docker";
containergs = {
our-container-image = {
autoStart = false;
image = "our-container-image";
imageFile = pkgs.dockerTools.buildImage {
name = "our-container-image";
contents = with pkgs; [ git git-lfs gitlab-runner ];
};
@shapr
shapr / QuickCheck.hs
Created April 7, 2022 17:39
fails as expected
#!/usr/bin/env cabal
{- cabal:
build-depends: base
, QuickCheck
-}
module Main where
import Test.QuickCheck