Skip to content

Instantly share code, notes, and snippets.

View davidhenley's full-sized avatar

David Henley davidhenley

  • Best Brands Inc.
  • Nashville, TN
View GitHub Profile
@davidhenley
davidhenley / angular-hooks.ts
Last active September 10, 2019 21:37
Angular Hooks
import { Component } from '@angular/core';
@Component({
selector: 'hooks-example',
template: `
<p>You clicked {{count}} times</p>
<button (click)="setCount(count + 1)">Click Me</button>
`
})
export class HooksComponent {
@miguelmota
miguelmota / setup.config
Last active July 26, 2021 15:42
Elastic Beanstalk NGINX rewrite http to https using .ebextensions
files:
"/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf":
mode: "000755"
owner: root
group: root
content: |
server {
listen 80;
gzip on;
@livimonte
livimonte / box-min-height-100.html
Last active March 28, 2022 23:30
Take 100% height of inner div with min-height in the container. Crossbrowser, only html and css.
<!DOCTYPE html>
<head>
<style>
.main {
overflow:hidden;
border:#000 1px solid;
width:450px;
position: relative;
min-height: 50px;
@fdidron
fdidron / App.js
Last active April 11, 2023 13:54
React Router v4 Auth
//Usage
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import Route from './AuthRoute';
import Login from './Login';
import Private from './Private';
export default () =>
<Router>
@hallidev
hallidev / gist:300c50fa1bab3a44c3ee2fcb45c6eb1e
Created December 5, 2019 15:47
Emit MediatR Events to EventGrid
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MyApp.AppServices.Configuration;
using MyApp.AppServices.EventBus.Command;
using MyApp.AppServices.Model.EventGrid;
using Framework.EventBus.Command;
using Framework.Model;
@adamreisnz
adamreisnz / package.json
Last active January 19, 2024 13:01
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",
@bdcravens
bdcravens / add-timestamps.sql
Created December 19, 2012 21:32
SQL Server - add createdAt and updatedAt columns, automatically updates
ALTER TABLE myTable
add createdAt datetime
CONSTRAINT DF_myTable_createdat DEFAULT GETDATE()
ALTER TABLE myTable
add updatedAt datetime
CONSTRAINT DF_myTable_updatedAt DEFAULT GETDATE()
go
@joepie91
joepie91 / random.md
Last active May 5, 2024 06:33
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@davidfowl
davidfowl / dotnetlayout.md
Last active May 5, 2024 11:47
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {