Skip to content

Instantly share code, notes, and snippets.

View asduser's full-sized avatar

Network Engineer asduser

View GitHub Profile
@asduser
asduser / delegate_1.cs
Created March 30, 2016 21:25
How does delegate work? Explanation via C#. Example based on abstract user account in bank.
using System;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
// Create a new account instance with initial amount.
Account acc = new Account(500);
@asduser
asduser / performanceTest1a.js
Last active July 2, 2021 10:33
Performance difference between array.find vs array.indexOf. Result: indexOf is faster ;)
// ES5
var list = [];
for (var i =0, len = 500000; i < len; i++) {
list.push(i);
}
console.time("test");
repeater(20, {callback: test1, value: 499999, list: list} );
console.timeEnd("test");
/**
* This class provides a functional to find a point inside a specific figure.
* First of all you have to define a figure coordinates.
* Then use an appropriate method "check( point )", which will return a result.
*/
class PointManager {
constructor(setList) {
this.setX = [];
this.setY = [];
@asduser
asduser / callback_sample.js
Created March 28, 2016 21:32
Simple JavaScript callback.
const users = [
{Name: "Peter", Age: 30, Id: 1},
{Name: "Bob", Age: 20, Id: 2},
{Name: "Jack", Age: 25, Id: 3}
];
class userManager {
constructor() {
this.getById = (id, callback) => {
let result = users.find( (u) => u.Id == id );
@asduser
asduser / TypeScript_sample.js
Created March 16, 2016 20:24
TypeScript sample.
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
// Enumeration to define a Person gender.
var Gender;
(function (Gender) {
Gender[Gender["Male"] = 0] = "Male";
Gender[Gender["Female"] = 1] = "Female";