Binary patched by using various algorithm :

bsdiff:

To install : sudo apt-get install bsdiff
Create Patch : bsdiff old_version_file new_version_file delta_file.bsdiff
Apply Patch : bspatch old_version_fil newfile delta_file.bsdiff
Example by using text file :
bsdiff dog.txt hen.txt hd.diff
bspatch hen.txt dog1.txt hd.diff

xdelta:

To install : sudo apt-get install xdelta3
Create Patch : xdelta3 -9 -S lzma -e -f -s old_version_file new_version_file xdelta_file
Apply Patch : xdelta3 -dfs old_version_file xdelta_file newfile
Example by using text file :
xdelta3 -9 -S lzma -e -f -s dog.txt hen.txt hd.delta
xdelta3 -dfs dog.txt hd.delta dog.txt

How to verify the content after patch using kdiff3:
hexdump old_version_file > myfile1.hex
hexdump new_version_file delta > myfile2.hex
kdiff3 myfile1.hex myfile2.hex : Here we can see the difference
hexdump newfile > myfile3.hex
kdiff3 myfile2.hex myfile2.hex : Here we can see no difference

 

Note: Tried using Ubuntu OS.

jQuery by Gurudath BN

jQuery Introduction

jQuery is a lightweight, “write less, do more”, JavaScript library.

The purpose of jQuery is to make it much easier to use JavaScript on your website.

jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.

The jQuery library contains the following features:

  1. HTML/DOM manipulation  
  2. CSS manipulation  
  3. HTML event methods  
  4. Effects and animations  
  5. AJAX  
  6. Utilities


The jQuery library is a single JavaScript file, and you reference to it using the HTML

<head>http://jquery.js</head>

There are two versions of jQuery available for downloading:  

  1. Production version : ­ This is for your live website because it has been minified and compressed .
  1. Development version :  This is for testing and development (uncompressed and readable code) .

Video link :- https://youtu.be/0FBRtM_azq0

Next post  will be soon. 

 

Animations using jQuery

animation-jquery-css
animation-jquery-css

The jQuery animate() method is used to create custom animations.

Syntax:

$(selector).animate({params},speed,callback);

params :- defines the CSS properties to be animated.
speed :- specifies the duration of the effect. It can take the following values: “slow”, “fast”, or milliseconds.
callback :- function to be executed after the animation completes.

animation Jquery

Example:

$(“button”).click(function(){
     $(“span”).animate({
        left: ‘250px’,
       opacity: ‘0.5’
    });
});

Using Relative Values

It is also possible to define relative values (the value is then relative to the element’s current value). This is done by putting += or -= in front of the value :

$(“button”).click(function(){
     $(“span”).animate({
        left: ‘250px’,
        height: ‘+=150px’
     });
});

Uses Queue Functionality

jQuery comes with queue functionality for animations.Which means that multiple animate() calls after each other, jQuery creates an “internal” queue with these method calls. Then it runs the animate calls ONE by ONE.

So, if you want to perform different animations after each other, we take advantage of the queue functionality:

$(“button”).click(function(){
       var span = $(“span”);
       span.animate({height: ‘300px’, opacity: ‘0.4’}, “slow”);
       span.animate({width: ‘300px’, opacity: ‘0.8’}, “slow”);
       span.animate({height: ‘100px’, opacity: ‘0.4’}, “slow”);
       span.animate({width: ‘100px’, opacity: ‘0.8’}, “slow”);
});

A sample example of using jQuery animation:

http://animation-jquery-css.bitballoon.com/

Jquery highlight search text plugin Gsearch on the webpage in a easy way.

hightlight search text jquery

Tiny, fast jQuery plugin to search text through elements as you type. This plugin is created and maintained by Gurudath BN ( Github ).

Features :-

  1. Lightweight. This plugin is only ~3.8kB minified and gzipped!
  2. Fast. This plugin is optimized for fast, lagless searching even through large element sets.
  3. Search types. This plugin provides search text ! Fuzzy matching, case insensitive also.
  4. Custom show/hide. You can define custom functions for showing and hiding the elements while searching.
  5. Provide a icon on hover textfield appear to search text , so it wont occupy space on page.
  6. Search anything. This plugin isn’t restricted to use on tables, any set of elements that has ‘rows’ with ‘columns’ inside them can be used.

Demo :-

Click here to view a demo of this plugin in action

https://jsfiddle.net/gurudath/k197zu3a/7/

