This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayDeque; | |
import java.util.ArrayList; | |
import java.util.Deque; | |
import java.util.List; | |
import java.util.Stack; | |
public class ReversePolish { | |
private ReversePolish() { } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DelegateUtility | |
{ | |
public static T Cast<T>(Delegate source) where T : class | |
{ | |
return Cast(source, typeof(T)) as T; | |
} | |
public static Delegate Cast(Delegate source, Type type) | |
{ | |
if (source == null) return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
namespace System.Windows.Forms.Helpers | |
{ | |
public class ApplicationHelper | |
{ | |
/// <summary> | |
/// Check if current process already running. If running, set focus to existing process and | |
/// returns <see langword="true"/> otherwise returns <see langword="false"/>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void DoubleBuffering(this Control control, bool enable) | |
{ | |
var method = typeof(Control).GetMethod("SetStyle", BindingFlags.Instance | BindingFlags.NonPublic); | |
method.Invoke(control, new object[] { ControlStyles.OptimizedDoubleBuffer, enable }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Maths | |
{ | |
internal class Maths | |
{ | |
public static IEnumerable<long> Fibonacci(int n) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires: | |
// using System.Diagnostics; | |
// using System.Runtime.CompilerServices; | |
[MethodImpl(MethodImplOptions.NoInlining)] | |
public static string GetCurrentMethod() | |
{ | |
StackTrace st = new StackTrace(); | |
StackFrame sf = st.GetFrame(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
public class FSM<T> where T : struct, IConvertible, IComparable | |
{ | |
public Transition<T, T>[] Transitions { get; private set; } | |
public T CurrentState { get; private set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Converts from degrees to radians. | |
Math.radians = function(degrees) { | |
return degrees * Math.PI / 180; | |
}; | |
// Converts from radians to degrees. | |
Math.degrees = function(radians) { | |
return radians * 180 / Math.PI; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rgbToHsv = function(r, g, b) { | |
var rp = r / 255; | |
var gp = g / 255; | |
var bp = b / 255; | |
var cmax = Math.max(rp, gp, bp); | |
var cmin = Math.min(rp, gp, bp); | |
var delta = cmax - cmin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "g(i,x,t,o){return((3&x&(i*((3&i>>16?\"BY}6YB6%\":\"Qj}6jQ6%\")[t%8]+51)>>o))<<4);};main(i,n,s){for(i=0;;i++)putchar(g(i,1,n=i>>14,12)+g(i,s=i>>17,n^i>>13,10)+g(i,s/3,n+((i>>11)%3),10)+g(i,s/5,8+n-((i>>10)%3),9));}"|gcc -xc -&&./a.out|aplay |