Skip to content

Instantly share code, notes, and snippets.

View Steven24K's full-sized avatar
🤹‍♂️
Enjoying life

Steven Steven24K

🤹‍♂️
Enjoying life
View GitHub Profile
@Steven24K
Steven24K / robots.txt
Created March 12, 2024 08:03
robots.txt
User-agent: *
Disallow: /
User-agent: ia_archiver
Disallow: /
User-agent: Googlebot
Disallow: /
User-agent: Facebot
function getUrlParam(key: string): string {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(key) ?? "";
}
function addUrlParam(key: string, value: string): void {
const url = new URL(window.location.href);
url.searchParams.set(key, value);
const newUrl = url.href;
window.history.pushState({ path: newUrl }, "", newUrl);
@Steven24K
Steven24K / docker-compose.yml
Created July 7, 2022 08:16
A simple minimal Dockerized Wordpres solution.
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
@Steven24K
Steven24K / get-geo-locations.py
Last active May 17, 2022 13:33
A small Python script to scrape this API https://nominatim.openstreetmap.org/search?format=json&q= to get the GEO coordinates based on adress.
# from functools import reduce
import json
import requests
import csv
csv_name = input("Where would you like to store the result? (filename)")
f = open("output/" + csv_name + ".csv" ,'x')
error_log = open("output/" + "error_" + csv_name + ".txt", "x")
writer = csv.writer(f)
@Steven24K
Steven24K / index.php
Created January 20, 2022 08:19
A worpdress plugin for making the hubspot API publically available from the wordpress API. It supports getting a form, getting all formssubmit form with recaptcha, upload attahced files,
<?php
/*
Plugin Name: Hubspot API
Description: Plugin to make the hubspot API available from WordPress
Author: Steven K
Author URI: https://www.stevenkoerts.nl
*/
// Demo form: 233bb53d-071f-4d39-8859-f041855bbbd4, API_KEY: demo
@Steven24K
Steven24K / app.py
Created October 15, 2021 12:09
A small ready to copy Python Flask api. I use this when I need a simple proxy for my fontend app to consume.
from flask import Flask, jsonify, request
from flask_cors import CORS
import requests
# RUn the app by running flask run -p 3000 you can change the port number if have allready something running on port 3000
app = Flask(__name__)
# Allow CORS on every request
CORS(app)
@Steven24K
Steven24K / setBlockState.ts
Created September 3, 2021 11:43
A simple utility function to set the state of a custom block
const setBlockState = <K extends keyof BLOCKPROPS>(prop: K, newValue: BLOCKPROPS[K]) => (s: CMSState<customBlockData, extra_images, PublicSite_CustomPageData>): CMSState<customBlockData, extra_images, PublicSite_CustomPageData> => {
if (!s.blocks.has(props.block_index)) return s
let current_block = s.blocks.get(props.block_index) as any
if (current_block.kind != 'BLOCK_NAME') return s
current_block = ({
...current_block,
value: {
...current_block.value,
fst: {
...current_block.value.fst,
@Steven24K
Steven24K / statemachine.ts
Created June 30, 2021 12:07
A small statemachine in Typescript
interface StateMachine {
busy: boolean
update: () => void
reset: () => void
}
interface Seq extends StateMachine {
sm1: StateMachine
sm2: StateMachine
current: StateMachine,
@Steven24K
Steven24K / BarcodeScanner.tsx
Created June 24, 2021 07:46
A barcode scanner component for React using the users webcam and image procesing library @zxinf/library.
import * as React from 'react'
import { BrowserMultiFormatReader, DecodeHintType, Result, BarcodeFormat } from '@zxing/library'
import Webcam from './Webcam'
// https://github.com/dashboardphilippines/react-webcam-barcode-scanner
interface BarcodeScannerProps {
width: number
height: number
@Steven24K
Steven24K / README.md
Last active May 28, 2021 08:12
A wrapper component for Googles ReCaptcha React. This is only client side, you still need to verify the ReCaptcha server side where you receive your form data.