Skip to content

Instantly share code, notes, and snippets.

View cjshaw1976's full-sized avatar
:atom:
Always learning & developing.

Chris Shaw cjshaw1976

:atom:
Always learning & developing.
View GitHub Profile
@cjshaw1976
cjshaw1976 / gh-pages.sh
Created November 13, 2019 06:46
Create a gh-pages branch of your simple html repository
# These comands make a gh-pages branch on your local machine and push it to github, as is.
# It is designed for a simple html repository.
# Github should automatically publish the repository page
# create gh-pages branch
git checkout --orphan gh-pages
# add all files
git add .
@cjshaw1976
cjshaw1976 / passenger_wsgi.py
Last active June 5, 2020 18:39
Fix for Django on passenger_wsgi not routing POST request on A2 servers. Simply replace the automatically generated passenger_wsgi.py with this version and change the the two instances of 'projectname' to the name of the folder in which the settings.py and wsgi.py reside.
"""
Post request dont work on Djano apps on A2 hosted servers. This replacement 'passenger_wsgi.py'
has fixed the issue for me. Works with Python 3.5 with Django 1.11, 2.0, 2.1, 2.2 and Python 3.7 with Django 3.0.
"""
# Keep this empty
SCRIPT_NAME = ''
class PassengerPathInfoFix(object):
"""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
@cjshaw1976
cjshaw1976 / react_basics_01.html
Last active January 23, 2018 12:03
Started learning React. Here we create a heading, a button and a toggle button.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
"""
Take a list of numbers and make a new list of only the first and last elements of the given list
"""
____author___ = "Christopher J Shaw"
def first_last(input_list):
return [input_list[0], input_list[-1]]
print(first_last([5, 10, 15, 20, 25]))
"""
Ask the user for a number and determine whether the number is prime or not.
"""
___author___ = "Christopher J Shaw"
def check_prime(number):
for test in range(2, number):
if number % test == 0:
return False
return True
"""
Take two lists and write a program that returns a list that contains only the elements that are
common between the lists (without duplicates). Make sure your program works on two lists of different
sizes. Write this using at least one list comprehension.
"""
___author___ = "Christopher J Shaw"
import random
"""
Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right.
Keep going till the user types exit. Keep track of number of attempts
"""
___author___ = "Christopher J Shaw"
import random
number = random.randint(1, 9)
"""
Make a two-player Rock-Paper-Scissors game.
"""
___author___ = "Christopher J Shaw"
import os
def cls():
os.system('cls' if os.name=='nt' else 'clear')
'''
07.py: Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it.
'''
____author___="Christopher J Shaw"
nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
even = [num for num in nums if not num % 2]
print(even)