Skip to content

Instantly share code, notes, and snippets.

View kayode-adechinan's full-sized avatar

Kayode Adechinan kayode-adechinan

  • Dakar, Senegal
View GitHub Profile
@kayode-adechinan
kayode-adechinan / condaenv.txt
Created February 3, 2018 23:53 — forked from pratos/condaenv.txt
To package a conda environment (Requirement.txt and virtual environment)
# For Windows users# Note: <> denotes changes to be made
#Create a conda environment
conda create --name <environment-name> python=<version:2.7/3.5>
#To create a requirements.txt file:
conda list #Gives you list of packages used for the environment
conda list -e > requirements.txt #Save all the info about packages to your folder
@kayode-adechinan
kayode-adechinan / rest-server.py
Created February 4, 2018 01:00 — forked from miguelgrinberg/rest-server.py
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@kayode-adechinan
kayode-adechinan / README-Template.md
Created February 24, 2018 23:06 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kayode-adechinan
kayode-adechinan / bobp-python.md
Created March 10, 2018 21:43 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
Perl and PHP Regular Expressions
PHP regexes are based on the PCRE (Perl-Compatible Regular Expressions), so any regexp that works for one should be compatible with the other or any other language that makes use of the PCRE format. Here are some commonly needed regular expressions for both PHP and Perl. Each regex will be in string format and will include delimiters.
All Major Credit Cards
This regular expression will validate all major credit cards: American Express (Amex), Discover, Mastercard, and Visa.
//All major credit cards regex
'/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/'
//Regular Expressions List
//Short Tutorial
\ // the escape character - used to find an instance of a metacharacter like a period, brackets, etc.
. // match any character except newline
x // match any instance of x
^x // match any character except x
[x] // match any instance of x in the bracketed range - [abxyz] will match any instance of a, b, x, y, or z
| // an OR operator - [x|y] will match an instance of x or y
public void test0(){
CompletableFuture.runAsync(this::sendReport);
}
public void test1(){
CompletableFuture.supplyAsync(this::sendMsg);
}
@kayode-adechinan
kayode-adechinan / postgres-cheatsheet.md
Created September 22, 2018 00:41 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@kayode-adechinan
kayode-adechinan / Atom_export_settings.md
Created September 23, 2018 02:04 — forked from michalczukm/Atom_export_settings.md
Atom: Backup all settings

Export:

  1. Copy from ${user}/.atom:
  • config.cson
  • keymap.cson
  • snippets.cson
  • styles.less
  1. Save installed packages list apm list --installed --bare > packages.list
@kayode-adechinan
kayode-adechinan / DjangoQuerySetToJsonResponse.py
Created September 25, 2018 17:42 — forked from leemac/DjangoQuerySetToJsonResponse.py
Example of returning a Django QuerySet as a JSON response (Django 1.7)
# Get the objects from the database
rawData = Launch.objects.all()
# Create array
json_res = []
# Iterate over results and add to array
for record in rawData:
json_obj = dict(name = record.name)
json_res.append(json_obj)