Skip to content

Instantly share code, notes, and snippets.

View seanwiseman's full-sized avatar
🚀
💻 from 🏡

Sean Wiseman seanwiseman

🚀
💻 from 🏡
View GitHub Profile
/*
We need a function called `calculateTotal` that will accept an array of numbers, then add them all up and return the total.
`hint` - maybe take a look at https://www.w3schools.com/js/js_loop_forin.asp .
Here are some examples that sound work:
Example 1:
/*
Username check (part 1):
We need a function called `doesUserExist` that will accept a user's username (string) and return a boolean value stating
if the user already exists for our check.
`hint` - maybe take a look at https://www.w3schools.com/jsref/jsref_includes_array.asp .
For now use these usernames to check against:
/*
Age check:
We need a function called `isOldEnough` that will accept a user's age (integer) and return a boolean value stating
if the user is old enough for our check.
For now the minimum age limit should be 18.
Here are some examples that sound work:
def extract_key_value_pairs(input_str, keys):
"""
# Example:
result = extract_key_value_pairs(
input_str="Postcode: NG11 Radius: 5 Price range: 450000-500000 Number of bedrooms: 2",
keys=["Postcode", "Radius", "Price range", "Number of bedrooms"]
)
@seanwiseman
seanwiseman / gist:384621186c99930e2ab2878c9e5c2858
Created April 21, 2020 19:37
React Native with Redux + persist + redux-react-hook
import { AppLoading } from 'expo';
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import React, { useEffect, useState } from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { ThemeProvider } from 'react-native-elements';
import { LocalizeProvider, withLocalize } from "react-localize-redux";
import { Ionicons } from '@expo/vector-icons';
import AppNavigator from './navigation/AppNavigator';
import { createLogger } from "redux-logger";

Keybase proof

I hereby claim:

  • I am seanwiseman on github.
  • I am seanwiseman (https://keybase.io/seanwiseman) on keybase.
  • I have a public key ASDC-E67pXjsw7A9tJqiQRe_bFVxOeR3-7y8cAL8QhWG7wo

To claim this, I am signing this object:

@seanwiseman
seanwiseman / 0066-payload.xml
Created June 1, 2018 14:34
Example article payload
<root>
<content-list>
<list-item>
<language>en</language>
<name>front</name>
<model>href="http://localhost:8081/schemas/elife/article/front.rng"</model>
<content>
<front xmlns="http://libero.pub" xmlns:elife="http://elifesciences.org"
xmlns:mml="http://www.w3.org/1998/Math/MathML" xml:lang="en">
@seanwiseman
seanwiseman / ip_from_request.py
Created January 17, 2018 15:36
Some options to get an ip from a successful request and error. Though the error is a fall back as there is no guarantee it will resolve to the same ip.
import requests
from requests.exceptions import ConnectionError
import socket
import sys
def get_host_ip(target):
try:
return socket.gethostbyname(target)
except socket.gaierror:
@seanwiseman
seanwiseman / import_users.py
Created January 11, 2018 11:03
Small script to import user data for ingestion
import json
import subprocess
base_cmds = ['python', 'manage.py', 'create-profile']
import_file = 'import_users.json'
def import_users():
print('*Starting User Import*')