Skip to content

Instantly share code, notes, and snippets.

View jyunderwood's full-sized avatar

Jonathan Underwood jyunderwood

View GitHub Profile
@jyunderwood
jyunderwood / nginx.conf
Created April 1, 2013 21:07
Serving PHP with Nginx and PHP-FPM
server {
listen 80;
server_name example.com;
root /home/deploy/apps/example.com/public;
index index.html index.php;
client_max_body_size 1G;
fastcgi_buffers 64 4K;
location / {
##
# Will keep all passed in attributes in the `attributes` attribute
# But will allow you to pull out certain attributes that you want as
# getters and setters. Great for accessing with `random_object.some`
#
class RandomObject
WANTED_ATTRS = [:some, :attrs, :you, :want]
attr_accessor :attributes, *WANTED_ATTRS
---
- hosts: all
sudo: yes
tasks:
- name: "test for swap partition"
shell: 'sudo swapon -s | grep -E "^/"'
register: swapfile
ignore_errors: yes
@jyunderwood
jyunderwood / transmission.sh
Created March 11, 2015 13:38
Set Transmission.app preferences on OS X
#!/usr/bin/env bash
# Use `~/Downloads` to store incomplete downloads
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads"
# Do not prompt for confirmation before downloading
defaults write org.m0k.transmission DownloadAsk -bool false
# Trash original torrent files
@jyunderwood
jyunderwood / mboxdiff.py
Last active August 29, 2015 14:23
mboxdiff.py
import mailbox
# Open the mbox files (relative to your present working directory)
# Note, Mail.app actually exports a mbox folder that contains an mbox file
mbox1 = mailbox.mbox('Old-Archive.mbox/mbox')
mbox2 = mailbox.mbox('New-Archive.mbox/mbox')
# Use something like `subject` to unique the messages
# or they will all be unique.
def subjects(mbox):
require 'base64'
require 'open-uri'
require 'net/http'
require 'net/https'
require 'json'
class OCR
attr_reader :api_key, :image_url
def self.scan(api_key:, image_url:)
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
using CRMProject.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
namespace Infrastructure.Data
{
public class AppDbContext : DbContext
{
public DbSet<Contact> Contacts { get; set; }
@jyunderwood
jyunderwood / Program.cs
Created June 18, 2018 14:48
SCP and Email a file
using Renci.SshNet;
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.IO;
using System.Linq;
namespace PlayBall
{
internal class Program
@jyunderwood
jyunderwood / letsencrypt.conf
Created January 21, 2020 14:48
Certbot + redirects
# /etc/nginx/snippets/letsencrypt.conf
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /srv/www/letsencrypt;
}
# Hide /acme-challenge subdirectory and return 404 on all requests.
location = /.well-known/acme-challenge/ {
return 404;