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
class AcmeSocialAccountAdapter(DefaultSocialAccountAdapter): | |
# ...or save_user | |
def populate_user(self, request: Request, sociallogin: SocialLogin, data: dict) -> Any: | |
user = super().populate_user(request, sociallogin, data) | |
roles = sociallogin.account.extra_data.get("roles", []) | |
# Do something with extra attributes incoming from the SAML authentication response | |
user.roles = map_to_your_app_roles(roles) | |
return 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
const animals = ['wolf', 'goat', 'cabbage'] | |
boat.init(animals) | |
boat.load(animals[0]) | |
boat.moveToNext() | |
boat.moveToNext() | |
//The next step is to load the cabbage | |
boat.load(animals[2]) | |
// Crash! |
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
//react-native-fs | |
const imagePath = '/somewhere/image.jpeg'; | |
const imageFile = await RNFS.stat(imagePath) | |
const response = await fetch('file://'+imagePath); | |
const imageBody = await response.blob(); | |
// Android returns true, iOS false :/ | |
console.log(imageBody.size === imageFile.size) |
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" | |
"syscall" | |
) | |
func main() { | |
a := 10 | |
// NOTE: this does not actually work in any non-trivial applications. |
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 * as pulumi from '@pulumi/pulumi' | |
import {Droplet, DropletSlug, Region} from '@pulumi/digitalocean'; | |
import * as fs from 'fs'; | |
const dropletName = 'myDroplet'; | |
const region = Region.AMS2; | |
const size = DropletSlug.DropletS1VCPU1GB; | |
const config = new pulumi.Config(); |
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
// Fast TS compile | |
<Controller | |
control={control} | |
...> | |
</Controller> | |
// Slow TS compile | |
<Controller<MyInputs, 'myField'> | |
control={control} | |
...> |
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 RootStack = (): JSX.Element => { | |
return ( | |
<Stack.Navigator initialRouteName={initialRouteName}> | |
<Stack.Screen | |
name="SomeScreenWithLazyWrapper" | |
component={ScreenWrapper} | |
options={{title: 'Screen 1'}} | |
/> | |
<Stack.Screen | |
name="SomeScreenWithGetComponent" |
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
# diff -dqry alpine distroless > diff | |
Only in alpine/bin: arch | |
Only in alpine/bin: ash | |
Only in alpine/bin: base64 | |
Only in alpine/bin: bbconfig | |
Only in alpine/bin: busybox | |
Only in alpine/bin: cat | |
Only in alpine/bin: chgrp | |
Only in alpine/bin: chmod | |
Only in alpine/bin: chown |
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 function fetchContentLength(url: string): Promise<string | null> { | |
const response = await fetch(url, {method: 'HEAD'}); | |
return response.headers.get('content-length'); | |
} |
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
{ | |
"change": [ | |
{ | |
"kind": "update", | |
"schema": "public", | |
"table": "users", | |
"columnnames": ["id", "name"], | |
"columntypes": ["bigint", "text"], | |
"columnvalues": [14, "emily"], | |
"oldkeys": { |
NewerOlder