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 golangglobalcachewithmutex | |
import "sync" | |
type MemCache[K comparable, T any] struct { | |
cache map[K]T | |
mutex *sync.Mutex | |
} | |
func (m MemCache[K, T]) Get(key K) (T, bool) { |
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
use std::collections::HashMap; | |
fn parse_string(chars: &[char]) -> (String, &[char]) { | |
if chars[0] != '"' { | |
unreachable!() | |
} | |
let mut result = vec![]; | |
let mut index = 1; |
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 React, { useState, useCallback, MouseEvent } from "react"; | |
import { css } from "@emotion/core"; | |
const RippleEffect = ({ | |
top, | |
left, | |
radius, | |
opacity, | |
transition, | |
scale, |
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
/** @jsx jsx */ | |
import React from "react"; | |
import { jsx, css } from "@emotion/core"; | |
export const GamingTextField: React.FC = () => { | |
return ( | |
<div | |
css={css` | |
background: linear-gradient( | |
217deg, |
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 D<T> = { | |
[P in keyof T]?: T[P] extends Array<infer U> ? Array<D<U>> : T[P] | |
} | |
type W<V> = { | |
wrapper: V | |
} | |
type A = D<{ | |
hoge: number, |
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
func identity<A>(x: A): A { | |
x | |
} | |
enum List<A> { | |
Nil, | |
Cons(A, List<A>), | |
} | |
record User { |
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
# https://www.quora.com/What-is-a-sed-script-that-will-remove-the-n-character-but-only-if-it-is-inside-characters-delimited-string-not-the-n-that-is-actually-at-the-end-of-the-virtual-line | |
$ mlr --csv --rs lf --implicit-csv-header --headerless-csv-output --quote-all put ' | |
for (col_no in $*) { | |
$[col_no]=gsub($[col_no], "\n", " \\\\n ") | |
} | |
' my.csv > sanitized.csv |
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
{-# LANGUAGE BangPatterns #-} | |
import Gauge.Main | |
import Control.Monad | |
import Control.Monad.State.Strict | |
import qualified Data.Vector.Unboxed.Mutable as V | |
import Data.ByteString.Internal (accursedUnutterablePerformIO) | |
{- | |
benchmarked accursed | |
time 5.238 μs (5.168 μs .. 5.339 μs) |
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
{-# LANGUAGE BangPatterns #-} | |
import Gauge.Main | |
import Control.Monad | |
import Control.Monad.State.Strict | |
import qualified Data.Vector.Unboxed.Mutable as V | |
import Data.ByteString.Internal (accursedUnutterablePerformIO) | |
{- | |
benchmarked accursed | |
time 136.3 μs (135.7 μs .. 137.0 μs) |
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 Gauge.Main | |
import Control.Monad | |
import Control.Monad.State.Strict | |
import Data.IORef | |
import qualified Data.Vector.Unboxed.Mutable as V | |
import Data.Primitive.MutVar | |
{- | |
benchmarked IORef | |
time 3.196 μs (3.170 μs .. 3.226 μs) |
NewerOlder