Skip to content

Instantly share code, notes, and snippets.

View collinsrj's full-sized avatar

Robert Collins collinsrj

View GitHub Profile
#Build on the previous assignment for “user authentication.” Define a User class which represents the user of an app. A user should have a username, password, and a collection of permissions. User should define methods to add and remove permissions. Create 1 user with the ‘admin’ permission.
#After authenticating as the admin user, you should be able to add new users and remove existing ones through the use of functions.
#Acceptance Criteria
# 1. Authenticate username and password against an admin account
# 2. Given that authentication is successful;
# a. allow admin to add a new user
# b. allow admin to remove an existing user
# 3. Allow these actions until “exit” is entered into the REPL
# Assignment 2
# Before granting a user access to a system, they need to enter a valid username and password combination. This is a very basic form of authentication.
# Write a program which allows a user to input a username and password. Verify that the username exists and the password entered matches the one associated with the username.
# Acceptance Criteria
# 1. If the username and password combination is incorrect, print an error message
# 2. If the username and password combination is correct, print a success message
# 3. Allow the user to enter their password up to three times before quitting the program
# Extra Credit (if we were grading)
# 1. Allow the user to create an account if it does not already exist
@collinsrj
collinsrj / main.py
Created February 17, 2021 15:10
week 2 exercise
users = [
{'username': 'dz88', 'password': 'super-secret'},
{'username': 'DogL0ver42', 'password': 'mydogsnameisfreckles'},
{'username': 'punkrock3rgir1', 'password': 'joeyramone4lyfe'}]
not_logged_in=True
attempt_count=0
while not_logged_in and attempt_count < 3:
username = input('Enter your username: ')
@collinsrj
collinsrj / Escrow.sol
Created September 18, 2019 13:27
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.26+commit.4563c3fc.js&optimize=false&gist=
pragma solidity >=0.4.1 <0.6.0;
contract Escrow {
uint balance;
address public buyer;
address public seller;
address private escrow;
uint private start;
bool buyerOk;
bool sellerOk;

I work for IBM, on a very large, mature enterprise product. My role is technical architect, I was tasked with building a new application for consumers. By consumers, I mean systems real people interact with, not those employees of a business paid to use it. This wasn't something which had been done before for the product.

We faced two big challenges. We had to deliver an application which would work well across all platforms and my team were a a set of native iOS developers. The second was I strongly believed that the existing framework for web UI development would not deliver the great experiences required by our customer.

Addressing the team issue was not a big hurdle. We had already been looking at web applications to expand our reach. It didn't take too much convincing. The team were used to change, we'd been working in the Swift programming language following the latest builds and language changes.

The enterprise product had a long established way of building user interfaces. For end users, it resul

@collinsrj
collinsrj / FlattenIntArray.js
Created May 10, 2017 22:38
A simple JavaScript (ES6) function to flatten a nested integer array.
/**
* Flattens an integer array. The function should handle deeply nested arrays
* without issue using an ES6 interpretter which supports Tail Call
* Optimisation.
*
* @returns {Array} a flattened Integer array
*/
const flattenIntArray = array => array
.filter(item => {
if (Number.isInteger(item) || Array.isArray(item)) {
@collinsrj
collinsrj / HttpsPlayground.swift
Created May 7, 2016 13:14
Synchronous HTTPS Request in Playground
import Foundation
func getEncoding(response: NSHTTPURLResponse) -> NSStringEncoding {
guard let encodingName = response.textEncodingName else {
return NSUTF8StringEncoding
}
let encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding(encodingName))
if encoding != UInt(kCFStringEncodingInvalidId) {
return encoding
}
# The following is an example - it may not represent best practice. Your security is your own responsibility.
# Create the fake CA key and cert.
openssl genrsa -des3 -out ca.key 2048
openssl req -new -x509 -sha256 -days 365 -key ca.key -out ca.crt
# Generate a key for the server
openssl genrsa -out server.key 2048
# for this next command, make sure you specify your domain as the Common Name e.g. example.com
openssl req -new -key server.key -out server.csr
openssl x509 -sha256 -req -in server.csr -out server.crt -CA ca.crt -CAkey ca.key -CAcreateserial -days 365
@collinsrj
collinsrj / Swift2httpsExample.swift
Last active August 29, 2015 14:25
An example in Swift 2 of connecting to an HTTPS service and parsing the resulting JSON.
let urlString = "https://example.com/names"
guard let url = NSURL(string: urlString) else {
fatalError("The URL: \(urlString) wasn't valid!")
}
let request = NSMutableURLRequest(URL: url)
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) -> Void in
do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableLeaves)
@collinsrj
collinsrj / server.js
Created July 22, 2015 05:10
TLS 1.2 Node.js Server
// A super simple HTTPS service which allows you to GET a collection of names from https://<hostname>/names
var express = require('express');
var https = require('https');
var app = express();
var fs = require('fs');
app.get('/names', function (req, res) {
res.json(["Simon", "Bob"])
});