Skip to content

Instantly share code, notes, and snippets.

@yutopio
yutopio / tree.cs
Created May 24, 2013 14:18
AVL Tree implemenation in C#
using System;
using System.Collections;
using System.Collections.Generic;
public class Tree<T> : ICollection<T>, IList<T> where T : IComparable<T>
{
public class TreeNode : ICollection<T>, IList<T>
{
public TreeNode(T value, Tree<T> tree)
{
@yutopio
yutopio / sieve.cs
Created May 24, 2013 14:34
Sieve of Eratostheness
using System;
using System.Collections.Generic;
using System.IO;
unsafe class Program
{
static void Main()
{
var start = DateTime.Now;
var fs = new FileStream("prime.txt", FileMode.Create, FileAccess.Write, FileShare.Read);
@yutopio
yutopio / ipv4.cs
Created May 24, 2013 14:35
Enumerates IPv4 address space allocation.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
class Program
{
static void Main()
@yutopio
yutopio / pseudoprimes.cs
Created May 24, 2013 14:43
Enumerates some pseudoprimes.
using System;
using System.IO;
unsafe class Program
{
const int size = 1000000000;
static bool[] sieve = null;
static void Main()
{
@yutopio
yutopio / neville.cs
Created May 24, 2013 14:54
Neville interpolation
using System;
class Program
{
static void Main()
{
var funcs = new Func<double, double>[8];
funcs[0] = x => Math.Exp(x);
funcs[1] = x => Math.Log(x);
funcs[2] = x => 1 + x + x * x;
@yutopio
yutopio / YTOMultilineTextbox.m
Created January 18, 2014 11:00
Multiline Textbox for iOS 7.
//
// YTOMultilineTextbox.m
// MultilineTextbox
//
// Created by Yuto Takei on 1/18/14.
// Copyright (c) 2014 Yuto Takei. All rights reserved.
//
@interface YTOMultilineTextbox : UITextView
@yutopio
yutopio / YTONotificationTest.m
Created January 19, 2014 04:45
Sample project to inspect notification messages during iOS application running.
//
// YTONotificationTest.m
//
// Created by Yuto Takei on 1/19/14.
// Copyright (c) 2014 Yuto Takei. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@yutopio
yutopio / BytesEncoder.cs
Last active January 4, 2016 08:09
Encoder/decoder for byte array into string with 0-9,a-v
using System;
using System.Diagnostics;
using System.Text;
class Program
{
static void Main(string[] args)
{
var rnd = new Random(1);
for (var i = 0; i < 5000; i++)
@yutopio
yutopio / FileSplitMerge.cs
Last active August 29, 2015 13:55
Splits a large file into smaller files, and merges them back into the original one.
using System;
using System.IO;
class Program
{
const int SplitSize = 1024 * 1024 * 1024; // Splits into 1GB files
const int BufferSize = 1024 * 1024; // using 1MB size buffer
static void Main(string[] args)
{
@yutopio
yutopio / ViewControllerTrack.m
Created November 6, 2014 02:37
Implementation injection
//
// AppDelegate.m
//
// Created by Yuto Takei on 10/8/14.
// Copyright (c) 2014 Yuto Takei. All rights reserved.
//
#import <objc/runtime.h>
#import "AppDelegate.h"