Skip to content

Instantly share code, notes, and snippets.

View 8parth's full-sized avatar

Parth Modi 8parth

View GitHub Profile
@8parth
8parth / git-clear_merged.sh
Created May 7, 2018 05:48
git and heroku helper scripts
#!/bin/sh
cd $PWD
echo $1
if [ -d .git ]; then
if [ -z "$1" ]; then
echo "checking out $(git symbolic-ref --short -q HEAD) ..."
# Add UbuntuGIS-unstable repository and update packages:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt update
# Install PostGIS:
sudo apt install postgis postgresql-9.6-postgis-2.3
# frozen_string_literal: true
class DynamoDBConfig
include Singleton
attr_reader :client, :configs
def initialize
@configs ||= {
access_key_id: Rails.application.secrets.aws_access_key_id,
@8parth
8parth / presentations.html
Created June 14, 2017 05:09
layout for iterating over presentations
---
layout: page
title: Presentations
---
<div class="posts">
{% for presentation in site.presentations %}
<li>
<a href="{{ site.baseurl }}{{ presentation.url }}">
{{ post.title }}
</a>
<head>
<link href="http://gmpg.org/xfn/11" rel="profile">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!-- Enable responsiveness on mobile devices-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>
@8parth
8parth / slide.html
Last active June 12, 2017 18:23
Slide layout for reveal js, inspired from https://gist.github.com/luugiathuy/c07ac5608addadb642e5
<!DOCTYPE html>
<html lang="en-us">
{% include presentations-head.html %}
<body>
<div class="reveal">
<div class="slides">
{{ content }}
</div>
</div>
@8parth
8parth / aws_configs.rb
Last active August 9, 2017 06:52
pagination with dynamodb
# frozen_string_literal: true
class AWSConfigs
include Singleton
attr_reader :ddb_client, :sqs_client, :iot_client, :configs, :ddb_configs
def initialize
@configs ||= {
access_key_id: Rails.application.secrets.aws_access_key_id,
@8parth
8parth / example-mqtt.conf
Created April 6, 2017 05:27
Mosquitto config file example
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
@8parth
8parth / attribute-api-example.rb
Last active March 29, 2017 17:07
Rails 5 Attributes API
class User < ApplicationRecord
# rails 4 way of defining virtual attribute
attr_accessor :full_name
# new rails 5 way of defining virtual attributes with datatype and default values
attribute :name, :string, default: -> { "No Name" }
attribute :age, :float, default: 99
before_save :assign_name
before_save :assign_full_name
@8parth
8parth / Song.rb
Created March 23, 2017 10:59
Example of has_many with dynamodb
class Song
include ActiveModel::Model, ActiveModel::Serialization
attr_accessor :name
attr_accessor :movie_ids
attr_accessor :created_at
attr_accessor :updated_at
def self.migrate_table
migration = Aws::Record::TableMigration.new(self)