Skip to content

Instantly share code, notes, and snippets.

View jdiamond's full-sized avatar

Jason Diamond jdiamond

  • 02:45 (UTC -08:00)
View GitHub Profile
@jdiamond
jdiamond / package.json
Created September 11, 2020 03:12
top-level await
{
"type": "module"
}
@jdiamond
jdiamond / Dockerfile
Created November 16, 2017 02:24
SSH certificates
FROM alpine
# Install OpenSSH:
RUN apk -U add openssh
# Generate host keys:
RUN ssh-keygen -A
# Create users:
RUN adduser -D user1
@jdiamond
jdiamond / notes.md
Created August 16, 2017 21:55
Testing React apps and components

"Injecting" configuration into a create-react-app is done with environmental variables. I always have at least one for the root of my REST API or GraphQL endpoint.

When running in development, I set that variable to point at a local version of the backend server I have running on my laptop. That's some other project that I do whatever I need to in order to get it running and available to accept requests from my React app.

If I wanted to start simple with static JSON files, maybe I would use something

@jdiamond
jdiamond / oui.md
Last active November 15, 2016 21:32
systemd OUI service

This unit file changes the OUI in the MAC addresses for enabled interfaces. It leaves the remaining bytes as is.

Copy [email protected] to /etc/systemd/system.

Enable it for each interface like this:

sudo systemctl enable oui@eth0
sudo systemctl enable oui@wlan0
@jdiamond
jdiamond / swap.sh
Created June 2, 2015 17:49
Enable swapfile on Ubuntu
# create the swapfile:
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
# enable it:
swapon /swapfile
sysctl vm.swappiness=10
sysctl vm.vfs_cache_pressure=50
@jdiamond
jdiamond / memory.js
Last active August 29, 2015 14:19
Watch memory and dump heaps in Node.js
function startWatchingMemory() {
if (process.env.MEMWATCH) {
var memwatch = require('memwatch-next');
var heapdump = process.env.HEAPDUMP && require('heapdump');
var hd = null;
memwatch.on('leak', function(info) {
log(info);
@jdiamond
jdiamond / Vagrantfile
Created August 11, 2014 17:39
Yeoman Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
INSTALL_NODE = <<SCRIPT
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -y nodejs
var arr1 = [ { name: 'Nikki' }, { name: 'Jason' }, { name: 'Thanh' } ];
var arr2 = [ { name: 'Nikki' }, { name: 'Thanh' } ];
var index = {};
arr1.forEach(function(item) {
index[item.name] = item;
});
console.log(index);
@jdiamond
jdiamond / require-mustache.js
Created May 2, 2013 02:31
RequireJS Mustache plugin
define([ 'text', 'mustache' ], function(text, Mustache) {
return {
load: function(name, require, callback, config) {
text.load(name, require, function(text) {
callback(Mustache.compile(text));
}, config);
}
};
});

Your original example:

public virtual List<UserDC> GetAllActiveAgentsByReason(int reasonID)
{
    try
    {
        if (reasonID < 0)
        {
 throw new ArgumentException("An invalid reasonID was passed.");