Skip to content

Instantly share code, notes, and snippets.

@jgautsch
jgautsch / _.md
Created August 20, 2013 19:40
[dot enter: 08] movetofront
@jgautsch
jgautsch / _.md
Created August 20, 2013 19:58
[dot enter: 09] move along
@jgautsch
jgautsch / simple_udp_server.rb
Created September 10, 2013 04:41
A simple UDP server that will receive some text, reverse it and send that as a response. Runs locally on port 1234 (127.0.0.1:1234)
require 'socket'
require 'pp'
host = 'localhost'
port = 1234
s = UDPSocket.new
s.bind(nil, port)
while 1 do
@jgautsch
jgautsch / wtf.c
Created October 3, 2013 06:22
sending name to ftp server
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Interacting with server
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char *file_name = argv[3];
/* First send the length of the file name */
short int file_name_length = strlen(file_name);
if (send(sock, &file_name_length, sizeof(file_name_length), 0) <= 0)
DieWithError("send() sent a different number of bytes than expected");
@jgautsch
jgautsch / application.rb
Created October 21, 2013 15:58
Acting like production. Caching everything, not reloading anything
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
@jgautsch
jgautsch / 20131022143445_add_subject_to_if_report.rb
Last active December 26, 2015 05:59
A migration that is stalling
# This one worked just fine 20 minutes ago. Nothing has changed since then.
class AddSubjectToIfReport < ActiveRecord::Migration
def change
add_column :if_reports, :subject, :text
end
end
@jgautsch
jgautsch / thermd.c
Created October 30, 2013 19:59
Thermal sensor threaded server
/***** Jon Gautsch and Rob Wirthman
***** thermd.c
***** CSE 30264 - Project 2
*****
***** USAGE: ./tcpserver
*****
***** See comments and README.txt for details
*****/
#include <stdio.h> /* for printf() and fprintf() */
@jgautsch
jgautsch / thermd.c
Last active December 27, 2015 01:08
fixed the thermal sensor server. The problem was not closing the socket, resulting in too many file descriptors open. I'll send part of a readme soon...
/***** Jon Gautsch and Rob Wirthman
***** thermd.c
***** CSE 30264 - Project 2
*****
***** USAGE: ./tcpserver
*****
***** See comments and README.txt for details
*****/
#include <stdio.h> /* for printf() and fprintf() */
@jgautsch
jgautsch / heap.c
Created December 5, 2013 02:09
reformatted the heap code
/* HPSORT.C : PROGRAM TO CREATE A HEAP AND TO SORT A HEAP, HEAP IS STORED IN AN ARRAY */
#include<stdio.h>
#include<conio.h>
void crheap(int [], int);
void processheap(int [],int);
int main(void)
{
int k[50],child,parent,q,key,n,t,i;
clrscr();
printf("\n enter the no. of elements: ");
@jgautsch
jgautsch / btree.c
Created December 5, 2013 02:36
btree for benchmarking
#include <stdio.h>
#include <stdlib.h>
// #include "Tree.h"
typedef int ElementType;
struct TreeNode;
typedef struct TreeNode *Position;
typedef struct TreeNode *SearchTree;
SearchTree MakeEmpty(SearchTree T);