This file contains 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 { useState, useEffect, useCallback } from "react"; | |
const useSafeState = <T>(initialValue?: T): [T, (value: T) => void] => { | |
let mounted = true; | |
const [current, setCurrent] = useState(initialValue); | |
useEffect(() => () => (mounted = false), []); | |
const setter = useCallback((value: T) => mounted && setCurrent(value), [mounted]); | |
return [current, setter]; | |
} |
This file contains 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 { useState, useEffect, useCallback } from "react"; | |
const useSafeState = <T>(initialValue: T): [T, (value: T) => void] => { | |
let mounted = true; | |
const [current, setCurrent] = useState(initialValue); | |
useEffect(() => () => (mounted = false), []); | |
const setter = useCallback((value: T) => mounted && setCurrent(value), [mounted]); | |
return [current, setter]; | |
} |
This file contains 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
/** .vscode/launch.json */ | |
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Jest Tests", | |
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js", | |
"args": [ |
This file contains 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 abstract class Logger : IDisposable | |
{ | |
private LogVerbosity _verbosity; | |
private Queue<Action> _queue = new Queue<Action>(); | |
private ManualResetEvent _hasNewItems = new ManualResetEvent(false); | |
private ManualResetEvent _terminate = new ManualResetEvent(false); | |
private ManualResetEvent _waiting = new ManualResetEvent(false); | |
private Thread _loggingThread; | |
private static readonly Lazy<Logger> _lazyLog = new Lazy<Logger>(() => { |
This file contains 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 lr = require('tiny-lr'), | |
gulp = require('gulp'), | |
nib = require('nib'), | |
jade = require('gulp-jade'), | |
stylus = require('gulp-stylus'), | |
livereload = require('gulp-livereload'), | |
myth = require('gulp-myth'), | |
csso = require('gulp-csso'), | |
imagemin = require('gulp-imagemin'), | |
uglify = require('gulp-uglify'), |
This file contains 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
// ref: http://stackoverflow.com/a/1293163/2343 | |
// This will parse a delimited string into an array of | |
// arrays. The default delimiter is the comma, but this | |
// can be overriden in the second argument. | |
function CSVToArray( strData, strDelimiter ){ | |
// Check to see if the delimiter is defined. If not, | |
// then default to comma. | |
strDelimiter = (strDelimiter || ","); | |
// Create a regular expression to parse the CSV values. |
This file contains 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; | |
using System.Web; | |
using System.Web.Mvc; | |
using Microsoft.AspNet.Identity; | |
using Microsoft.AspNet.Identity.Owin; | |
namespace Common | |
{ | |
public class CustomAuthAttribute : AuthorizeAttribute |
This file contains 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.Diagnostics; | |
using System.Linq.Expressions; | |
using System.Net; | |
using System.Net.Http; | |
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Threading.Tasks; | |
using System.Web.Http.ModelBinding; |
NewerOlder