Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / web-caesar.html
Last active May 16, 2017 05:21
Web Caesar Form Template
<!DOCTYPE html>
<html>
<head>
<style>
form {
background-color: #eee;
padding: 20px;
margin: 0 auto;
width: 540px;
@chrisbay
chrisbay / quine.py
Last active May 13, 2017 14:08
A (cheating) quine in Python
with open(__file__) as f:
print(f.read())
@chrisbay
chrisbay / Quine.java
Last active May 13, 2017 14:08
A (cheating) quine in Java
import java.io.*;
public class Quine{
public static void main(String[] args) throws IOException {
try(BufferedReader br = new BufferedReader(new FileReader("Quine.java"))) {
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line).append(System.lineSeparator());
}
System.out.print(sb.toString());
@chrisbay
chrisbay / .classpath
Created November 11, 2016 20:54
.classpath for spring-blogz
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>