Skip to content

Instantly share code, notes, and snippets.

View ParthBarot-BoTreeConsulting's full-sized avatar

Parth Barot ParthBarot-BoTreeConsulting

View GitHub Profile
.fc-time-grid .fc-event, .fc-time-grid .fc-bgevent {
position: relative;
width: 100%;
left: 0 !important;
right: 0 !important;
height: 40px;
margin-bottom: 2px;
}
var ShareCounter = {};
ShareCounter.Addthis = {
totalHttpShareCount: 0, //This is to store the http share counts received from Addthis
/*
** Following method gets the https share count generated by Addthis on the page elements.
*/
getCurrentHttpsCount: function(currentHttpsCountVal){
if(currentHttpsCountVal.length == 0 ||
(currentHttpsCountVal.length != 0 && !isNaN(Number(currentHttpsCountVal)))){
@ParthBarot-BoTreeConsulting
ParthBarot-BoTreeConsulting / js_refactor_final_version.js
Last active May 17, 2017 18:57
Javascript Refactoring - Nested conditions to readable code using recursion
// Final code
var MayApp = {};
MyApp.Base = {
data: {
rules: {
FirstSet:{
"0-12": {
"0-12000":{
"0-90" :{
fixedVal: 0.4
var MyApp = {};
MyApp.Base = {
getFixedVal: function(){
//Javascript code before refactoring
var myDataVal = someCalculationHere();
var amount = someInputFieldValue;
var fixedVal = 0;
if(myDataVal > 12){
if(0 < amount && amount <= 12000){
DEFINE amount, fixedVal, myDataVal
IF RANGE(0 - 12) INCLUDES myDataVal
IF RANGE(0,12000) INCLUDES amount
IF RANGE(0,95) INCLUDES calculatedVal
RETURN 0.8
ELSEIF RANGE(95,*) INCLUDES calculatedVal
RETURN 0.7
// intermediate code
var MyApp = {};
MyApp.Base = {
data: {
rules: {
FirstSet:{
"0-12": {
"0-12000":{
"0-90" :{
// Final code
var MayApp = {};
MyApp.Base = {
data: {
rules: {
FirstSet:{
"0-12": {
"0-12000":{
"0-90" :{
fixedVal: 0.4
@ParthBarot-BoTreeConsulting
ParthBarot-BoTreeConsulting / js_integer_to_bytes.js
Created June 28, 2017 05:52
JS - 32 bit integer to bytes
~$ node
> var calculatedChecksum = 1513135
// Anding an integer with 0xFF leaves only the least significant byte.
// For example, to get the first byte, we can write "<int value> & 0xFF"
// This is typically referred to as "masking"
> var firstByte = calculatedChecksum & 0XFF
// 0XFF00 is hexadecimal, We are masking out the lower byte of your number,
// then bit-shifting all of the bits to the right by 8.

Problem

Assuming there is an array A = [1,3,-1,4,2], We have the linked list built as following,

A[0] = 1
A[1] = 3
A[3] = 4
A[4] = 2
A[2] = -1
@ParthBarot-BoTreeConsulting
ParthBarot-BoTreeConsulting / video_youtube_integration.rb
Last active August 10, 2017 09:54
Youtube API integration using YT gem
#
# Old code, which has a loop and sends API call for each video ID
#
video_ids.map do |video_id|
Yt::Video.new(id: video_id).select(:snippet, :content_details, :statistics, :status)
end