Skip to content

Instantly share code, notes, and snippets.

View johnchambers's full-sized avatar

John Chambers johnchambers

View GitHub Profile
<?
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
// License: MIT
//
@mankind
mankind / rails-jsonb-queries
Last active April 17, 2024 12:14
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
This gist is the update of this post https://u.osu.edu/hasnan.1/2014/03/30/rails-4-multiple-file-upload-with-carrierwave-nested-form-and-jquery-file-upload/
License MIT
@JamesDullaghan
JamesDullaghan / digitalocean.md
Created July 6, 2013 20:54
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@jmolivas
jmolivas / gist:3954344
Created October 25, 2012 18:00
Twig template code - Displaying flash messages using bootstrap
{# twig template #}
<div class="flash-messages">
{% block flashes %}
{% for notice_level in ['success','error','info', 'warning', 'notice'] %}
{% if app.session.hasFlash(notice_level) %}
<div class="alert alert-{{ notice_level }}">
<a class="close" data-dismiss="alert" href="#">x</a>
<h4 class="alert-heading">{{ notice_level }}</h4>
{{ app.session.flash(notice_level) }}
@coolaj86
coolaj86 / gist:2332953
Last active April 2, 2020 04:17
Dimensions for VistaPrint business cards
Standard
Bleed Margin: 90mm x 52mm
Content Ends: 87mm x 49mm
Imperial
Bleed Margin: 3.54in x 2.05in
Content Ends: 3.43in x 1.93in
@tomykaira
tomykaira / clockwork-init.sh
Created October 25, 2011 10:21
Create a new project with clockwork for heroku.
#!/bin/sh
# Licence: MIT
# Created by tomykaira, 2011-10-25
if [ $# -ne 1 ]; then
echo "Give me your new project name (only)"
exit 1
fi
@chrisbloom7
chrisbloom7 / README.md
Created June 6, 2011 07:16
A cheap knock off of the default validates_length_of validator, but checks the filesize of a Carrierwave attachment

Note that this validation runs both after the file is uploaded and after CarrierWave has processed the image. If your base uploader includes a filter to resize the image then the validation will be run against the resized image, not the original one that was uploaded. If this causes a problem for you, then you should avoid using a resizing filter on the base uploader and put any specific size requirements in a version instead.

So instead of this:

require 'carrierwave/processing/mini_magick'