Getting started :-

Basic usage  :-
U can know the basic workflow using the github url:-  https://github.com/gurudath/Gsearch

Git Path :- https://github.com/gurudath/Gsearch.git

Example usage :-

This example uses the configurations shown above to customize the plugin:

$(document).ready(function () {

       $(‘#update_stiky_search’).GSearch({

            update_at: ‘update_stiky_search’,

            margin_top: ‘100px’,

            background_color: ‘#01A9DB’,

            highlight_class: ‘highlight’,

            content_main: $(‘.main-content’)

        });

});

Sidekiq Vs Delayed Job Comparison

delayedjob_sidekiq
delayedjob_sidekiq

Features

Delayed Job

SideKiq

Storage SQL database Redis
Jobs Processing Single-threaded process Multi-threaded process
Set-up Simple Easy to setup, but need redis also to be installed
Scalability Aren’t great More efficient in terms of raw processing speed
Systems Processing Would not use for systems processing 100,000s of jobs/day Largest customers are processing 500,000 jobs/min(Reference link)
Process Mechanism Queue Thread
Clock Process Availability Available as package which install both delayed job and (delayed_job_recurring Gem) Available as package which install both SIdekiq and sidekiq-cron Gem
Active Job Compatibility Available Available
Total Gems Needed delayed_job_recurring,daemons sidekiq-cron,sinatra,slim
GUI Support No Yes ( We can restrict user to view GUI by USER PRIVILEGE)
Extender Pro Version For More Features No Yes

Active Job , Sidekiq And Redis In Rails 4

activejob_sidekiq
activejob_sidekiq

Active Job is a framework for declaring jobs and making them run on a variety of queueing backends. These jobs can be everything from regularly scheduled clean-ups, to billing charges, to mailings. Anything that can be chopped up into small units of work and run in parallel, really.

Sidekiq simple, efficient background processing for Ruby. Sidekiq uses threads to handle many jobs at the same time in the same process. It does not require Rails but will integrate tightly with Rails 3/4 to make background processing dead simple.

Redis :-

Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperlog logs.

Other features include :-  

  1. Transactions
  2. Pub/Sub
  3. Lua scripting
  4. Keys with a limited time-to-live
  5. LRU eviction of keys
  6. Automatic failover

Installation :-

  1. wget http://download.redis.io/redis-stable.tar.gz
  2. tar xvzf redis-stable.tar.gz
  3. cd redis-stable
  4. make
  5. redis-server

Integrating Sidekiq with Rails :-

Gem file

  1. activejob_backport
  2. sidekiq-cron
  3. sinatra
  4. slim

application.rb

Add this line to configure the sidekiq

include Sidekiq::Worker

config/initializer/active_job_configuration.rb

ActiveJob::Base.queue_adapter = :sidekiq

config/sidekiq.yml

:concurrency: 25

:pidfile: ./tmp/pids/sidekiq.pid

:logfile: ./log/sidekiq.log

:queues:

– default

– [high_priority, 2]

 

config/routes.rb

require ‘sidekiq/web’

mount Sidekiq::Web, at: ‘/sidekiq’ , constraints: ->(request) {SideKiqConstraint.authenticate?(request)}

Note:- SideKiqConstraint.authenticate?(request) is the method which authenticate and ensure only user with role excelfore is able to see sidekiq GUI.

class SideKiqConstraint

def self.authenticate?(request)

if (!request.session[‘user_id’].blank? and !(user= User.find_by(id:request.session[‘user_id’])).blank?)

return user if user.excelfore?

end

end

end

Command to start sidekiq

In Development

sidekiq -C config/sidekiq.yml

In Production

bundle exec sidekiq -d -L sidekiq.log -q mailer,5 -q default -e production

The above steps ensure sidekiq to work background jobs. Now lets see the steps to setup sidekiq for the cron jobs.

config/schedule.yml

my_first_job:

 cron: “*/1 * * * *”

 class: “SidekiqClock1”

Add the below code in config/initializer/active_job_configuration.rb to load the jobs from the schedule.yml file

schedule_file=”config/schedule.yml”

if File.exists?(schedule_file)

Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)

end

Sample cron job method:-

class SidekiqClock1

include Sidekiq::Worker

def perform

ActionMailer::Base.mail(to: ‘gurudath@gurudath.com’ ,subject: ‘Process Completed’,body:’Gurudath Test’,from:”xbass@gurudath.com”).deliver

end

end