Skip to content

Instantly share code, notes, and snippets.

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

Nyaundi Brian danleyb2

:octocat:
...
View GitHub Profile

Keybase proof

I hereby claim:

  • I am danleyb2 on github.
  • I am danleyb2 (https://keybase.io/danleyb2) on keybase.
  • I have a public key ASA3TCNVO1kXk46ZlvZ4tMvEflADiA7hkKiHHHEqb8JD7Ao

To claim this, I am signing this object:

@danleyb2
danleyb2 / cirm.py
Created August 15, 2017 05:20
Plot a given number of equally spaced circumferance cordinates on a x,y center with given radius
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
@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 / settings_local.py
Created February 10, 2018 10:05
Danleyb2 Django Local Settings
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')
@danleyb2
danleyb2 / gist:00a3e099fc9292ffe617e6ee7bba78c7
Created September 11, 2018 02:35 — forked from SimonSun1988/gist:2ef7db45e46b889783647d941ec15e4d
解決 Ubuntu "can’t set the locale; make sure $LC_* and $LANG are correct" 的錯誤
## 安裝語系檔
`$ sudo locale-gen "en_US.UTF-8"`
## 重新設定語系檔
`$ sudo dpkg-reconfigure locales`
## 設定檔
@danleyb2
danleyb2 / bitbucket-webhook.php
Created September 13, 2018 13:27 — forked from maztch/bitbucket-webhook.php
A simple php script for deploy using bitbucket webhook
<?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 / 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.

@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 / 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 / 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.