Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
...

Nyaundi Brian danleyb2

:octocat:
...
View GitHub Profile
@danleyb2
danleyb2 / fancy-tabs-demo.html
Created Aug 2, 2019 — forked from ebidel/fancy-tabs-demo.html
Fancy tabs web component - shadow dom v1, custom elements v1, full a11y
View fancy-tabs-demo.html
<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 Jun 11, 2019 — forked from subfuzion/curl.md
curl POST examples
View curl.md

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 Apr 24, 2019 — forked from cowboy/mixin.js
JavaScript ES6 - mixins with super
View mixin.js
// 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 Dec 21, 2018 — forked from backpackerhh/subdomain_validator.rb
Subdomains validation, inspired by Matthew Hutchinson.
View subdomain_validator.rb
# 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 Dec 19, 2018 — forked from soarez/ca.md
How to setup your own CA with OpenSSL
View ca.md

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.

@danleyb2
danleyb2 / bitbucket-webhook.php
Created Sep 13, 2018 — forked from maztch/bitbucket-webhook.php
A simple php script for deploy using bitbucket webhook
View bitbucket-webhook.php
<?php
//edit with your data
$repo_dir = '~/repository.git';
$web_root_dir = '~/project';
$post_script = '~/project/scripts/post_deploy.sh';
$onbranch = 'master';
// A simple php script for deploy using bitbucket webhook
// Remember to use the correct user:group permisions and ssh keys for apache user!!
// Dirs used here must exists on server and have owner permisions to www-data
@danleyb2
danleyb2 / gist:00a3e099fc9292ffe617e6ee7bba78c7
Created Sep 11, 2018 — forked from SimonSun1988/gist:2ef7db45e46b889783647d941ec15e4d
解決 Ubuntu "can’t set the locale; make sure $LC_* and $LANG are correct" 的錯誤
View gist:00a3e099fc9292ffe617e6ee7bba78c7
## 安裝語系檔
`$ sudo locale-gen "en_US.UTF-8"`
## 重新設定語系檔
`$ sudo dpkg-reconfigure locales`
## 設定檔
@danleyb2
danleyb2 / settings_local.py
Created Feb 10, 2018
Danleyb2 Django Local Settings
View settings_local.py
import os
# Helper settings for prj.settings
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
INSTANCE = '/tmp/mapping_app_instance/'
MEDIA_UPLOAD_ROOT = os.path.join(INSTANCE,'media')
View dagger2-demo-DbHelper.java
@Singleton
public class DbHelper extends SQLiteOpenHelper {
//USER TABLE
public static final String USER_TABLE_NAME = "users";
public static final String USER_COLUMN_USER_ID = "id";
public static final String USER_COLUMN_USER_NAME = "usr_name";
public static final String USER_COLUMN_USER_ADDRESS = "usr_add";
public static final String USER_COLUMN_USER_CREATED_AT = "created_at";
public static final String USER_COLUMN_USER_UPDATED_AT = "updated_at";
@danleyb2
danleyb2 / cirm.py
Created Aug 15, 2017
Plot a given number of equally spaced circumferance cordinates on a x,y center with given radius
View cirm.py
import math
from math import pi
def points_on_circumference(center=(0, 0), r=50, n=100):
return [
(
center[0]+(math.cos(2 * pi / n * x) * r), # x
center[1] + (math.sin(2 * pi / n * x) * r) # y