Skip to content

Instantly share code, notes, and snippets.

@chrisbay
chrisbay / caesar.py
Created May 15, 2017 13:05
For Web Caesar assignment
def alphabet_position(character):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
lower = character.lower()
return alphabet.index(lower)
def rotate_string_13(text):
rotated = ''
alphabet = 'abcdefghijklmnopqrstuvwxyz'
@chrisbay
chrisbay / format.py
Created May 22, 2017 11:24
Examples of using string.format to create HTML snippets
# Using indexed placeholders
markup = """
<!doctype html>
<html>
<head>
<title>{0}</title>
</head>
<body>
<h1>{0}</h1>
@chrisbay
chrisbay / form-inputs.html
Created May 23, 2017 12:18
Code from the LaunchCode Unit 2 lesson on form inputs
<!doctype html>
<html>
<body>
<style>
br {margin-bottom: 20px;}
</style>
<form method='POST'>
@chrisbay
chrisbay / form-inputs.py
Created May 23, 2017 14:27
Flask handlers to display and process various form inputs
from flask import Flask, request
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route("/form-inputs")
def display_form_inputs():
return """
<style>
@chrisbay
chrisbay / grade.py
Created June 5, 2017 19:32
Grading script for part 1 of HTML Me Something
import requests
import sys
from html.entities import html5 as html5Entities
from html.parser import HTMLParser
from py_w3c.validators.html.validator import HTMLValidator
class bcolors:
HEADER = '\033[95m'
@chrisbay
chrisbay / print_bot_id.py
Created June 21, 2017 13:11
Find a Slackbot's ID after connecting with its token
import os
from slackclient import SlackClient
BOT_NAME = 'bot_name_without_at_sign'
slack_client = SlackClient('BOT_TOKEN_GOES_HERE')
if __name__ == "__main__":
api_call = slack_client.api_call("users.list")
@chrisbay
chrisbay / application-h2.properties
Created January 9, 2018 14:07
Spring Boot config for H2 in-memory database
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:test
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update
POSTGRES_USER=zika_app_user
POSTGRES_PASS=somethingsensible
POSTGRES_DBNAME=zika
ALLOW_IP_RANGE=<0.0.0.0/0>
@chrisbay
chrisbay / osm-basemap.json
Created March 14, 2018 16:08
Open Street Maps Config for stl-parks
{
"version": 8,
"name": "OSM Bright",
"metadata": {
"mapbox:type": "template",
"mapbox:groups": {
"1444849364238.8171": {
"collapsed": true,
"name": "Buildings"
},
@chrisbay
chrisbay / load_data.sh
Last active May 9, 2018 13:13
Load some data into a local Elasticsearch instance
curl -XPOST 'localhost:9200/twitter/tweets/1' -H 'Content-type:application/json' -d '
{
"date" : "2014-09-13",
"name" : "Mary Jones",
"tweet" : "Relational databases are so yesterday",
"user_id" : 2,
"likes": 1
}
'