Skip to content

Instantly share code, notes, and snippets.

@amitverma2196
amitverma2196 / Apple push notification
Created November 2, 2018 10:55 — forked from netoxico/Apple push notification
Apple push notification with python
#!/usr/bin/env python
import ssl
import json
import socket
import struct
import binascii
def send_push_message(token, payload):
# the certificate file generated from Provisioning Portal
@amitverma2196
amitverma2196 / aggregation_lookup.md
Created August 13, 2018 07:43 — forked from bertrandmartel/aggregation_lookup.md
MongoDB $lookup aggregation example

MongoDB $lookup aggregation

SO link

db.votes.aggregate([{
    $lookup: {
        from: "users",
        localField: "createdBy",
        foreignField: "_id",
@amitverma2196
amitverma2196 / memory_usage.py
Created June 28, 2018 11:33 — forked from ds7711/memory_usage.py
measure the memory usage by a function
def measure_memory_usage(target_call, target_args, log_filename=None, memory_denominator=1024.0**2, memory_usage_refresh=0.005):
"""
measure the memory usage of a function call in python.\n
Note: one may have to restart python to get accurate results.\n
:param target_call: function to be tested\n
:param target_args: arguments of the function in a tuple\n
:param memory_usage_refresh: how frequent the memory is measured, default to 0.005 seconds\n
:return: max memory usage in kB (on Linux/Ubuntu 14.04), may depend on OS
"""
import time
@amitverma2196
amitverma2196 / Install_mongify_ubuntu.md
Created June 6, 2018 09:56 — forked from Lazhari/Install_mongify_ubuntu.md
Installing mongify on Ubuntu 16.04 server

Installing mongify on Ubuntu 16.04 server

  1. Install Ruby dev
$ sudo apt-get install ruby-dev
  1. Install dependencies
@amitverma2196
amitverma2196 / new_task.py
Created May 21, 2018 06:42 — forked from reedsa/new_task.py
RabbitMQ Retry using Dead Letter Exchange in Python/Pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
@amitverma2196
amitverma2196 / new_task.py
Created May 21, 2018 06:42 — forked from quiver/new_task.py
rabbitmq : dead letter exchange example with python/pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
@amitverma2196
amitverma2196 / git-deployment.md
Created April 21, 2018 07:11 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@amitverma2196
amitverma2196 / Git push deployment in 7 easy steps.md
Created April 21, 2018 07:10 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@amitverma2196
amitverma2196 / stargate.class.php
Created February 13, 2018 05:26 — forked from AMSTKO/stargate.class.php
Connect to Hbase Stargate server with PHP
<?php
/**
* @name Connect to Hbase Stargate server with PHP
* @author Mr.Ping (Jonathan)
*/
class hbase_stargate {
@amitverma2196
amitverma2196 / 0_urllib2.py
Created February 6, 2018 07:35 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()