Skip to content

Instantly share code, notes, and snippets.

View crshmk's full-sized avatar

Chris Hammock crshmk

  • Nha Trang, Vietnam
View GitHub Profile
@crshmk
crshmk / script.js
Last active March 7, 2022 21:19
apply a transform to each key in an object
import updateKeys from './updateKeys'
import { map, toLower } from 'ramda'
const x = {
ONE: 1,
TWO: 2
}
const toLowerKeys = updateKeys(toLower)
toLowerKeys(x)
@crshmk
crshmk / .bash_profile
Created December 8, 2020 20:58
delete test snapshots
alias rmsnap="find ./ -name '*.snap' -delete"
@crshmk
crshmk / App.jsx
Last active February 9, 2021 14:28
jest / react-testing-library / axe
import React from "react"
let App = () => (
<div>
<img data-testid="image" src="" />
<p>hi</p>
</div>
)
export default App
@crshmk
crshmk / App.js
Last active February 9, 2021 16:13
Wrapper for jest-axe
import React from "react"
let App = () => (
<div>
<img src="" />
<p>hi</p>
</div>
)
export default App
@crshmk
crshmk / docker_commands.txt
Last active March 14, 2021 00:09
Standard Docker commands
# download and run an image
docker run image-name
# list images
docker images
# build an image
docker build -t image-name <path>
# run an image
@crshmk
crshmk / makeCities.js
Last active January 2, 2023 08:44
Some point-free string processing with curried utils
// let's create a util by composing common utils
import {
join,
map,
pipe,
reverse,
split,
tail,
toArray,
toLower,
@crshmk
crshmk / replace.js
Last active January 2, 2023 05:35
a string replace api that takes a map of replacements
const replace = replacements => str => {
const fragmentsToReplace = Object.keys(replacements).join('|')
const regex = new RegExp(fragmentsToReplace, 'g')
return str.replace(regex, match => replacements[match])
}
@crshmk
crshmk / 11_svelte-file.svelte
Last active November 3, 2022 20:44
Learn Svelte in a gist
<script>
let x
</script>
<p>markup</p>
<style>
body {
background: white;
}
import { fromPairs, map, path, pipe, split, tail } from 'ramda'
const removeEmptyQuery = filter(complement(isNil))
const getQueryParams = pipe(
path(['location', 'search']),
tail,
split('&'),
map(split('=')),
fromPairs,
@crshmk
crshmk / mapObj.js
Created July 4, 2022 16:45
a cleaner Object.entries api
const mapObj = (fn, obj) =>
Object.entries(obj).map(([key, value]) => {
return fn(value, key)
})