Skip to content

Instantly share code, notes, and snippets.

View joeswann's full-sized avatar

Joe Swann joeswann

View GitHub Profile
@employee451
employee451 / resolveSanityGraphqlReferences.ts
Last active May 7, 2024 10:17
Resolve references in Sanity data (GraphQL)
import { groq } from 'next-sanity' // Replace with another library if you don't use Next.JS
import { client } from './client' // Replace this with wherever you have set up your client
/**
* Resolves all unresolved references when fetching from the Sanity GraphQL API.
* There is no native way to do this, so we have to do it manually.
* @param data
*/
export const resolveSanityGraphqlReferences = async <T = unknown>(
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@goodwill
goodwill / cloud-sql-proxy.service
Last active December 15, 2023 06:37
Example Systemd file for starting cloud sql proxy at system start
[Install]
WantedBy=multi-user.target
[Unit]
Description=Google Cloud Compute Engine SQL Proxy
Requires=networking.service
After=networking.service
[Service]
Type=simple
@jarednorman
jarednorman / webpack-rails-1.markdown
Last active May 13, 2020 18:24
Webpack with Rails Part 1

Webpack with Rails Part 1

I don't like Sprockets, but it's the easiest and best choice for lots of Ruby on Rails projects. When looking for a better way to manage my JavaScript assets and an improved developer story, my current tool of choice is webpack. While I wish Rails supported drop-in asset pipelines the way that Phoenix does, it's not hard to use webpack with Rails.

@tristanm
tristanm / README.md
Last active May 13, 2024 06:16
Migrating a Rails project from MySQL to PostgreSQL

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
@dragolabs
dragolabs / ubunru-rsyslog-hack.sh
Last active August 18, 2017 16:35
Hack to repair 100% CPU load by rsyslog on ubuntu 12.04 in openvz
#!/bin/sh
service rsyslog stop
sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf
service rsyslog start
@basti
basti / application.rb
Last active March 1, 2021 10:42 — forked from keighl/application.rb
Local Rails 4 assets precompilation using Capistrano 3 and rsync
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@pelgrim
pelgrim / old_file_killer.rb
Created July 6, 2012 15:29
A Ruby script to delete files older than X days in a given directory.
#!/usr/bin/env ruby
# A Ruby script to delete files older than X days in a given directory. Pretty simple.
# Like this: file_control.rb /User/pelgrim/Documents '*.pdf' 7
# The command above you remove ALL your pdfs inside Documents older than SEVEN DAYS.
# Quickly written by pelgrim < guskald at gmail dot com >
unless ARGV.size == 3
puts "Usage: file_control <directory> <filename pattern> <max age>"
exit 1
@denmarkin
denmarkin / mysql.god.rb
Created May 10, 2011 07:45
God recipes examples for Rackspace Cloud (Ubuntu) with resque and php-cgi. Try any of them with "sudo god -c /path/to/config -D"
God.watch do |w|
w.name = "mysqld"
w.interval = 30.seconds # default
w.start = "service mysql start"
w.stop = "service mysql stop"
w.restart = "service mysql restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
w.pid_file = "/var/lib/mysql/hostname.pid"
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz