Skip to content

Instantly share code, notes, and snippets.

Munish Kapoor manishkpr

Block or report user

Report or block manishkpr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@manishkpr
manishkpr / BackPress.java
Last active Aug 31, 2019
Android - handle back press in Fragment More Details Visit: http://manishkpr.webheavens.com
View BackPress.java
This article describes how our FragmentBack works under the hood.
BaseFragment
First step to create back-sensitive fragments is to define interface that we can call to notify particular fragments about back-press. It contains only one method onBackPressed() which returns a value that indicates if back-press event was consumed by the fragment.
In this example we use base class, but you can define it via interface as well.
public class BaseFragment extends Fragment {
/**
* Could handle back press.
@manishkpr
manishkpr / postgres_index_foreign_keys.md
Last active Feb 21, 2019
POSTGRESQL: INDEXES AND FOREIGN KEYS
View postgres_index_foreign_keys.md

Step 1:

CREATE TABLE a (
    a_id int PRIMARY KEY
);

Step 2:

CREATE TABLE b (
@manishkpr
manishkpr / osx-kong.sh
Created Jun 12, 2018 — forked from sepehr/osx-kong.sh
OSX: Kong Installation
View osx-kong.sh
#!/bin/bash
#
# The homebrew formula of kong has a lot of version incompatibilities. So
# we install kong directly from Luarocks.
#
# Kong only works with Cassandra 2.1.x/2.2.x, the latest brew formula for
# cassandra is 3.x. We need to tap homebrew/versions and install cassandra22
# instead.
#
@manishkpr
manishkpr / server_certificates_to_pem.md
Created Apr 23, 2018 — forked from stevenhaddox/server_certificates_to_pem.md
Convert .crt & .key files into .pem file for HTTParty
View server_certificates_to_pem.md

Two ways to do it, but only worked for me so I'll put it first and the second for reference:

$ openssl pkcs12 -export -in hostname.crt -inkey hsotname.key -out hostname.p12
$ openssl pkcs12 -in hostname.p12 -nodes -out hostname.pem

Other options for this method in comments below:

# Note, the -certfile root.crt appends all CA certs to the export, I've never needed these so it's optional for my personal steps
$ openssl pkcs12 -export -in hostname.crt -inkey hsotname.key -certfile root.crt -out hostname.p12
# Note, I've always had my hostname.crt as part of my .pem, so I keep my certs but apparently you may not have to, hence the nocerts flag being an extra option in this sample
View ruby_1.9.3.sh
#!/usr/bin/env bash
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libxml2-dev libxslt-dev libreadline6-dev libyaml-dev
# apt-get -y install libmysqlclient-dev # uncomment for mysql support
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p286.tar.gz
tar -xvzf ruby-1.9.3-p286.tar.gz
cd ruby-1.9.3-p286/
./configure --prefix=/usr/local
sudo make
@manishkpr
manishkpr / phalcon_aws_sdk.text
Created Aug 10, 2017
Hang the Amazon AWS SDK in Phalcon PHP
View phalcon_aws_sdk.text
AWS SDK uses a lot of third-party libraries and Framework, so the namespace to manually handle the words will be more trouble, I suggest using Composer to deal with these things, it uses spl_autoload to deal with, so the class will be used in the time to load, Fast and concise.
Under the project put composer.json, the content is
{
"require": {
"aws/aws-sdk-php": "dev-master"
}
}
Download composer.phar placed under the project
wget http://getcomposer.org/composer.phar
View async_waterfall_example.js
var async = require('async');
async.waterfall(
[
function(callback) {
callback(null, 'Yes', 'it');
},
function(arg1, arg2, callback) {
var caption = arg1 +' and '+ arg2;
callback(null, caption);
@manishkpr
manishkpr / Foreground.java
Created Feb 28, 2017 — forked from steveliles/Foreground.java
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
View Foreground.java
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;
@manishkpr
manishkpr / CustomSnackbar.java
Created Feb 6, 2017 — forked from raphaelbussa/CustomSnackbar.java
Helper for inflate custom layout in google support design snackbar
View CustomSnackbar.java
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Raphaël Bussa
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
View depn.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
You can’t perform that action at this time.