Skip to content

Instantly share code, notes, and snippets.

Avatar
💪
Trying to find time to contribute more.

OJ Reeves OJ

💪
Trying to find time to contribute more.
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am oj on github.
  • I am oj (https://keybase.io/oj) on keybase.
  • I have a public key ASDEtNxWXtN0-EAM9rF-6tP-qjzzVpaJbq6rVyq8Eo0tIAo

To claim this, I am signing this object:

@OJ
OJ / windbg_dark.wew.b64
Created Mar 22, 2017
Dark windbg workspace
View windbg_dark.wew.b64
V0RXUwEAAAAAAAIAEAAEABkZGQAAAAAAAQACABAABADPzpoAAAAAAAIAAgAQAAQAb21+AAAAAAADAAIAEAAEAM/OmgAAAAAACAACABAABACAMToAAAAAAAkAAgAQAAQAb21+AAAAAAAKAAAAEAAEACAAAAAAAAAAEgAAABAABAABAAAAAAAAAAoAAgAQAAQA5h48AAAAAAALAAIAEAAEAFJUWAAAAAAAEAACABAABADPaUsAAAAAABEAAgAQAAQAdaaHAAAAAAASAAIAEAAEAHWmhwAAAAAAEwACABAABAB1h6YAAAAAABgAAgAQAAQAr8TbAAAAAAAZAAIAEAAEADOZ/wAAAAAAIwACABAABABSVFgAAAAAAAD/AgAQAAQAz86aAAAAAAAB/wIAEAAEABkZGQAAAAAAAv8CABAABACAMToAAAAAAAP/AgAQAAQAGRkZAAAAAAAI/wIAEAAEAM/OmgAAAAAACf8CABAABAAZGRkAAAAAAAr/AgAQAAQAz86aAAAAAAAL/wIAEAAEABkZGQAAAAAAEP8CABAABADPzpoAAAAAABH/AgAQAAQAGRkZAAAAAAAS/wIAEAAEAM/OmgAAAAAAE/8CABAABAAZGRkAAAAAADj/AgAQAAQAz86aAAAAAAA5/wIAEAAEABkZGQAAAAAAOv8CABAABADPzpoAAAAAAED/AgAQAAQAz86aACEGAABB/wIAEAAEABkZGQAlBgAAIwAAABAAAgAAAAAAAAAAADAAAAC4AK4AIgBDADoAXABVAHMAZQByAHMAXABiAHUAcgBsAHkAXABEAG8AYwB1AG0AZQBuAHQAcwBcAFYAaQBzAHUAYQBsACAAUwB0AHUAZABpAG8AIAAyADAAMQAwAFwAUAByAG8AagBlAGMAdABzAFwAUAByAG8AYwBlAHMAcwBJAG4AagBlAGMAdABpAG8AbgBcAGIAaQBuAFwAVwBpAG4AMwAyAFwARABlAGIAdQBnAAAAAAAiAAAAgAB0AHMAcgB2ACoA
@OJ
OJ / Ruler.hs
Created Oct 26, 2011
Solution to the Ruler Problem in Haskll
View Ruler.hs
ruler :: Int -> Int -> String
ruler h s = ruler' (2 ^ h * s + 1) h 1 [] []
where
outChar c r = if (c `mod` (2 ^ r)) == 1 then '|' else ' '
ruler' _ 0 _ _ a = unlines $ reverse a
ruler' w r c l a = let nl = (outChar c r) : l
in if c == w then ruler' w (r - 1) 1 [] (nl : a)
else ruler' w r (c + 1) nl a
-- to diplay results:
View gist:273516
let rec nums = seq { yield 1
for n in nums do yield n+1 }
How does this work?
First thing to remember is that seq is a lazy sequence. It's an IEnumerable under the hood I believe. It'll only evaluate those values which you actually attempt to access. When you take the first element of the sequence, it'll return 1 (I'll assume you know the yield keyword already). The next time you hit the sequence it knows, thanks to yield, that it bypasses the first yield statement and makes it ways to the for loop. That loop iterates over the already-evaluated values in the sequence, which in our case is just 1. So the second item in the sequence is a yield of 1 + 1, whichi s 2. So yes, the two elements of the evaluated sequence are now 1 and 2. When you next access the sequence to get the next value, you are returned to the point where the yield statement was last called and hence we're back in the for loop. The loop has already taken the value of 1 from the previous iteration, but now the sequence
View words.erl
%% My second code kata.
%% This is the first part of the question listed at this URL:
%% http://codekata.pragprog.com/2007/01/kata_eight_conf.html
%% more to come later.
-module(words).
-author('OJ Reeves <oj@buffered.io>').
-export([composition/1]).
-define(WORDLENGTH, 6).
composition(FileName) ->
View anagrams.erl
%% @author OJ Reeves <oj@buffered.io>
%%
%% My first crappy attempt at Dave Thomas' 6th Code Kata
%% (located at http://codekata.pragprog.com/2007/01/kata_six_anagra.html)
%%
%% Extra bits are now done.
%%
%% Refactored some small bits, and made changes based on suggestions from
%% the guys on Google Wave.
@OJ
OJ / MoreAbsoluteFuckingGenius.cs
Created Apr 20, 2009
Another pile of shit that I stumbled across!
View MoreAbsoluteFuckingGenius.cs
XmlDocument doc = rs.BuildXmlDoc();
System.IO.MemoryStream aMemoryStream = new System.IO.MemoryStream();
XmlTextWriter aXmlTextWriter = new XmlTextWriter(aMemoryStream, System.Text.Encoding.UTF8);
//save the xml representation in a memory stream
doc.Save(aXmlTextWriter);
//pass the xml as a parameter
param[2] = System.Text.Encoding.UTF8.GetString(aMemoryStream.ToArray());
@OJ
OJ / AwfulPileOfShit.cs
Created Apr 15, 2009
A large pile of shit that I recently discovered in an open source code base from CodePlex.
View AwfulPileOfShit.cs
public void SendMessage()
{
lock(this)
{
//do some sanity checking
if(host == null || host.Trim().Length == 0)
{
throw new Exception("No host specified.");
}
if(from == null || from.Trim().Length == 0)
View keybase.md

Keybase proof

I hereby claim:

  • I am oj on github.
  • I am oj (https://keybase.io/oj) on keybase.
  • I have a public key whose fingerprint is D64B 75C1 3A08 FB66 D196 4A56 D5DC 61FB 9326 0597

To claim this, I am signing this object: