Skip to content

Instantly share code, notes, and snippets.

View jsuwo's full-sized avatar

Jeff Shantz jsuwo

View GitHub Profile
@jsuwo
jsuwo / log4j2.xml
Last active August 29, 2015 13:55
Snippets from lab 2 files allowing you to copy/paste them, rather than typing them all in yourselves.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<File name="File1" fileName="target/app.log" bufferedIO="false"></File>
</Appenders>
<Loggers>
<Root level="trace" additivity="true">
@jsuwo
jsuwo / App.java
Last active August 29, 2015 13:56
Pasteable code for CS 2212 - Lab 4.
package ca.uwo.csd.cs2212.USERNAME;
import javax.swing.SwingUtilities;
public class App {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@jsuwo
jsuwo / Address.java
Last active August 29, 2015 13:56
Starter code for Lab 7.
package ca.uwo.csd.cs2212.USERNAME;
import java.lang.StringBuilder;
public class Address {
private String street;
private String city;
private String country;
@jsuwo
jsuwo / App.java
Last active August 29, 2015 13:56
Starter code for Lab 8.
package ca.uwo.csd.cs2212.USERNAME;
import javax.swing.SwingUtilities;
public class App {
public static void main(String args[]) {
SwingUtilities.invokeLater(new Runnable() {
@Override
@jsuwo
jsuwo / Customer.java
Last active August 29, 2015 13:56
Starter code for Lab 6.
package ca.uwo.csd.cs2212.USERNAME;
public class Customer {
private String firstName;
private String lastName;
private String gender;
private String planName;
private double balanceOwing;
@jsuwo
jsuwo / App.java
Last active August 29, 2015 13:56
Starter code for Lab 9.
package ca.uwo.csd.cs2212.USERNAME;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class App {
private final static String SENDER_NAME = "John Doe";
private final static String SENDER_EMAIL = "jdoe@example.com";
@jsuwo
jsuwo / new.html.erb
Created March 31, 2014 15:15
Skeleton for a quiz app
<%= form_for [@test, @attempt, @question, @response] do |f| %>
<label><%= @question.question_text %></label>
<%= f.text_area :response_text %>
<%= f.submit 'Next >' %>
<% end %>
@jsuwo
jsuwo / fig3-1.c
Last active August 29, 2015 14:06
Code samples from Computer Networks I Lab Manual, Chapter 3 - Program I/O with the Getopt and Syslog Libraries
#include <stdio.h>
#include <stdlib.h>
#define NAME_LENGTH 20
int main()
{
char name[NAME_LENGTH];
printf("Please enter your name: ");
@jsuwo
jsuwo / fig4-10.c
Last active August 29, 2015 14:07
Code samples from Computer Networks I Lab Manual, Chapter 4 - TCP Socket Programming
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
struct addrinfo* get_sockaddr(const char* hostname, const char* port)
{
@jsuwo
jsuwo / lxc-ubuntu.patch
Created July 28, 2015 20:55
Patch to update Ubuntu template in lxc-templates-1.0.7-1.el7.x86_64 to latest version (as of 2015-07-28)
--- lxc-ubuntu 2014-12-07 13:23:40.000000000 -0500
+++ lxc-ubuntu-new 2015-07-28 15:49:46.633633812 -0400
@@ -46,6 +46,41 @@
. /etc/default/lxc
fi
+# Check if given path is in a btrfs partition
+is_btrfs()
+{
+ [ -e $1 -a $(stat -f -c '%T' $1) = "btrfs" ]