Skip to content

Instantly share code, notes, and snippets.

@chrisbay
chrisbay / gist:3eef7aca409adbd0722552565899f19c
Created September 18, 2016 21:28
Bash commands for .bash_profile/.bash_rc to prepend prompt with random emoji
# generate random emoji for prompt
EMOJIS=(🌱 🌲 🌳 🌴 🌵 🌿 🍀 🍁 🍂 🍃 🍇 🍈 🍉 🍊 🍋 🍌 🍍 🍎 🍏 🍐 🍑 🍒 🍓 🍅 🌽 🌶 🍄 🧀 🌮 🌯 🍩 🍪 🍰 🍫 🍬 🍭 🍮 🍷 🍸 🍹 🍺)
IDX=$(jot -r 1 0 ${#EMOJIS[@]})
EMOJI=${EMOJIS[IDX]}
export PS1="$EMOJI \[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\W\[\033[m\]\$ "
@chrisbay
chrisbay / gist:c8510b141fece941967c80abc6a3a208
Last active November 3, 2016 23:13
Print all beans found or provided by Spring Boot
@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(MyApplication.class, args);
        System.out.println("Beans provided or found by Spring Boot:");
        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
 for (String beanName : beanNames) {
@chrisbay
chrisbay / application.properties
Created November 7, 2016 14:16
application.properties for Spring Blogz assignment
# Disable Thymeleaf caching for hot-swapping of templates
spring.thymeleaf.cache = false
# Database connection settings
spring.datasource.url=jdbc:mysql://localhost:3306/blogz
spring.datasource.username=blogz
spring.datasource.password=launchcode
# Specify the DBMS
spring.jpa.database = MYSQL
@chrisbay
chrisbay / application.properties
Created November 8, 2016 00:26
application.properties for hello, spring app
# enable hot swapping
spring.thymeleaf.cache = false
# Database connection settings
spring.datasource.url=jdbc:mysql://localhost:3306/hello
spring.datasource.username=hello
spring.datasource.password=launchcode
# Specify the DBMS
spring.jpa.database = MYSQL
@chrisbay
chrisbay / pom.xml
Created November 8, 2016 00:27
pom.xml for hello, spring application
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.launchcode</groupId>
<artifactId>hello-spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
@chrisbay
chrisbay / .project
Created November 11, 2016 20:50
.project for spring-blogz
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>blogz-spring</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@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>
@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 / quine.py
Last active May 13, 2017 14:08
A (cheating) quine in Python
with open(__file__) as f:
print(f.read())
@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;