Skip to content

Instantly share code, notes, and snippets.

View atinder's full-sized avatar

Atinder Singh atinder

View GitHub Profile
@atinder
atinder / rails-jsonb-queries
Created July 23, 2023 07:47 — forked from mankind/rails-jsonb-queries
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")
{
"Type" : "SubscriptionConfirmation",
"MessageId" : "0941b7b3-4797-44e5-8079-dbf8ef09793f",
"Token" : "2336412f37fb687f5d51e6e241d164b0533302ec696efc8f113cd2252ce8a925c1e44a3c4ca2984675da85b9bd8c05da85337beb1f24a9c659b22ed3a8cc682f3457c4ead28d392a40e5c35c0e9>
"TopicArn" : "arn:aws:sns:us-west-2:164053224164:email-list",
"Message" : "You have chosen to subscribe to the topic arn:aws:sns:us-west-2:164053224164:email-list.\nTo confirm the subscription, visit the SubscribeURL included in this message",
"SubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-west-2:164053224164:email-list&Token=REDACTED",
"Timestamp" : "2013-10-05T17:00:04.135Z",
"SignatureVersion" : "1",
"Signature" : "<REDACTED>"
@atinder
atinder / gist:b39ff15e2b379aa68a13228628722dd0
Created September 27, 2018 15:24 — forked from jtperreault/gist:5161942
This is the service script for Nginx installed to /opt/ by the Phusion Passenger gem. This script should reside in /etc/init.d/ and is invoked to manage the nginx process from the command line like so: $ service nginx restart
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@atinder
atinder / curried.es5.js
Last active June 15, 2017 05:41 — forked from ryanseddon/curried.es5.js
ES5 vs ES6 function currying
function curry(fn) {
var args = [].slice.call(arguments, 1);
function curried(fnArgs) {
if (fnArgs.length >= fn.length) {
return func.apply(null, fnArgs);
}
return function () {
return curried(fnArgs.concat([].slice.apply(arguments)));
@atinder
atinder / simple-capistrano-docker-deploy.rb
Created October 20, 2015 18:36 — forked from johnbintz/simple-capistrano-docker-deploy.rb
Simple Capistrano deploy for a Docker-managed app
# be sure to comment out the require 'capistrano/deploy' line in your Capfile!
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'my-cool-application'
# the base docker repo reference
set :name, "johns-stuff/#{fetch(:application)}"
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
{{-- Define all our servers --}}
@servers(['staging' => '', 'production' => ''])
@setup
{{-- The timezone your servers run in --}}
$timezone = 'Europe/Amsterdam';
{{-- The base path where your deployments are sitting --}}
$path = '/var/www/site.com/htdocs';
@atinder
atinder / .bowerrc
Last active August 29, 2015 14:15 — forked from ericlbarnes/.bowerrc
{
"directory": "vendor/bower_components"
}
@atinder
atinder / wp.sh
Last active August 29, 2015 14:06 — forked from samface/wp.sh
#!/bin/bash
# Exit this bash script if any statement returns a non-true return value (same as: set -e)
set -o errexit
if [ -z "$1" ]; then
echo
echo "ERROR: Must pass parameter of absolute or relative path to directory where Wordpress is to be installed."
echo "USAGE: $0 path/to/public/html/dir"
echo
<?php
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
class ViewsCommand extends Command {
/**
* The console command name.
*
* @var string