Skip to content

Instantly share code, notes, and snippets.

View akolybelnikov's full-sized avatar
:octocat:
Building the future, one line of code at a time. 🚀

reddree akolybelnikov

:octocat:
Building the future, one line of code at a time. 🚀
View GitHub Profile
import { AfterViewInit, Directive, ElementRef, EventEmitter, forwardRef, Inject, Injectable, InjectionToken, Injector, Input, NgZone, OnInit, Output } from '@angular/core';
import { AbstractControl, ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR, NgControl, Validators } from '@angular/forms';
import { Http } from '@angular/http';
declare const grecaptcha : any;
declare global {
interface Window {
grecaptcha : any;
reCaptchaLoad : () => void
@arniebradfo
arniebradfo / any.component.html
Last active October 22, 2024 18:40
Angular *ngFor recursive list tree template
<h1>Angular 2 Recursive List</h1>
<ul>
<ng-template #recursiveList let-list>
<li *ngFor="let item of list">
{{item.title}}
<ul *ngIf="item.children.length > 0">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container>
</ul>
</li>
</ng-template>
@dhunmoon
dhunmoon / jsCSVFileCreationBlob.js
Created March 22, 2017 09:57
JS: CSV File Creation Using BLOB
function exportToCsv(filename, rows) {
var processRow = function (row) {
var finalVal = '';
for (var j = 0; j < row.length; j++) {
var innerValue = row[j] === null ? '' : row[j].toString();
if (row[j] instanceof Date) {
innerValue = row[j].toLocaleString();
};
var result = innerValue.replace(/"/g, '""');
if (result.search(/("|,|\n)/g) >= 0)
@petergloor
petergloor / main.go
Created January 25, 2017 13:00
MaxInt, MinInt, MaxUint and MinUint in Go (golang)
package main
import "fmt"
// Constant definitions
const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(^uint(0) >> 1)
const MinInt = -MaxInt - 1
@scottopolis
scottopolis / splice-object-array.js
Last active July 4, 2025 13:21
Remove object from array of objects in Javascript
// we have an array of objects, we want to remove one object using only the id property
const apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
// get index of object with id of 37
const removeIndex = apps.findIndex( item => item.id === 37 );
// remove object
apps.splice( removeIndex, 1 );
@rondomondo
rondomondo / rsa_sig_check.py
Last active December 22, 2022 14:40
Sign and Verify signature using a SSL certificate. I've been wanting to play around with various RSA signing methods. Particularly around JWT RSA signed tokens and verifying a sig using the public key extracted from a website certificate. Some of the nuances of it all can be a bit tricky. As part of my effort to get my head around it I cobbled t…
#!/usr/bin/env python
import argparse
import sys
import os
from datetime import datetime
from os import path
import pprint
from urllib3 import connection
@klinki
klinki / anguar2-select-changed-stuff.ts
Created December 9, 2016 10:07
Angular 2 select with custom comparator
import {Directive, Renderer, ElementRef, Input, OnDestroy, Optional, Host} from "@angular/core";
import {SelectMultipleControlValueAccessor} from "@angular/forms";
import {looseIdentical} from "@angular/core/src/facade/lang";
import {Comparator, ComparatorCallback, CUSTOM_SELECT_MULTIPLE_VALUE_ACCESSOR} from "./custom-select.directive";
// [formControlName],select[multiple][wu-select][formControl],select[multiple][wu-select][ngModel]
@Directive({
selector: 'select[multiple][wu-select]',
host: {'(change)': 'onChange($event.target)', '(blur)': 'onTouched()'},
@mfukar
mfukar / terminate-worker-threads.c
Last active July 25, 2024 13:26
C11 code to have a POSIX multithreaded application which signal work completion via a condition variable, and then terminate.
/**
* Demonstration of a way to break out of a multi-threaded program with one "manager" thread and
* many "worker" threads.
* There is the assumption that the work being done is long-standing enough to guarantee that
* all threads have been created and are running prior to one of them completing its assigned work.
* If this is not the case, adjustments to this code have to be made. Better yet, implement and use
* a monitor / barrier.
* The primary use of this is to demonstrate usage of condition variable(s) and cancellation.
*
* IMPORTANT:
@mikattack
mikattack / logger_test.go
Created August 16, 2016 19:32
Example Go unit test for logging middleware
package middleware
import (
"bufio"
"bytes"
"fmt"
"net/http"
"net/http/httptest"
"os"
"strings"
@elico
elico / client.go
Created July 26, 2016 00:21
golang tcp client connection alive check
package main
import (
"fmt"
"io"
"net"
"time"
)
func main() {