Skip to content

Instantly share code, notes, and snippets.

Avatar

Franklin Chen FranklinChen

View GitHub Profile
@FranklinChen
FranklinChen / inheritance.c
Created Nov 7, 2011
Most basic inheritance in C
View inheritance.c
#include <stdlib.h>
#include <stdio.h>
/* Single inheritance, treating Animal as abstract base class. */
typedef struct Animal_vtable {
void (*eat)(void *);
void (*sound)(void *);
} Animal_vtable;
typedef struct Animal {
View keybase.md

Keybase proof

I hereby claim:

  • I am franklinchen on github.
  • I am franklinchen (https://keybase.io/franklinchen) on keybase.
  • I have a public key ASDhVqCYgr6xkfxsfiM5OWYrkqFtO0Rc6P6wKgk8Mh8Xhwo

To claim this, I am signing this object:

@FranklinChen
FranklinChen / # shibboleth-sp - 2016-09-28_16-50-24.txt
Created Sep 28, 2016
shibboleth-sp on macOS 10.12 - Homebrew build logs
View # shibboleth-sp - 2016-09-28_16-50-24.txt
Homebrew build logs for shibboleth-sp on macOS 10.12
Build date: 2016-09-28 16:50:24
@FranklinChen
FranklinChen / ForBill.hs
Created Nov 18, 2013
For @BillLaboon hey @FranklinChen is there an easy way in Haskell to find out which element in a list is most common, e.g. [1,1,1,2,3] -> 1 ?
View ForBill.hs
import Test.HUnit
import qualified Data.List as List
import qualified Data.Ord as Ord
import Data.PSQueue as PSQueue
{-
For @BillLaboon
hey @franklinchen is there an easy way in Haskell to find out which element in a list is most common, e.g. [1,1,1,2,3] -> 1 ?
View tree_select.rb
require 'minitest/autorun'
# Traverse in preorder
def tree_traverse(tree, &block)
if tree.is_a? Array and tree.length > 0
yield tree
tree.each {|t| tree_traverse(t, &block) }
end
end
@FranklinChen
FranklinChen / playground.rs
Created Nov 15, 2015 — forked from anonymous/playground.rs
Shared via Rust Playground
View playground.rs
use std::sync::{Arc, Mutex};
use std::thread;
struct Toaster {
count: u32
}
impl Toaster {
fn new() -> Toaster {
Toaster { count: 0 }
@FranklinChen
FranklinChen / playground.rs
Last active Nov 15, 2015 — forked from anonymous/playground.rs
Shared via Rust Playground
View playground.rs
use std::thread::{spawn, sleep_ms};
use std::sync::mpsc::channel;
fn main() {
// Names of attendees.
let names = vec![format!("A"), format!("B"), format!("C"), format!("D"), format!("E")];
// Create a channel to communicate between attendees and the toaster.
let (toaster_tx, toaster_rx) = channel();
View test-pipes-recursive.hs
-- | http://stackoverflow.com/questions/14259229/streaming-recursive-descent-of-a-directory-in-haskell/14261710#14261710
--
-- Updated to latest Pipes 4.
module Main where
import Pipes
import qualified Pipes.Prelude as P
import Control.Monad (forM_)
import System.Directory (doesDirectoryExist, getDirectoryContents)
@FranklinChen
FranklinChen / WordCount.hs
Created Dec 8, 2011
Knuth/McIlroy word count task using Haskell
View WordCount.hs
import qualified System
import qualified Data.List as List
import qualified Data.Char as Char
import qualified Data.HashMap.Strict as HashMap
main :: IO ()
main = do
[arg] <- System.getArgs
text <- getContents
let n = read arg
@FranklinChen
FranklinChen / cpp_abuse_1.cc
Created Oct 5, 2011
C++ abuse: simple example
View cpp_abuse_1.cc
// C++ abuse
#include <iostream>
using namespace std;
class Animal {
public:
virtual void food() = 0;
virtual void sound() = 0;