Skip to content

Instantly share code, notes, and snippets.

@kflorence
kflorence / markdown-toc-tree.sh
Last active April 26, 2024 20:30
Creates a markdown table of contents from a file tree (omitting the directory itself, "readme.md" files and "images" folders and their contents)
#!/usr/bin/env bash
# This script generates markdown from the output of the `tree` command.
# See: https://linux.die.net/man/1/tree
# See: https://gist.github.com/kflorence/7f18ad97c65337ef77d37159260a331d
set -e
# Tree is configured with:
# - `-f`: use full paths in output (relative to directory given, in this case '.').
# - `--noreport`: exclude the directories and files report as the last line of output.
@kflorence
kflorence / ircd.php
Last active September 1, 2022 21:44
An IRC daemon written in PHP
<?
#require("server-functions.php");
#Phircd v 0.1.0 - written by siron.
set_time_limit(0);
error_reporting(0);
/* reads the config file and defines commands
$cline = file("ircd.conf") or die("cannot find ircd.conf!");
$cnum_lines = count($cline);
$conf = 0;
@kflorence
kflorence / invoke-lambda.sh
Last active February 16, 2022 18:27
Invokes an AWS Lambda function and displays the logs for the invocation
#!/usr/bin/env bash
set -e -o pipefail
FILENAME=$0
FILENAME=$(basename "$FILENAME")
function usage {
echo "Invokes an AWS Lambda function and displays the logs for the invocation."
echo "usage: $FILENAME --function-name [--help] [--payload] [--wait] [<STDIN>]"
echo " --function-name the Lambda function name or ARN."

Keybase proof

I hereby claim:

  • I am kflorence on github.
  • I am kflo (https://keybase.io/kflo) on keybase.
  • I have a public key whose fingerprint is 79E4 56F4 4594 3E67 C69A AFB7 A371 9CEE B95E D236

To claim this, I am signing this object:

@kflorence
kflorence / scrollbarWidth.js
Created July 10, 2012 22:13
Calculate scroll bar width cross-browser
function getScrollBarWidth() {
var inner = document.createElement('p');
inner.style.width = "100%";
inner.style.height = "200px";
var outer = document.createElement('div');
outer.style.position = "absolute";
outer.style.top = "0px";
outer.style.left = "0px";
outer.style.visibility = "hidden";
@kflorence
kflorence / .gitconfig
Last active April 26, 2018 20:42
Useful config settings
[alias]
br = branch
ci = commit
cl = clone
co = checkout
cp = cherry-pick
df = diff
lg = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
mg = merge --no-ff
pl = pull --rebase
@kflorence
kflorence / cart-mysql.sql
Last active October 26, 2017 17:54
sample mysql interview questions
drop table if exists customer;
create table customer(
id int auto_increment primary key,
first_name varchar(96) not null,
last_name varchar(96) not null,
address_id int not null
);
insert into customer (first_name, last_name, address_id) values ('john', 'doe', 1);
insert into customer (first_name, last_name, address_id) values ('jane', 'doe', 2);
@kflorence
kflorence / Conversions.scala
Created December 30, 2015 01:13
spring conversion helpers for scala
package com.solarmosaic.core.service.converter
import javax.inject.Inject
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.core.convert.{TypeDescriptor, ConversionService}
import scala.reflect._
/**
/*!
* jQuery Floating Scrollbar - v0.5 - 09/05/2013
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($, window){
@kflorence
kflorence / .jshintrc
Created August 22, 2013 21:37
Wikia .jshintrc
{
// Wikia .jshintrc
// Enforcing
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,