Skip to content

Instantly share code, notes, and snippets.

View navneetgupta's full-sized avatar

Navneet Gupta navneetgupta

View GitHub Profile
@navneetgupta
navneetgupta / Using_Custom_XMPP_stanza_in_Ejabberd.md
Last active November 11, 2019 10:34
Create Custom Ejabberd XMPP elements as well as tools to work with them.

For Using Above created Custom xmpp element :

Two ways:

  1. Modify Dependencies of ejabberd to use your cloned xmpp repositories instead of provided one.
  2. Let's say u want to use those Custom xmpp Element in your module named my_custom_module.
    a. Add the generated files/modules (src/message_custom_module.erl) from above example to your ejabberd src directory.
    b. copy the type and record defination generated in xmpp_codec.hrl (use git diff to get the highlighted changes.) and put it in your include/my_custom_module.hrl (naming as per convention, could be anything else also, but as per best procatices.) in the ejabberd repository.
    c. In Your custom Module (my_custom_module.erl) include the -include("my_custom_module.hrl").
    d. Register the codecs module generated src/message_custom_module.erl in the module.
    i. To Register , In start(Host,Opts) of module add xmpp:register_codec(message_custom_module)
@navneetgupta
navneetgupta / Push_Notification.md
Last active October 8, 2019 08:17
Enable Push Notification in Ejabberd

WIP

XMPP-0357 Speciifcation

-- Feature <feature var='urn:xmpp:push:0'/> should be implemented.
-- Identity <identity category='pubsub' type='push' /> should be implemented.

Feature <feature var='urn:xmpp:push:0'/>

-- This feature enable following functionality: -- client can enable/disable the push notification.

@navneetgupta
navneetgupta / plaindrome.ex
Created September 8, 2018 14:35
Check Plaindrome
defmodule Plaindrome do
def is_plaindrome(x) when is_bitstring(x) do
x
|> String.reverse()
|> is_palindrome(x)
end
def is_plaindrome(x) when is_integer(x) do
x
@navneetgupta
navneetgupta / fibonacci.ex
Last active September 8, 2018 14:26
Print n Fibonacci
defmodule FibonacciCalc do
def fibonacci(x) when x <= 0, do: IO.puts "Enter a number greater than 0"
def fibonacci(x) do
calculate_fibonacci(x,1,1)
end
def calculate_fibonacci(x, first, _second ) when x == 1, do: IO.puts "#{first}"
def calculate_fibonacci(x, first, second ) do
@navneetgupta
navneetgupta / 00. tutorial.md
Created November 5, 2017 17:42 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler