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)));
add this before
<!--.social-media-->
<?php if($at_options['pinterest'] != '') {?><li class="tt" data-toggle="tooltip" data-container="body" data-placement="left" title="<?php _e('Find us on Pinterest','at'); ?>"><a href="<?php echo $at_options['pinterest']; ?>" class="icon-pinterest"></a></li><?php } ?>
and in inc/theme-options.php
add this
@atinder
atinder / gist:6279189
Last active December 21, 2015 08:38
BIR single-portfolio.php
<?php
global $at_options;
get_header(); ?>
<?php
if(have_posts()) : while(have_posts()) : the_post();
$page_meta = get_post_meta($post->ID,'page_meta',true);
$portfolio_meta = get_post_meta($post->ID,'portfolio_meta',true);
$images = get_post_meta($post->ID,'portfolio_images',true);
@atinder
atinder / deploy.rb
Created August 19, 2013 06:07 — forked from chipotle/deploy.rb
# Capistrano Laravel 4 Deployment Tasks
# Watts Martin (layotl at gmail com)
# https://gist.github.com/chipotle/5506641
# updated 14-Aug-2013
# Assumptions:
#
# - You are using a .gitignore similar to Laravel's default, so your
# vendor directory and composer(.phar) are *not* under version control
# - Composer is installed as an executable at /usr/local/bin/composer
@atinder
atinder / gist:5310153
Created April 4, 2013 12:59
alveera shortcodes updated
<?php
if ( !function_exists('at_remove_autop') ) {
function at_remove_autop($content) {
$content = do_shortcode( shortcode_unautop($content) );
$content = preg_replace( '#^<\/p>|^<br \/>|<p>$#', '', $content );
return $content;
}
@atinder
atinder / cleanography-widgets
Created March 31, 2013 03:26
cleanography widgets updated
<?php
/**** WIDGETS AREA ****/
/* *****************************************************
* Plugin Name: Cleanography Recent Posts
* Description: Display Recent Posts with Thumbs.
* Version: 1.0
* Author: Atinder
* Author URI: http://www.atinder.com
@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)}"