This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Install] | |
WantedBy=multi-user.target | |
[Unit] | |
Description=Google Cloud Compute Engine SQL Proxy | |
Requires=networking.service | |
After=networking.service | |
[Service] | |
Type=simple |
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.
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.
- Replace
mysql2
gem withpg
inGemfile
. - Update
config/database.yml
for PostgreSQL. I used [Rails' template][2] as a starting point.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
service rsyslog stop | |
sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf | |
service rsyslog start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Speed things up by not loading Rails env | |
config.assets.initialize_on_precompile = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
NewerOlder