Skip to content

Instantly share code, notes, and snippets.

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

Steven Steven24K

🤹‍♂️
Enjoying life
View GitHub Profile
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"
@Steven24K
Steven24K / ForceDirectedGraph.ts
Created March 26, 2020 14:38
A Force directed graph layouting algorithm based on Fruchterman and Reingold's principle, written in Typescript.
/**
* Force directed graph layout algorithm according to Fruchterman and Reingold's principle.
* The algorithm can be summarized as follows:
* algorithm SPRING(G:graph);
* place vertices of G in random locations;
* repeat N times
* calculate the force on each vertex;
* move the vertex c4
* draw graph on canvas, plotter or any drawing tool.
*
@Steven24K
Steven24K / boolean-logic.php
Created March 25, 2020 09:56
An experiment for comparing boolean expressions in PHP
<?php
function toString($value) {
if ($value === TRUE) return 'TRUE';
if ($value === FALSE) return 'FALSE';
if ($value === null) return 'null';
if (is_string($value)) return '"' . $value . '"';
return $value;
}