Skip to content

Instantly share code, notes, and snippets.

using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace IsKernel.Pool.Vanilla.Memory
{
public static class GenericCopyMaker<T>
{
public static T GetDeepCopy(object objectToCopy)
{
@iskernel
iskernel / UbuntuNotebook_Bash_InstallCpanm.sh
Last active December 20, 2015 01:29
How to install cpanm.
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
#Install module with dependencies
sudo cpanm Foo::Bar
@iskernel
iskernel / NotebookPerl_StringFileIO.pl
Last active December 20, 2015 01:29
How to read an entire file into a string using Perl.
use File::Slurp;
#Reads an entire file into a string (scalar)
my $text = read_file( 'index.html' ) ;
#Writes a string (scalar) into a file
write_file( 'index_2.html', $text ) ;
@iskernel
iskernel / CSharp_GrandTrunkCurrencyConversionApi_Example.cs
Created July 14, 2013 19:07
An example on how to use the GrandTrunk currency conversion Web Service C# API
using System;
using System.Collections.Generic;
using IsKernel.Api.Pool.Currency;
namespace GrandTrunkCurrenciesApiExample
{
class Program
{
public static void Main(string[] args)
{
@iskernel
iskernel / CSharp_Nunit_AlwaysObtainAFutureDate_Example.cs
Last active December 19, 2015 17:39
A simple method for always obtaining a future date.
//The RIGHT way
[Test]
public void GetConversionRate_DateFutureParameter_ThrowsException()
{
//This will always return a date that will be in the future
DateTime future = DateTime.Now.AddYears(1);
Assert.Throws( typeof(CurrencyConversionException),
() => GrandTrunkCurrencyConversionService.Instance
.GetConversionRate(TEST_CURRENCY_NAME_US_DOLLAR,
TEST_CURRENCY_NAME_AU_DOLLAR,
@iskernel
iskernel / Notebook_Java_EnvironmentNewline.java
Created July 13, 2013 17:15
How to get line separator in a OS-independent way in Java.
//Equivalent of C# Environment.Newline
System.getProperty("line.separator");
@iskernel
iskernel / Notebook_CSharp_DesignPatterns_Singleton.cs
Created July 13, 2013 13:01
An example implementation of the Singleton Design pattern in C#
using System;
public class Singleton
{
private static Singleton instance;
private Singleton() {}
public static Singleton Instance
{
@iskernel
iskernel / Notebook_PowerShell_FixCorruptDirectory.ps1
Created July 13, 2013 00:25
How to fix a corrupt directory using ChkDsk.
<#
When you attempt to open, delete or rename a file or folder using Windows NT
Explorer, File Manager or a command prompt, you may receive one of the
following error messages:
<drive>:\<folder> is not accessible
The file or directory is corrupt and non-readable.
The file or directory is corrupt and non-readable.
The file or directory \<folder> is corrupt and unreadable.
#>
#The drive you want to check
@iskernel
iskernel / Notebook_PowerShell_ChangeExecutionPolicy.ps1
Created July 13, 2013 00:26
How to change the execution policy for PowerShell scripts.
#Allows execution PowerShell scripts on System
Set-ExecutionPolicy Unrestricted
@iskernel
iskernel / Dart_HtmlTablesorter_HowToUse.dart
Created July 6, 2013 17:20
The Dart code for using the HTML Tablesorter package.
import "dart:html";
import "package:iskernel_html_tablesorter/html_tablesorter.dart";
void main()
{
TableSorter sorter = new TableSorter("#sortableTable");
sorter.enableSorting(true);
}