Skip to content

Instantly share code, notes, and snippets.

View cem2ran's full-sized avatar
⚛️
~ The only constant is change ~

Cem Turan cem2ran

⚛️
~ The only constant is change ~
View GitHub Profile
@colomboe
colomboe / fx-test.kt
Created July 4, 2019 19:25
Porting of "Simple example of testing with ZIO environment" to Kotlin
// Porting of https://gist.github.com/jdegoes/dd66656382247dc5b7228fb0f2cb97c8
typealias UserID = String
data class UserProfile(val name: String)
// The database module:
interface DatabaseService {
suspend fun dbLookup(id: UserID): UserProfile
suspend fun dbUpdate(id: UserID, profile: UserProfile)
}
@zephraph
zephraph / clean_node_modules.sh
Last active June 13, 2023 13:53
A shell script to clean up all node_modules in projects that haven't been touched in a couple weeks.
#!/bin/bash
DAYS_SINCE_LAST_CHANGE=14 # If a project hasn't been touched in this long its node_modules will be deleted
SEARCH_PATH="./Git" # Update this to the path where your code is stored
TOTAL_BYTES_REMOVED=0
Mb=1000000
Kb=1000
node_modules=$(find $SEARCH_PATH -name "node_modules" -type d -prune)
@sibelius
sibelius / useEventEmitter.tsx
Created April 16, 2019 01:20
UseEventEmitter hook to work with react navigation navigationOptions buttons
import { useEffect, useRef } from 'react';
export const useEventEmitter = (eventEmitter, eventName: string, fn: () => void) => {
const subscription = useRef(null);
useEffect(() => {
subscription.current = eventEmitter.addListener(eventName, fn);
return () => {
if (subscription.current) {
@eldh
eldh / Hooks.re
Last active April 1, 2019 15:54
ReasonReact useReducer hook
type update('state, 'action) =
| NoUpdate
| Update('state)
| SideEffects(self('state, 'action) => unit)
| UpdateWithSideEffects('state, self('state, 'action) => unit)
and self('state, 'action) = {
state: 'state,
send: 'action => unit,
};
@sibelius
sibelius / Sample.tsx
Created February 27, 2019 15:47
useRelayPagination to be used with React Native Flatlist
const {
isFetchingEnd,
isFetchingTop,
onRefresh,
onEndReached,
} = useRelayPagination(relay, users);
const isRefreshing = isFetchingEnd || isFetchingTop;
<FlatList
@i-am-tom
i-am-tom / Tree.purs
Last active February 1, 2019 18:57
A labelled, uninterestingly-heterogeneous rose tree implementation in PureScript, with a little dash of Coyoneda.
module Data.Labelled.Tree where
-- Traditionally, we express a rose tree with a structure along the lines of
--
-- ```
-- data RoseTree a
-- = RoseTree a (Array (RoseTree a))
-- ```
--
-- As with many of our favourite "Haskell containers", this comes with an
@cellularmitosis
cellularmitosis / solutions-by-exercise.md
Last active May 25, 2021 21:20
Index of Exercism.io solutions, grouped by problem

Blog 2019/1/25

<- previous | index | next ->

Index of solutions to Exercism.io problems (grouped by exercise)

Browsing solutions to the same problem is a great way to compare languages!

@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@rxwei
rxwei / ad-manifesto.md
Last active November 9, 2023 09:58
First-Class Automatic Differentiation in Swift: A Manifesto
@webcpu
webcpu / exercism-downloader.py
Last active October 14, 2018 08:25
Download all of the exercism ReasonML projects and install the npm packages. (macOS)
#!/usr/local/bin/python3
import os
import subprocess
import json
from os.path import expanduser
home = expanduser("~")
track = 'reasonml'
projects = ['protein-translation', 'armstrong-numbers', 'change', 'rna-transcription', 'space-age', 'bob', 'anagram', 'accumulate', 'run-length-encoding', 'minesweeper', 'hello-world', 'leap', 'isogram', 'raindrops', 'acronym', 'word-count', 'allergies', 'all-your-base', 'pangram', 'binary-search']