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 / 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 / .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 / 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 / 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 / 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 / user.go
Created November 20, 2019 05:35
A Firestore user edit that should roll back your data
package user
import (
"context"
"errors"
"log"
"time"
"cloud.google.com/go/firestore"
)
@frikky
frikky / netcraft_screenshot.py
Created July 11, 2019 09:16
Taking a screenshot in Netcraft using your own credentials
import requests
def screenshot(username, password, takedownurl, proxies):
if not isinstance(proxies, list) or len(proxies) == 0:
print("Proxies should be a list of countrynames e.g. [us,en]")
return ""
if len(username) == 0 or len(password) == 0:
print("Username and password has to be defined")
return ""
@frikky
frikky / runcontainer.go
Created June 18, 2019 09:20
Run a custom Docker container with port 8080 and environment variables
package main
import (
"log"
"context"
"fmt"
"github.com/docker/docker/client"
natting "github.com/docker/go-connections/nat"
"github.com/docker/docker/api/types/container"
@frikky
frikky / removecontainer.go
Created June 18, 2019 08:57
Stop and remove a docker container with Golang
package main
import (
"log"
"fmt"
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)