Skip to content

Instantly share code, notes, and snippets.

View alanjcfs's full-sized avatar
🧏‍♂️

Alan Fung-Schwarz alanjcfs

🧏‍♂️
View GitHub Profile
extern crate unicode_segmentation;
use unicode_segmentation::UnicodeSegmentation;
use std::fs::File;
use std::io::{BufReader, Error, Read};
use regex::Regex;
pub fn read_file(s: &str) -> Result<Vec<String>, Error> {
let f = File::open(s)?;
let mut file = BufReader::new(&f);
let mut string: String = "".to_string();

Keybase proof

I hereby claim:

  • I am alanjcfs on github.
  • I am mimic (https://keybase.io/mimic) on keybase.
  • I have a public key ASBmZqKO5C1s06856tzEecMny9tXx_THTB_IcysxYTHM2Qo

To claim this, I am signing this object:

pub mod area_calculator {
#[test]
fn it_works() {
let s = Rectangle{width: 10u32, height: 20u32};
assert!(s.area() == 200u32);
let t = Square{ side: 20u32 };
assert!(t.area() == 400u32);
}
pub struct Rectangle {
use std::old_io::net::tcp::TcpStream;
fn main() {
// use std::old_io::net::ip::{Ipv4Addr, SocketAddr};
// let SocketAddress = SocketAddr { ip: "irc.freenode.net", port: "6667" };
let mut g = 1;
{
let mut stream = TcpStream::connect("irc.freenode.net:6667").unwrap();
let _ = stream.write_all(b"NICK simplerustbot\r\n");
@alanjcfs
alanjcfs / xmonad.hs
Created July 24, 2014 18:11
xmonad config (provided by Fedora with some of my modifications)
-- default desktop configuration for Fedora
import System.Posix.Env (getEnv)
import Data.Maybe (maybe)
import XMonad
import XMonad.Config.Desktop
import XMonad.Config.Gnome
import XMonad.Config.Kde
import XMonad.Config.Xfce
var checkTime = function(){
currTime = myPlayer.currentTime();
if (currTime >= 3 && currTime <= 4 && hsh['calendar'] === false) {
hsh['calendar'] = true;
$('.fc-highlight-this').effect("highlight", 3000);
}
if (currTime >= 13 && currTime <= 14 && hsh['always'] === false) {
hsh['always'] = true;
$('.always span').effect("highlight", {color: '#83c0ff',
@alanjcfs
alanjcfs / generalizefizzbuzz.scala
Last active December 17, 2015 13:29
This is an attempt to generalize FizzBuzz based on my current Scala understanding.
import scala.collection.SortedMap
object FizzBuzz {
def generator(mapping: SortedMap[Int, String], lst: List[Int]): List[String] = {
// sort Map descending - Unimplemented
// Something very simple
// (n: Int) => {
object FizzBuzz {
def convertToFizzBuzz(listOfNumber: List[Int]): List[String] = {
listOfNumber.map((i: Int) => fizzbuzz(i))
}
def fizzbuzz(n: Int): String = {
if (n % 3 == 0 && n % 5 == 0) { "FizzBuzz" }
else if (n % 3 == 0) { "Fizz" }
else if (n % 5 == 0) { "Buzz" }
else { n.toString }
@alanjcfs
alanjcfs / grid-question-test.rb
Created April 2, 2013 22:49
sample file for creating a grid question using surveyor
survey "Grid question test", default_mandatory: false do
section 'Communication Skills' do
grid 'Identify communication and interviewing skills' do
a 'Yes'
a 'No'
q 'Able to articulate job duties and skills', pick: :one
q 'Easily understood, clear', pick: :one
q 'Demonstrates good listening skills', pick: :one
q 'Professional via phone/email and in person', pick: :one
class Client < ActiveRecord::Base
attr_accessible :first_name, :last_name, :middle_initial, :suffix,
:email, :email_2, :phone, :using, :phone_2, :using_2,
:age_group, :communication_types, :funder,
:street_address, :street_address_2, :city, :county, :zip_code, :state,
:permission_to_photograph, :mailing_list, :email_or_letter,
:notes
validates :first_name, presence: true, length: { maximum: 15 }
validates :last_name, presence: true, length: { maximum: 15 }