Skip to content

Instantly share code, notes, and snippets.

View jsuwo's full-sized avatar

Jeff Shantz jsuwo

View GitHub Profile
@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 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
package ca.uwo.csd.cs2212.USERNAME;
public class BankAccount {
private double balance;
public BankAccount(double balance) {
this.balance = balance;
}
@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
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 / 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">
# This script can be run using any of the following:
#
# ruby XmlParsingExampleExplained < file1.xml
# cat file1.xml | ruby XmlParsingExampleExplained
# ruby XmlParsingExampleExplained file1.xml
#
# Note that multiple XML files should NOT be specified at the same time, as was possible in the regex matching example.
# Require the Nokogiri library -- this library must be installed with 'gem install nokogiri'
require 'nokogiri'
@jsuwo
jsuwo / XmlParsingExample.md
Last active December 27, 2015 00:39
Output of the XML parsing example
$ cat test.xml | ruby -r nokogiri -e "puts Nokogiri::XML(ARGF.read).xpath('//article-title').map { |t| t.content.gsub(/\s+/, ' ') }" | wc -l

      78
      
$ cat test.xml | ruby -r nokogiri -e "puts Nokogiri::XML(ARGF.read).xpath('//article-title').map { |t| t.content.gsub(/\s+/, ' ') }"

Chemical Approaches To Perturb, Profile, and Perceive Glycans
On the frequency of protein glycosylation, as deduced from analysis of the SWISS-PROT database
Annotation of glycoproteins in the SWISS-PROT database
# This script can be run using any of the following:
#
# ruby RegexMatchingExampleExplained.rb < file1.xml
# cat file1.xml file2.xml file3.xml | ruby RegexMatchingExampleExplained.rb
# ruby RegexMatchingExampleExplained.rb file1.xml file2.xml file3.xml
#
# Read everything from standard input or from files specified as command line arguments
content = ARGF.read
@jsuwo
jsuwo / RegexMatchingExample.md
Last active December 27, 2015 00:39
Output of the regular expression matching example
$ cat test.xml | ruby -e "puts ARGF.read.scan(/<article-title>(.*?)<\/article-title>/m).flatten.map { |title| title.gsub(/\s+/, ' ') }" | wc -l 

      78

$ cat test.xml | ruby -e "puts ARGF.read.scan(/<article-title>(.*?)<\/article-title>/m).flatten.map { |title| title.gsub(/\s+/, ' ') }"

Chemical Approaches To Perturb, Profile, and Perceive Glycans
On the frequency of protein glycosylation, as deduced from analysis of the SWISS-PROT database
Annotation of glycoproteins in the SWISS-PROT database