Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@swalkinshaw
swalkinshaw / README.md
Last active December 14, 2023 20:53
Secret Santa

Holiday Gift Exchange Problem

Description

A Holiday gift exchange is where a group of people are randomly assigned one other person in the group to buy a gift for. This person can be anyone else in the group except for themselves. Everyone should both give and receive a gift.

Design a program that reads a provided CSV file, performs the matching, and then prints out the matches. Assume that you may email the match to the person later, but focus on printing first.

The format of the CSV is name,email on each row.

@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@swalkinshaw
swalkinshaw / application.php
Created November 17, 2019 17:29
Trellis + Sentry
<?php
/**
* composer require sentry/sentry-sdk
*/
use Sentry;
Env::init();
// Bedrock application config...
if (env('SENTRY_DSN')) {
Sentry\init([
'dsn' => env('SENTRY_DSN'),
@swalkinshaw
swalkinshaw / gist:2695510
Created May 14, 2012 18:25
WordPress: Mandatory Excerpt
<?
function mandatory_excerpt($data) {
$excerpt = $data['post_excerpt'];
if (empty($excerpt)) {
if ($data['post_status'] === 'publish') {
add_filter('redirect_post_location', 'excerpt_error_message_redirect', '99');
}
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
ANSIBLE_PATH = '.' # path targeting Ansible directory (relative to Vagrantfile)
# Set Ansible roles_path relative to Ansible directory
ENV['ANSIBLE_ROLES_PATH'] = File.join(ANSIBLE_PATH, 'vendor', 'roles')
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'graphql', '1.10.10'
end
class BaseArgument < GraphQL::Schema::Argument
def initialize(*args, **kwargs, &block)
super(*args, prepare: method(:convert_id), **kwargs, &block)
<?php
if (!is_blog_installed()) { return; }
if ('http://' . $_SERVER['SERVER_NAME'] . '/wp' == get_option('home')) {
update_option('siteurl', 'http://' . $_SERVER['SERVER_NAME'] . '/wp');
update_option('home', 'http://' . $_SERVER['SERVER_NAME']);
update_option('upload_path', $_SERVER['DOCUMENT_ROOT'] . '/media');
update_option('upload_url_path', 'http://' . $_SERVER['SERVER_NAME'] . '/media');
update_option('permalink_structure', '/%postname%/');
}
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Custom tasks
require 'capistrano/composer'
require 'capistrano/npm'
const WHITELIST = [
'https://cdn.theathletic.com'
]
const ALLOW = { cancel: false };
const DENY = { cancel: true };
chrome.webRequest.onBeforeSendHeaders.addListener((req) => {
var cancel = null;
@swalkinshaw
swalkinshaw / site.yml
Last active June 15, 2018 15:37
Multiple sites on one box with bedrock-ansible
# this is group_vars/development
---
www_root: /srv/www
# Define your WordPress sites here
wordpress_sites:
- site_name: site1.dev
site_hosts:
- site1.dev