Skip to content

Instantly share code, notes, and snippets.

View guyhughes's full-sized avatar

guy hughes guyhughes

  • /boot/efi/vmlinuz+0x0
View GitHub Profile
@guyhughes
guyhughes / kill-ssh-agents.posix.sh
Last active May 10, 2016 20:13
Kill all ssh-agents by process id using POSIX-ish tools only (cygwin-friendly)
ps -s | grep ssh-agent | sed -re 's/^\s+([[:digit:]]+).*$/\1/' | xargs kill -TERM
@guyhughes
guyhughes / check-path-directories.bash
Created May 9, 2016 20:19
Check that every directory in $PATH exists
(IFS=:;for p in ${PATH}; do if [[ -d $p ]]; then echo "OK $p"; else echo "ERR $p"; fi; done; )
@guyhughes
guyhughes / openvpn-resolv.conf-issues.md
Created April 20, 2016 14:36
How to make openvpn resolv.conf updates work
apt-get install openresolv
echo > vpntarget.ovpn <<<EOF
script-security 2
dhcp-option DNS 8.8.8.4
dhcp-option DNS 8.8.4.4
up /etc/openvpn/update-resolv-conf
public class Cell<E> {
private E value;
public Cell(E value){
if (value == null)
throw new NullPointerException();
this.value = value;
}
public boolean isCell(){return true;}
#include <iostream>
int main ()
{
int z;
for (int i = 39; i < 43; i++){
std::cerr << "i: " << i << std::endl;
for (int j = 29; j < i-9; j+=3){
z = i % j;
std::cerr << "z: " << z << std::endl;
@guyhughes
guyhughes / Frequency.java
Created April 16, 2016 01:10
ITI1121 Apirl 2014 question 7 exam
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.Random;
class Tuple {
private final char c;
private boolean visited;
public Tuple(char c){
#include <bits/wordsize.h>
#include <stdio.h>
#include <inttypes.h>
int main(void)
{
uint64_t f, b, q, *foo, *bar, *qux;
foo=&f, bar=&b, qux=&q;
printf("size of a pointer is %d bytes\n",__WORDSIZE/8);
/*
* Question 5
* All of these classes should be public and in their own file.
*/
class Shape {
protected double x,y;
public Shape(double x, double y){
this.x=x;
this.y=y;
}
@guyhughes
guyhughes / Makefile
Last active June 27, 2016 15:27
trig in cpp
trig: trig.cc
g++ -o trig trig.cc -Wall -Wextra -pipe -lm
import java.util.LinkedList;
public class Lucas {
public static int lucas(int n){
switch(n){
case 0:
return 2;
case 1:
return 1;
default:
if (n < 0)