Skip to content

Instantly share code, notes, and snippets.

View danleyb2's full-sized avatar
:octocat:
...

Nyaundi Brian danleyb2

:octocat:
...
View GitHub Profile
@danleyb2
danleyb2 / semantic-commit-messages.md
Created September 7, 2022 20:33 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@danleyb2
danleyb2 / unixhttpc.go
Created November 14, 2020 11:26 — forked from teknoraver/unixhttpc.go
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@danleyb2
danleyb2 / debugger pause beforeunload
Created May 30, 2020 10:03 — forked from carcinocron/debugger pause beforeunload
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@danleyb2
danleyb2 / bot_example.py
Created May 2, 2020 12:34 — forked from EvieePy/bot_example.py
A Cogs Example for the rewrite version of - discord.py
import discord
from discord.ext import commands
import sys, traceback
"""This is a multi file example showcasing many features of the command extension and the use of cogs.
These are examples only and are not intended to be used as a fully functioning bot. Rather they should give you a basic
understanding and platform for creating your own bot.
These examples make use of Python 3.6.2 and the rewrite version on the lib.
@danleyb2
danleyb2 / custom.element.js
Created December 12, 2019 17:23 — forked from argyleink/custom.element.js
custom element with shadow dom
export default class CustomElement extends HTMLElement {
constructor() {
super()
this.$shadow = this.attachShadow()
this.$shadow.innerHTML = this.render()
}
connectedCallback() {}
disconnectedCallback() {}
@danleyb2
danleyb2 / monitor.sh
Created October 1, 2019 09:15 — forked from indatawetrust/monitor.sh
redis-cli monitor grep
redis-cli monitor | grep -E ' "set" '
@danleyb2
danleyb2 / fancy-tabs-demo.html
Created August 2, 2019 09:39 — forked from ebidel/fancy-tabs-demo.html
Fancy tabs web component - shadow dom v1, custom elements v1, full a11y
<script>
function execPolyfill() {
(function(){
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1.
/*
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
@danleyb2
danleyb2 / curl.md
Created June 11, 2019 07:08 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@danleyb2
danleyb2 / mixin.js
Created April 24, 2019 10:12 — forked from cowboy/mixin.js
JavaScript ES6 - mixins with super
// This mixin might be used to extend a class with or without its
// own "foo" method
const mixin = Base => class extends Base {
foo() {
// Only call super.foo() if it exists!
if (super.foo) {
super.foo();
}
console.log('mixin');
@danleyb2
danleyb2 / subdomain_validator.rb
Created December 21, 2018 10:36 — forked from backpackerhh/subdomain_validator.rb
Subdomains validation, inspired by Matthew Hutchinson.
# Each subdivision can go down to 127 levels deep, and each DNS label can contain up to 63 characters,
# as long as the whole domain name does not exceed a total length of 255 characters.
class SubdomainValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
return unless value
reserved_names = %w[admin beta blog ftp imap mail pop pop3 sftp smtp ssl www]
reserved_names += options[:reserved] if options[:reserved]
object.errors[attribute] << 'cannot be a reserved name' if reserved_names.include?(value.downcase)