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 / 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 / footer.php
Last active March 20, 2020 10:28
Php Include Header and Footer from a root
@danleyb2
danleyb2 / fetch_csv.js
Created March 16, 2020 08:18
Fetch Csv
// const csvFile = 'latest_by_country.csv';
// fetch(csvFile).then(function(response) {
//
// return response.ok ? response.text() : Promise.reject(response.status);
//
//
// }).then(function(text) {
// console.log(text);
//
// });a
@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)
@danleyb2
danleyb2 / ca.md
Created December 19, 2018 08:30 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.