Skip to content

Instantly share code, notes, and snippets.

View frikky's full-sized avatar
:shipit:
Shuffling

Frikky frikky

:shipit:
Shuffling
View GitHub Profile
@frikky
frikky / rollback.go
Last active November 20, 2019 09:36
To roll back a user (simple structure, could be way more complex)
// Handles the rollback to a previous document
func handleRollbackUser(ctx context.Context, e FirestoreEvent) error {
// This can be grabbed from split of e.OldValue.Name
clientDoc := client.Collection("users").Doc(strings.Split(e.OldValue.Name, "/")[6])
// Again, you have to
type NewUser struct {
Username string `json:"userId"`
Email string `json:"email"`
DateEdited int64 `json:"date_edited"`
@frikky
frikky / new_user_rollback.go
Created November 20, 2019 09:39
As you can see, this is way less code than rollback.go
import "github.com/frikky/firestore-rollback-go"
// This is our self-defined fields.
// FirestoreEvent.Value.Fields = User
type User struct {
Username rollback.StringValue `json:"userId"`
Email rollback.StringValue `json:"email"`
DateEdited rollback.IntegerValue `json:"date_edited"`
}
@frikky
frikky / webpack.config.js
Created March 18, 2020 04:34
Basic webpack configuration
# Minimal webpack.config.js
module.exports = {
mode: "production",
entry: {
"app": "./src/index.js",
},
module: {
rules: [
{
test: /\.css$/,
@frikky
frikky / .babelrc
Created March 18, 2020 04:36
Babel configuration for react
{
"presets":[
"@babel/preset-react",
"@babel/preset-env",
"@babel/preset-flow"
]
}
@frikky
frikky / .babelrc
Created March 18, 2020 04:36
Babel configuration for react
{
"presets":[
"@babel/preset-react",
"@babel/preset-env",
"@babel/preset-flow"
]
}
@frikky
frikky / webhook.go
Last active March 29, 2020 17:37
Used to handle the backend of the https://niceable.co chatbot
package function
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
@frikky
frikky / delete_badkeys.py
Last active October 7, 2025 21:45
Deletion of autogenerated keys in shuffle's datastore
import requests
import json
# OpenSearch endpoint
host = "https://localhost:9200"
index = "org_cache"
username = "admin" # replace with your username
password = "admin" # replace with your password
auth = (username, password) # all requests will use this