Skip to content

Instantly share code, notes, and snippets.

View virtualsafety's full-sized avatar

virtualsafety virtualsafety

View GitHub Profile
@virtualsafety
virtualsafety / ddns.go
Created December 24, 2012 14:23 — forked from hugozhu/ddns.go
package main
import (
"io/ioutil"
"log"
"net"
"net/http"
"net/url"
"strings"
"time"
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
// Implementation of a UDP proxy
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
module Main where
import Text.Parsec
import Text.Parsec.String
input_text :: String
input_text = "foo123:"
main :: IO ()
main = do
module AVLTree where
data BT = L | N Int BT BT deriving (Show, Eq)
-- Nice, small and useful functions
empty = L
-- You could say, depth L == Nothing depth (N v L L) == Just 0, but works for
-- me better this way:
depth L = 0
depth (N _ t u) = (max (depth t) (depth u)) + 1
import Data.Maybe (isJust)
data Tree a = Leaf | Node (Tree a) a (Tree a)
replace :: a -> Tree a -> Tree a
replace a Leaf = Node Leaf a Leaf
replace a (Node l _ r) = Node l a r
rotateR :: Tree a -> Tree a
rotateR (Node (Node x a y) b z) = Node x a (Node y b z)
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
module RedBlackTree where
data Zero
data Succ n
type One = Succ Zero
data Black
@virtualsafety
virtualsafety / Queue_LinkedList.c
Created July 23, 2016 04:05 — forked from mycodeschool/Queue_LinkedList.c
Linked List implementation of Queue.
/*Queue - Linked List implementation*/
#include<stdio.h>
#include<stdlib.h>
struct Node {
int data;
struct Node* next;
};
// Two glboal variables to store address of front and rear nodes.
struct Node* front = NULL;
struct Node* rear = NULL;
@virtualsafety
virtualsafety / c99.l
Created July 26, 2016 03:00 — forked from codebrainz/c99.l
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>