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 { 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 |
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
<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> |
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
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) |
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
package main | |
import "fmt" | |
// Constant definitions | |
const MaxUint = ^uint(0) | |
const MinUint = 0 | |
const MaxInt = int(^uint(0) >> 1) | |
const MinInt = -MaxInt - 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
// 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 ); | |
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
#!/usr/bin/env python | |
import argparse | |
import sys | |
import os | |
from datetime import datetime | |
from os import path | |
import pprint | |
from urllib3 import connection |
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 {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()'}, |
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
/** | |
* 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: |
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
package middleware | |
import ( | |
"bufio" | |
"bytes" | |
"fmt" | |
"net/http" | |
"net/http/httptest" | |
"os" | |
"strings" |
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
package main | |
import ( | |
"fmt" | |
"io" | |
"net" | |
"time" | |
) | |
func main() { |