A collection of articles and tools I've found really helpful, organized by subject.
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 Props = { | |
color: string; | |
}; | |
export default function CrescentSpinner({ | |
color = "gray", | |
}: Props) { | |
return ( | |
<div aria-label="Loading..." role="status"> | |
<svg className="h-6 w-6 animate-spin" viewBox="3 3 18 18"> |
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 type { Game, Move } from "boardgame.io"; | |
import { INVALID_MOVE } from "boardgame.io/core"; | |
export interface TicTacToeState { | |
cells: (null | string)[]; | |
} | |
function isVictory(cells: (null | string)[]): boolean { | |
const positions = [ | |
// Horizontal |
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
from django.contrib.auth import login as django_login, logout as django_logout | |
from rest_framework.request import Request | |
from rest_framework.response import Response | |
from rest_framework.decorators import ( | |
api_view, | |
authentication_classes, | |
permission_classes, | |
) | |
from rest_framework.authentication import SessionAuthentication | |
from rest_framework.permissions import IsAuthenticated |
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
from rest_framework.authentication import BasicAuthentication | |
class CustomBasicAuthentication(BasicAuthentication): | |
def authenticate_header(self, request): | |
# Important see https://stackoverflow.com/questions/9859627/how-to-prevent-browser-to-invoke-basic-auth-popup-and-handle-401-error-using-jqu?lq=1 | |
return None |
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
Your requirements could not be resolved to an installable set of packages. | |
Problem 1 | |
- Conclusion: don't install magento/magento-cloud-docker 1.1.1 | |
- Conclusion: remove symfony/console v4.4.11 | |
- Conclusion: don't install symfony/console v4.4.11 | |
- symfony/dependency-injection v3.3.0 conflicts with symfony/console[v4.4.11]. | |
- symfony/dependency-injection v3.3.1 conflicts with symfony/console[v4.4.11]. | |
- symfony/dependency-injection v3.3.10 conflicts with symfony/console[v4.4.11]. | |
- symfony/dependency-injection v3.3.11 conflicts with symfony/console[v4.4.11]. |
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 { useState, useEffect } from "react"; | |
import { AsyncStorage } from "react-native"; | |
function useAsyncStorage(key, initialValue) { | |
const [storedValue, setStoredValue] = useState(initialValue); | |
useEffect(() => { | |
AsyncStorage.getItem(key) | |
.then(value => { | |
if (value === null) return initialValue; |
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 fileinput | |
for line in fileinput.input(): | |
print(line) | |
""" | |
Usages | |
- Read from stdin: cat somefile | python script.py | |
- read from multiple files: python script.py file1.txt file2.txt file3.txt |
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 re | |
from collections import Counter | |
def guess_string_separator( | |
string: str, | |
to_ignore: Iterable[str] = tuple(), | |
ignore_empty_strings: bool = True, | |
) -> Optional[str]: | |
"""Guess a delimiter being used to split a string using term frequencies. |
NewerOlder