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 / wordpress-init-db.sql
Created April 19, 2021 12:08
A database dump to setup wordpress, site url localhost:5100, admin credentials: username: vidda, password: root
This file has been truncated, but you can view the full file.
-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: My Website
-- ------------------------------------------------------
-- Server version 5.7.33
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
@Steven24K
Steven24K / InnerHtmlWrapper.tsx
Created May 3, 2021 10:07
A little wrapper that can be used to keep track of the innerHtml inside react components.
import * as React from "react"
interface InnerHtmlWrapperProps {
text: string
className?: string
}
/**
* A component that puts the text inside a div using dangerouslySetInnerHTML to keep the html layout. Inside this component an internal ref is used to keep track of the content inside the div.
* When you are working with react you have full control over the DOM and the placement new HTML tags, manipulate attributes and event listeners. However when you deal with HTML encoded content you lose
import requests
from html.parser import HTMLParser
import os
class LinkParser(HTMLParser):
def __init__(self, *args, **kwargs):
self.title = ""
self.hasTitle = False
self.links = []
@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.
@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 / 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 / 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 / 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 / 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 / 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)