This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require rackunit) | |
(define (second pair) | |
(car (cdr pair))) | |
(define (frame-total frame) | |
(cond | |
((null? (cdr frame)) (car frame)) | |
(else (+ (car frame) (second frame))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.whitford.codewars; | |
import java.util.PrimitiveIterator.OfInt; | |
public class BrainLuck { | |
private byte[] instructions; | |
private byte[] data = new byte[255]; | |
private int dataPointer = 0; | |
private int instructionPointer = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cal) | |
(defn cal [d first-day-of-holiday] | |
(if (.isBefore d first-day-of-holiday) | |
(if (or (= (.getDayOfWeek d) java.time.DayOfWeek/FRIDAY) | |
(= (.getDayOfWeek d) java.time.DayOfWeek/SATURDAY) | |
(= (.getDayOfWeek d) java.time.DayOfWeek/SUNDAY)) | |
(cons "🍺" (cal (.plusDays d 1) first-day-of-holiday)) | |
(cons "💻" (cal (.plusDays d 1) first-day-of-holiday))) | |
'("🎄"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import strutils | |
import sequtils | |
import sugar | |
# Credit to https://forum.nim-lang.org/t/2812 | |
proc comb[T](a: openarray[T]; n: int; use: seq[bool]): seq[seq[T]] = | |
result = newSeq[seq[T]]() | |
var use = use | |
if n <= 0: return | |
for i in 0 .. a.high: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react"; | |
function Srchr({ searchItems }) { | |
const [searchText, setSearchText] = useState(null) | |
const [matchedItems, setMatchedItems] = useState([]) | |
useEffect(() => { | |
if (!searchText || searchText.length < 1) { | |
setMatchedItems([]) | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const fs = require('fs') | |
const crypto = require('crypto') | |
const r = process.stdin | |
r.on('readable', () => { | |
var c | |
while((c = r.read(1)) !== null) { | |
var s = c.toString() | |
if (s.match(/[a-z]/i)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec combs_with_rep size inputs = | |
match (size, inputs) with | |
| 0, _ -> [ [] ] | |
| _, [] -> [] | |
| k, hd :: tl -> | |
let next = combs_with_rep (k - 1) inputs in | |
let slice = List.map (fun a -> hd :: a) next in | |
slice @ combs_with_rep k tl | |
let () = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type note = C | Succ of note | Pred of note | |
let repeat f n v = | |
let rec helper f n v = if n = 0 then v else helper f (n - 1) (f v) in | |
helper f n v | |
let up_semitone = function | |
| Pred C -> C | |
| Pred n -> n | |
| Succ n -> Succ(Succ n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/gawk -f | |
BEGIN { | |
FS="," | |
} | |
NR != 1 { | |
gsub(/%/, "", $4) | |
if ($3 in services) { | |
services[$3] = services[$3] + $4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk'); | |
exports.handler = (_ev, _cont, callback) => { | |
const s3 = new AWS.S3(); | |
const bucketname = process.env.bucketname | |
const listParams = { | |
Bucket: bucketname, | |
MaxKeys: 50 | |
} | |
NewerOlder