Skip to content

Instantly share code, notes, and snippets.

View gogsbread's full-sized avatar

Antony Thomas gogsbread

  • facebook
  • San Francisco Bay area,CA
View GitHub Profile
@gogsbread
gogsbread / ReflectionUsingCTP.cs
Last active December 10, 2015 01:08
Quickly invoke a method using Reflection and power of Roslyn CTP.. Very helpful if you want to execute methods inside a framework library for debugging.
//Assume you have a method, m() in class "Framework" inside framework.dll
// Fire C# interpreter(a.k.a Roslyn CTP) from your Visual Studio and type the following lines of code.
using System.Reflection;
Assembly assembly = Assembly.LoadFrom(@"path\to\assembly\framework.dll");
Type framework = assembly.GetType("Framework");
ConstructorInfo cFramework = framework.GetConstructor(Type.EmptyTypes);
object oFramework = cFramework.Invoke(new object[] { });
MethodInfo mMethod = framework.GetMethod("m");
@gogsbread
gogsbread / DebugFlagFolder.cs
Created December 21, 2012 21:12
Check if your library folder contains non-optimized (“DEBUG” build) external libraries.
using System.Reflection;
string[] pathNames = Directory.GetFiles(@"path\to\library\folder\");
foreach (string path in pathNames)
{
Assembly asm = Assembly.LoadFrom(path);
object[] attrs = asm.GetCustomAttributes(typeof(DebuggableAttribute), false);
Console.WriteLine("{0}:{1}", asm.FullName, (attrs.Length > 0) ? "Release" : "Debug");
}
@gogsbread
gogsbread / shell_expansions.sh
Created December 23, 2012 21:25
Viewing Shell expansions
# You know that `cd ~` will change to your home directory. But, if you want to know how shell expands your ~, you can use 'echo'
echo ~
# will show /User/antonydeepak
echo Antony{1,2}
# shows Antony1 Antony2
@gogsbread
gogsbread / stop_daemons.sh
Last active December 10, 2015 02:48
How to stop application in your menubar on OsX(Mac)?
#If you find an annoying application that started during boot-up but you wanted to stop it thru console, use the following commands
#Note: The applications that appears in your menubar are mostly daemons(background processes) and hence our objective is to stop this daemon.
launchctl list
# This command will use launchctl(your interface to launchd, daemon\service manager for Osx) and lists all the current daemons running in your computer.
# The output will display 3 columns of information PID, status and Label.
# Search for the Label of the job\daemon\aplication that you wanted to kill.
launchctl stop <label>
# where <label> is the name of the label for your process. Using this command will stop and quit the application
@gogsbread
gogsbread / SimilarJugs.cs
Created January 2, 2013 23:03
Finding similar jugs in O(n2) time. This is a naive implementation of finding two jugs of similar capacity.
namespace dotNetPlayGround
{
using System;
using System.Collections.Generic;
public struct Jug
{
public int Capacity;
public int Filled;
public Jug(int capacity,int filled){
@gogsbread
gogsbread / Queue.cs
Created January 2, 2013 23:05
Rudimentary Queue ADT and a job processing example using Queue.
using System;
using System.Collections;
using System.Collections.Generic;
namespace dotNetPlayGround
{
///<summary>
///endpos - position where you can Enqueue
///currentpos - position where you can Dequeue
///</summary>
@gogsbread
gogsbread / RadixSort.cs
Created January 2, 2013 23:08
Rudimentary implementation of RadixSort. Academic and reference purpose
namespace dotNetPlayGround
{
using System;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// TODO: Update summary.
/// </summary>
public class RadixSort
{
@gogsbread
gogsbread / Reflections.cs
Created January 2, 2013 23:11
Comparing reflection using Mono.Cecil and .NET Reflection.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Mono.Cecil;
using System.IO;
class Reflect
{
@gogsbread
gogsbread / ReverseFileCopier.cs
Created January 2, 2013 23:14
Naive implementation of Copying file in reverse where 1) File size is large 2) buffering is not allowed. This is a good interview question. Not sure if the code works
namespace dotNetPlayGround
{
using System;
using System.IO;
using System.Collections.Generic;
/// <summary>
/// TODO: Update summary.
/// </summary>
public class ReverseFileCopier
{
@gogsbread
gogsbread / TypeDescriptor.cs
Created January 2, 2013 23:23
Basic TypeDescriptor example
using System;
using System.ComponentModel;
namespace dotNetPlayGround
{
public enum DataType : int
{
None = 0,
[Description("A")]
Alpha = 1,