Skip to content

Instantly share code, notes, and snippets.

@ArtemAvramenko
ArtemAvramenko / TypeScript_light.xml
Last active May 5, 2016 13:10
TypeScript for Notepad++ (light theme)
<NotepadPlus>
<UserLang name="TypeScript" ext="ts" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="yes" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00// 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@ArtemAvramenko
ArtemAvramenko / TypeScript_dark.xml
Last active August 10, 2023 11:51
TypeScript for Notepad++ (dark theme)
<NotepadPlus>
<UserLang name="TypeScript" ext="ts" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="yes" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00// 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
angular
.module("DemoApp", [])
.controller("DemoController", DemoController)
.config(["$provide", $provide =>
{
$provide.decorator("ngModelDirective", ["$delegate", $delegate =>
{
var directive = <angular.IDirective>$delegate[0];
var oldCompile = directive.compile;
directive.compile = (element, attr, trans) =>
@ArtemAvramenko
ArtemAvramenko / CsvWriter.cs
Last active August 29, 2015 14:19
C# CSV writer
public delegate void ValuesGetter(params Object[] values);
private const char Comma = ',';
private static readonly Regex _escapedChars = new Regex(@"[,""\r\n]");
public static string ToCsv<T>(IEnumerable<T> enumerable, string headers, Action<T, ValuesGetter> valuesGetter)
{
var columnCount = headers.Count(c => c == Comma) + 1;
var result = new StringBuilder();
// Type definitions for React:
// https://raw.githubusercontent.com/borisyankov/DefinitelyTyped/master/react/react-global.d.ts
declare var __extends: (derived: Object, base: Object) => void;
declare var JSXTransformer: { transform: (jsx: string, opts: Object) => { code: string } };
class ReactUtils {
private static _extends: typeof __extends;
private static _compiled = <{ [key: string]: () => React.ReactElement<any> }>{};
@ArtemAvramenko
ArtemAvramenko / SplitterEx.cs
Last active August 12, 2019 15:30
WinForms Splitter without flickering
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Windows.Forms
{
/// <summary>
/// Represents a splitter control that enables the user to resize docked controls.
@ArtemAvramenko
ArtemAvramenko / shamExports.ts
Last active December 7, 2015 00:34
Shams CommonJS modules
var module: { exports };
var exports = {
sham: (() => {
var sham = <{
(moduleName: string): void;
modules: { [moduleName: string]: { exports } };
}>(moduleName => {
exports = { sham };
module = sham.modules[moduleName] = { exports };
});
@ArtemAvramenko
ArtemAvramenko / WScript.d.ts
Created August 2, 2015 02:02
TypeScript declarations for Windows Scripting Host
// Windows Script Host APIS
// http://blogs.msdn.com/b/freik/archive/2012/10/19/goofing-around-with-typescript-amp-windows-script-host.aspx
declare var ActiveXObject: { new (s: string): any; };
interface IWScriptStringCollection {
Item(n: number): string;
Count: number;
length: number;
}
public static class AnonymousTypeHelper
{
public static T Cast<T>(T typeHolder, object x)
{
return (T)x;
}
public static T GetNull<T>(T typeHolder) where T : class
{
return null;
@ArtemAvramenko
ArtemAvramenko / mixWithFunc.ts
Last active August 29, 2015 14:27
Mix class with function.
/**
* Returns a function mixed with an object.
* @param obj - Object to mix.
* @param func - Target function.
*/
function mixWithFunc<T extends Function>(obj: { __proto__?}, func: T) {
var objProto = <{ constructor }>obj.__proto__;
var objClass = <{ __mixedProto__ }>objProto.constructor;
var proto = <typeof obj>objClass.__mixedProto__;
if (!proto) {