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
@shapr
shapr / Main.hs
Created December 12, 2022 19:31
Inside Termux: apt install ghc, adb push Main.hs $(dest dir); ghc --make -package base Main.hs ; LD_PRELOAD=$PWD/libchallenge_bypass_ristretto_ffi.so ./Main
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
import Foreign.C.String
import Foreign.Ptr
data C_Token
foreign import ccall "lib.h token_random" tokenRandom :: IO (Ptr C_Token)
foreign import ccall "lib.h token_encode_base64" tokenEncodeBase64 :: (Ptr C_Token) -> IO CString
@shapr
shapr / sqlblock.org
Created December 5, 2022 16:41
tiny demo of sql blocks in org-mode
\d
List of relations
SchemaNameTypeOwner
publicoldertableshae
publicupdatestableshae
add_newline = true
format = "$all"
[battery]
full_symbol = "+(bold blue)"
charging_symbol = "⚡(bold green)"
discharging_symbol = "-(bold red)"
[[battery.display]] # "bold red" style and discharging_symbol when capacity is between 0% and 10%
threshold = 10
style = "bold red"
@shapr
shapr / mpc.el
Created September 19, 2022 00:15
Shae's old elisp code
;;; mpc.el --- quick hack to make remote control bindings for mpd via the mpc client
; started out as xmms-shell, became alsaplayer-shell, is now mpc
;; copyright (C) 2005 Shae Matijs Erisson
;; released under the Lesser GPL license.
;; Author: Shae Erisson <[email protected]>
;; Keywords: multimedia mpc mpd fnord mp3 eris ogg flac
;; Version: 0.3
@shapr
shapr / Beggar.rs
Created July 19, 2022 18:59
Beggar My Neighbor in Rust, designed to go as fast as possible
use fastrand;
use std::collections::VecDeque;
use std::fmt;
use std::time::Instant;
impl fmt::Display for Game {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let p1: String = self.p1deal.iter().map(show_card).collect();
let p2: String = self.p2deal.iter().map(show_card).collect();
write!(fmt, "{} {} {}", self.steps, p1, p2)
@shapr
shapr / Main.hs
Created June 9, 2022 20:26
skeleton for advent of code 2015 day 1 part 1
module Main where
main :: IO ()
main = do
theFile <- readFile "input.txt"
print (theFunction theFile)
theFunction x = x
mylength :: Num p => [a] -> p
@shapr
shapr / Transcriptor.hs
Created May 25, 2022 23:20
Haskell script to call ffmpeg
module Main where
import Data.Time.Clock
import Data.Time.Format
import Data.Time.Format.ISO8601
import System.Cmd
import System.Directory
main :: IO ()
main = do
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)))