Skip to content

Instantly share code, notes, and snippets.

View jsuwo's full-sized avatar

Jeff Shantz jsuwo

View GitHub Profile
@jsuwo
jsuwo / 01-test.c
Created October 21, 2015 20:45
Simple syslog example
#include <syslog.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
openlog("fig3-7", LOG_PERROR | LOG_PID | LOG_NDELAY, LOG_USER);
syslog(LOG_NOTICE, "Hello Syslog!");
syslog(LOG_INFO, "Here's an informational message.");
syslog(LOG_WARNING, "Here's a warning.");
@jsuwo
jsuwo / lxc-centos.patch
Created July 28, 2015 20:55
Patch to update CentOS template in lxc-templates-1.0.7-1.el7.x86_64 to latest version (as of 2015-07-28)
--- lxc-centos 2014-12-07 13:23:40.000000000 -0500
+++ lxc-centos-new 2015-07-28 15:58:57.110168646 -0400
@@ -29,7 +29,7 @@
#Configurations
default_path=/var/lib/lxc
-# Some combinations of the tunning knobs below do not exactly make sense.
+# Some combinations of the tuning knobs below do not exactly make sense.
# but that's ok.
#
@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" ]
@jsuwo
jsuwo / Makefile
Last active November 9, 2015 04:32
Code samples from Computer Networks I Lab Manual, Chapter 6 - More Advanced Socket Programming
CC=gcc
CFLAGS=-Wall -Werror -g -c
LFLAGS=-Wall -Werror -g
all: client1 client2 client3 server1 server2 server3 endian poll
client%: client%.o udp_sockets.o udp_client.o
$(CC) $(LFLAGS) -o $@ $^
server%: server%.o udp_sockets.o udp_server.o
@jsuwo
jsuwo / Makefile
Last active November 9, 2015 04:32
Code samples from Computer Networks I Lab Manual, Chapter 5 - UDP Socket Programming
CC=gcc
CFLAGS=-Wall -Werror -std=gnu11 -g -c
LFLAGS=-Wall -Werror -g
all: fig5-3 fig5-4 fig5-5 server client
fig5-3: fig5-3.o udp_sockets.o udp_server.o
$(CC) $(LFLAGS) -o $@ $^
fig5-4: fig5-4.o udp_sockets.o udp_server.o
@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 / 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 / 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 / Gemfile
Created March 28, 2014 03:38
Rails / Ace Editor integration
gem 'jquery-ace-rails'
@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 = "[email protected]";