Skip to content

Instantly share code, notes, and snippets.

View SpiffGreen's full-sized avatar
:octocat:
Available

Spiff Jekey-Green SpiffGreen

:octocat:
Available
View GitHub Profile
@nicostombros
nicostombros / data-table.tsx
Last active July 17, 2025 22:01
Shadcn UI implementation of DataTable and Pagination components working together
// same as your regular shadcn datatable implementation (which uses tanstack table)
// note that the shadcn datatable uses shadcn table for the ui. see https://ui.shadcn.com/docs/components/data-table
import {
ColumnFiltersState,
SortingState,
VisibilityState,
flexRender,
getCoreRowModel,
getFilteredRowModel,
@SpiffGreen
SpiffGreen / bubble_sort.py
Last active December 15, 2022 06:20
Data Structures & Algorithms - implemented in python
# Bubble sort
def swap(arr, idx1, idx2):
temp = arr[idx1]
arr[idx1] = arr[idx2]
arr[idx2] = temp
def bubbleSort(arr):
for i in range(0, len(arr)):
swapped = False
@balazsorban44
balazsorban44 / apple-gen-secret.mjs
Last active August 14, 2025 21:08
Script to generate Apple Client secret
// This is now built into `npx auth add apple`! :tada:
// https://github.com/nextauthjs/cli/pull/10
#!/bin/node
import { SignJWT } from "jose"
import { createPrivateKey } from "crypto"
if (process.argv.includes("--help") || process.argv.includes("-h")) {
@SpiffGreen
SpiffGreen / app.js
Created July 25, 2021 00:41
A simple rule-based chatbot developed with javascript
const bot = require("./training");
console.log("Hello I'm Bujo. Let's Talk :)");
bot.converse();
@SpiffGreen
SpiffGreen / mysqltest.php
Created July 7, 2021 20:02
A simple CRUD API test with mysql implemented in php
<?php
header("Content-Type:application/json");
$dbhost = "DB_HOST";
$dbuser = "DB_USER";
$dbpass = "PASSWORD";
$db = "TABLE";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $db);
@pepasflo
pepasflo / lexer.js
Last active July 30, 2023 09:03
A regex-based javascript lexer / scanner / tokenizer
#!/usr/bin/env node
var assert = require('assert');
// Each lexed token is a array of three integers:
// 1. the "token type": an index into the list of token patterns.
// 2. the index into the input string marking the start of this token.
// 3. the length of the token.
// The list of "token types" which our lexer understands:
@rindPHI
rindPHI / LLVMParser.g4
Created August 24, 2018 12:42
ANTLR4 parser for LLVM IR (human readable ASM representation), parser part (lexer is separate)
// This ANTLR4 parser grammar is based on the parser part of an LLVM BNF grammar from
// https://gist.github.com/mewmew/a2487392d5519ef49658fd8f84d9eed5,
// which in turn has been based on the source code of the official LLVM project,
// as of 2018-02-19 (rev db070bbdacd303ae7da129f59beaf35024d94c53).
// * lib/AsmParser/LLParser.cpp
// === [ Module ] ==============================================================
// https://llvm.org/docs/LangRef.html#module-structure
@Mardiniii
Mardiniii / tcp_server.go
Created April 16, 2018 15:51
TCP server with HTTP protocol using Golang
package main
import (
"fmt"
"net"
"os"
)
const (
CONN_HOST = "localhost"
@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active February 17, 2025 18:17
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

@jwo
jwo / index.js
Created October 26, 2017 20:24
Simple way to sign in with github for oAuth in Node/Express
const express = require("express")
const app = express()
var passport = require("passport")
var session = require("express-session")
var GitHubStrategy = require("passport-github2").Strategy
const GITHUB_CLIENT_ID = "your-client-id-here" // or get from process.env.GITHUB_CLIENT_ID
const GITHUB_CLIENT_SECRET = "your-client-secret-here" // or get from process.env.GITHUB_CLIENT_SECRET
const GITHUB_CALLBACK_URL = "http://localhost:5000/auth/github/callback" // or get from process.env.GITHUB_CALLBACK_URL