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 hexRgb from "hex-rgb"; | |
// see: https://www.w3.org/TR/WCAG20/#relativeluminancedef | |
export function isDarkColor(hexColor: string): boolean { | |
const { red, green, blue } = hexRgb(hexColor); | |
const [r, g, b] = [red / 255, green / 255, blue / 255].map((v) => | |
v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) | |
); |
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 main | |
import "fmt" | |
type Base interface { | |
getID() int64 | |
} | |
type Person struct { | |
ID int64 |
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
function parseJwt (token) { | |
const base64Url = token.split('.')[1]; | |
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); | |
const jsonPayload = decodeURIComponent(atob(base64).split('').map((c) => { | |
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); | |
}).join('')); | |
return JSON.parse(jsonPayload); | |
}; | |
function isValidToken(token) { |
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, { useCallback, useEffect, useState } from "react"; | |
import axios, { AxiosRequestConfig } from "axios"; | |
class FetchError extends Error { | |
constructor({ name, message }: { name: string, message: string }) { | |
super(message); | |
this.name = name; | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="initial-scale=1.0, width=device-width, shrink-to-fit=no" /> | |
<style> | |
body { | |
display: grid; | |
grid-template-columns: [menu] 25% [content] auto [end]; |
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 main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
type response1 struct { | |
Page int `json:"page"` | |
Fruits []string `json:"fruits"` |
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
version: '2' | |
services: | |
elasticsearch: | |
image: docker.elastic.co/elasticsearch/elasticsearch:6.6.0 | |
ports: | |
- "9200:9200" | |
- "9300:9300" | |
kibana: | |
image: docker.elastic.co/kibana/kibana:6.6.0 | |
ports: |
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
(async () => { | |
try { | |
await createConnection(); | |
console.log("connected!"); | |
} catch (e) { | |
console.error(e); | |
} | |
})(); |
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 io = require('socket.io-client'); | |
const socket = io('http://localhost:3000', { | |
transportOptions: { | |
polling: { | |
extraHeaders: { | |
'Authorization': 'Bearer abc', | |
}, | |
}, | |
}, |
NewerOlder