Skip to content

Instantly share code, notes, and snippets.

View cblunt's full-sized avatar
👨‍💻
Coding

Chris Blunt cblunt

👨‍💻
Coding
View GitHub Profile
@cblunt
cblunt / general-rails-app.dockerfile
Last active May 15, 2019 10:40
General Dockerfile for a Rails App
# /path/to/app/Dockerfile
FROM ruby:2.5-alpine
# Set local timezone
RUN apk add --update tzdata && \
cp /usr/share/zoneinfo/Europe/London /etc/localtime && \
echo "Europe/London" > /etc/timezone
# Install your app's runtime dependencies in the container
RUN apk add --update --virtual runtime-deps postgresql-client nodejs libffi-dev readline sqlite
@cblunt
cblunt / tag_list_issue.rb
Last active October 25, 2018 10:32
Bug when versioning tag_list using paper-trail (10.0) and acts as taggable on (6.0)
# frozen_string_literal: true
# Use this template to report PaperTrail bugs.
# Please include only the minimum code necessary to reproduce your issue.
require 'bundler/inline'
gemfile(true) do
ruby '2.5.3'
source 'https://rubygems.org'
gem 'activerecord', '5.2.1'
@cblunt
cblunt / docker-compose.1.yml
Last active August 7, 2018 12:54
Linking Containers across Multiple Docker Compose Projects
version: '3.2'
networks:
default:
external:
name: my_net # Needs to be manually created using docker network create
services:
nginx:
image: jwilder/nginx-proxy
@cblunt
cblunt / rails-docker-pg-template.rb
Last active April 1, 2020 11:40
A simple Rails application configured for PostgreSQL and Docker
route "root to: 'posts#index'"
generate :scaffold, 'post', 'title:string', 'body:text'
file 'config/database.yml', <<-CODE
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: db
@cblunt
cblunt / gulpfile.js
Created May 11, 2017 21:37
Gulpfile for simple static website prototyping
// $ npm install
// $ gulp serve
// $ open http://localhost:8080
var gulp = require('gulp'),
del = require('del'),
scss = require('gulp-sass'),
htmlmin = require('gulp-htmlmin'),
cleancss = require('gulp-clean-css'),
connect = require('gulp-connect'),
@cblunt
cblunt / model.rb
Created July 9, 2015 07:09
A tiny concern for generating a UUID for a model. Code heavily based off Rails' `has_secure_token` method
class Model < ActiveRecord::Base
include UuidConcern
# uuid attribute is `:uuid` by default. Optionally pass in attribute name, e.g `has_uuid :unique_token`
has_uuid
end
{
"message": "JSON Response OK",
"code": 200,
"images": [
{
"url": "http://assets.chrisblunt.com/wp-content/uploads/2012/12/IMG_20120619_202506-e1356946615784.jpg",
"title": "Hand Sunset"
},
{
"url": "http://assets.chrisblunt.com/wp-content/uploads/2010/01/PC280118.jpg",
class MainActivity extends Activity {
// mEntries in this case is just an ArrayList store
private ArrayList<String> mEntries;
// ...
// Fetch method
private void fetch(RequestQueue requestQueue) {
JsonArrayRequest request = new JsonArrayRequest("http://example.com/feed.json",
new Response.Listener<JSONArray>() {
@cblunt
cblunt / ProductsActivity.java
Created December 16, 2014 18:25
Parsing list of objects in JSON
public class ProductsActivity extends Activity {
// ...
// onCreate(), etc.
// ...
/**
* Assuming a JSON feed similar to:
* {
* "products": [
@cblunt
cblunt / build.gradle
Last active August 29, 2015 14:10
Gradle build file for Android app with volley
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.plymouthsoftware.android.volleyapp"
minSdkVersion 8
targetSdkVersion 21