Skip to content

Instantly share code, notes, and snippets.

Avatar

Sundar Rajagopalan happysundar

View GitHub Profile
View create_rpm_using_fpm.md

fpm -s dir -t rpm -C /build -a all --verbose --no-depends --provides email-insights.jar -n email-insights -v 1.0.4 --prefix /opt/idp/email-insights email-insights.jar

View docker_commands.md

Creating an image

  1. Create a single Dockerfile in ~/dockerfile/Dockerfile
FROM centos
VOLUME /Users/sundar.rajagopalan/Downloads
VOLUME /Users/sundar.rajagopalan/docker-dir
RUN ["useradd", "builder"]
RUN ["yum", "install", "rpm-build", "-y"]
@happysundar
happysundar / setup.py
Created May 11, 2016
Sample setup.py
View setup.py
# $ virtualenv venv
# $ . venv/bin/activate
# $ pip install --editable
from setuptools import setup
setup(
name='repl_domstore',
version='0.1',
py_modules=['repl_domstore'],
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@happysundar
happysundar / LogstashAppender.java
Created Apr 12, 2015
Logstash appender for dropwizard : this generates a logstash compatible log file that can be synced using the logstash-forwarder
View LogstashAppender.java
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.Layout;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.dropwizard.logging.FileAppenderFactory;
import net.logstash.logback.encoder.LogstashEncoder;
@happysundar
happysundar / cleanup_schemas.sql
Created Oct 23, 2014
posgresql function to cleanup the schemas within a database
View cleanup_schemas.sql
DROP FUNCTION IF EXISTS cleanup( ) CASCADE;
CREATE OR REPLACE FUNCTION
cleanup()
RETURNS VOID
AS $$
DECLARE
row RECORD ;
BEGIN
FOR row IN WITH T1 AS (SELECT nspname :: TEXT AS schema_name
FROM pg_catalog.pg_namespace), T2 AS (SELECT schema_name
@happysundar
happysundar / get_column_names
Created Oct 19, 2014
Get all the column names of a table...
View get_column_names
DROP FUNCTION IF EXISTS get_column_names_csv( TEXT, TEXT ) CASCADE;
CREATE OR REPLACE FUNCTION
get_column_names_csv(input_schema_name TEXT, input_table_name TEXT)
RETURNS SETOF TEXT IMMUTABLE
AS $$
BEGIN
RETURN QUERY
WITH T1 AS (
SELECT column_name
FROM rovi.information_schema.columns
@happysundar
happysundar / plpython_returning_record.py
Last active Aug 7, 2020
Example of a PLPythonU method that returns a record
View plpython_returning_record.py
DROP FUNCTION IF EXISTS get_role_to_actor_and_actor_to_role( INOUT BIGINT, OUT JSONB, OUT JSONB );
CREATE OR REPLACE FUNCTION get_role_to_actor_and_actor_to_role(
INOUT program_id BIGINT,
OUT actor_to_role JSONB,
OUT role_to_actor JSONB)
RETURNS RECORD IMMUTABLE
AS $plpython_function$
import json
@happysundar
happysundar / JSONB to array
Created Aug 22, 2014
how to extract an array out of JSONB in postgres
View JSONB to array
select array_agg(value) from jsonb_each_text('{"3d": "2011-05-20", "wide": "2011-05-20", "imax_3d": "2011-05-20"}'::jsonb);
@happysundar
happysundar / install_python.yaml
Created Aug 7, 2014
playbook to get virtualenv + pythoz installed in a Centos box
View install_python.yaml
---
- hosts: all
sudo: yes
tasks:
- name: install the EPEL and remi repos
yum: name={{item}}
state=installed
with_items:
- http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- http://rpms.famillecollet.com/enterprise/remi-release-6.rpm