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 / 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.
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 / 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
@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 / simple-paginator.ts
Created February 18, 2021 15:59
A basic paginator written in Typescript. This is usefull when the backend does not support pagination, but you still need some sort of pagination functionality.
export interface Page<T> {
items: T[]
index: number
total_pages: number
page_size: number
current_page: number
}
export const getPage = <T>(list: T[], page_index: number, page_size: number): Page<T> => {
@Steven24K
Steven24K / LinkedList.cs
Created January 4, 2021 15:43
An immuatable linked list in C#
public interface IList<T>
{
public bool isEmpty { get; set; }
public IList<T> Add(T v);
public U Reduce<U>(Func<T, U, U> f, U init);
public IList<U> Map<U>(Func<T, U> f);
}
public class Node<T> : IList<T>
{
import csv
import os
from os import listdir
from os.path import isfile, join
from glob import glob
from pathlib import Path
import shutil
import datetime
import functools
@Steven24K
Steven24K / simple-grid.css
Created May 8, 2020 13:14
Just a simple reponsive CSS grid system
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
{
"description": "The array of models of the application.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"required": [
"name",
"attributes",
"permissions"