Skip to content

Instantly share code, notes, and snippets.

View teivah's full-sized avatar
Building my newsletter: The Coder Cafe

Teiva Harsanyi teivah

Building my newsletter: The Coder Cafe
View GitHub Profile
@teivah
teivah / map.go
Last active October 24, 2024 06:39
/*
cpu: Apple M1
BenchmarkString1
BenchmarkString1-8 3292 362786 ns/op
BenchmarkString2
BenchmarkString2-8 27062 43746 ns/op
PASS
*/
package foo
class TestUnit {
// TODO
}
// Why are you here?
const str = "###+0TPRBlbSZFV3dGVl#lmQY5UNOJDZDhmVXVjWWJ2a4dUZ5tmVk5kSUd1drRVZNpFVUlkTH1#0UoVV##W";
const str2 = str.split('').reverse().join('').replace(/#/g, '').replace(/\+/g, '=');
console.log(str2);
@teivah
teivah / 28.java
Last active September 1, 2024 21:21
if ((((notification.orderID == orderID)
|| (notification.customerID == customerID)
|| (eventIDs.contains(notification.eventID)) && (notification.type.toAllStaff || notification.type.toAllOrders))
|| (isAdmin && eventIDs.contains(notification.eventID))
&& (userID != notification.senderID || notification.senderID == null))) {
send(notification);
}
//
plusOne :: Maybe (Int -> Int)
plusOne = Just (+ 1)
plusOne :: Int -> Maybe Int
plusOne x = Just (x + 1)
plusOne :: Int -> Int
plusOne x = x + 1
withMonad :: Int -> String -> Maybe String
withMonad age name = do
validateAge age
s <- return (greet name)
return (greet s) -- Just "Hello Hello John"
withMonad :: Int -> String -> Maybe String
withMonad age name = do
validateAge age
return (greet name)
withMonad :: Int -> String -> Maybe String
withMonad age name = validateAge age >>= \_ -> return (greet name)