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
filteroutput () { | |
grep Total: | |
} | |
echo " min mean[+/-sd] median max" | |
ab -n 1000 -c 10 http://localhost:8080/plain 2>&1 | filteroutput | |
ab -n 1000 -c 10 http://localhost:8080/gzipped 2>&1 | filteroutput | |
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 stats = [... new Array(1000)].map(it => 0); | |
const makeStat = () => { | |
let result = 0; | |
for (let i = 0; i < 1000; i++) { | |
result += Math.random(); | |
} | |
return result | |
} | |
for (let i = 0; i < 100000; 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
import React, { useContext } from "react"; | |
const map = new Map<any, any>(); | |
export const createGlobalStore = <T>( | |
key: any, | |
generateStore: (prevStore: T | undefined) => T | |
) => { | |
const store = generateStore(map.get(key)); | |
map.set(key, store); |
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 { getSnapshot, Instance } from "mobx-state-tree"; | |
import { createContext, useEffect, useState } from "react"; | |
import { MyStore } from "./MyStore"; | |
export const useMyStore = () => { | |
const [state, setState] = useState(() => MyStore.create()); | |
useEffect(() => { | |
if ((window as any).reentrant) { | |
const newState = MyStore.create(getSnapshot(state)); |
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"; | |
const darkModeQuery = matchMedia("(prefers-color-scheme: dark)"); | |
export const useDarkMode = () => { | |
const [isDark, setDark] = useState(darkModeQuery.matches); | |
useEffect(() => { | |
const listener = () => { | |
console.log("Dark mode changed", darkModeQuery.matches); |
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
dest=src/components/atoms/icon/IconTypes.ts | |
cat > $dest <<EOF | |
export type IconTypes = | |
EOF | |
curl 'https://fonts.google.com/metadata/icons' \ | |
| tail -n +2 \ | |
| jq '.icons[].name' \ | |
| perl -e 'print " | " . join " | ", <>' \ |
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 ldap = require("ldapjs"); | |
const server = ldap.createServer(); | |
server.bind("", (req, res, next) => { | |
console.log(`Bind attempt with ${req.dn.toString()}`); | |
res.end(); | |
return next(); | |
}); |
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 formula = [31,28,31,30,31,30,31,31,30,31,30,31].map((e, m) => { | |
m++; | |
const otherMonths = [1,2,3,4,5,6,7,8,9,10,11,12].filter(e => e !== m); | |
return `${e} * (${otherMonths.map(om => `(x-${om})`).join('*')}) / (${otherMonths.map(om => `(${m}-${om})`).join('*')})` | |
}).join("\n + ") | |
// 31 * ((x-2)*(x-3)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((1-2)*(1-3)*(1-4)*(1-5)*(1-6)*(1-7)*(1-8)*(1-9)*(1-10)*(1-11)*(1-12)) | |
// + 28 * ((x-1)*(x-3)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((2-1)*(2-3)*(2-4)*(2-5)*(2-6)*(2-7)*(2-8)*(2-9)*(2-10)*(2-11)*(2-12)) | |
// + 31 * ((x-1)*(x-2)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((3-1)*(3-2)*(3-4)*(3-5)*(3-6)*(3-7)*(3-8)*(3-9)*(3-10)*(3-11)*(3-12)) | |
// + 30 * ((x-1)*(x-2)*(x-3)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(x-11)*(x-12)) / ((4-1)*(4-2)*(4-3)*(4-5)*(4-6)*(4-7)*(4-8)*(4-9)*(4-10)*(4-11)*(4-12)) |
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
''' | |
''' A simple unit testing library. | |
''' | |
''' @usage | |
''' Write a test class with the following rules. | |
''' | |
''' * A test class name must be ended with `Test` suffix. | |
''' * A Test method name must be ended with `_Test` suffix. | |
''' | |
''' You can see some examples in MonkeyTest class also included in Ariawase. |
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
# Before executing this command, you need to start an empty gitlab instance. | |
docker-compose exec gitlab /sbin/entrypoint.sh app:rake gitlab:backup:restore |
NewerOlder