Skip to content

Instantly share code, notes, and snippets.

View kamlekar's full-sized avatar
💭
Self refactoring

Venkateshwar kamlekar

💭
Self refactoring
View GitHub Profile
@kamlekar
kamlekar / hoisting.js
Last active November 30, 2018 10:56
Classic problem of hoisting.
var foo = 1;
function bar(){
if(!foo){
var foo = 10;
}
alert(foo);
}
bar();
@kamlekar
kamlekar / smoothScroll.js
Created December 2, 2016 07:54
Smooth scrolling effect (depends on jQuery)
$.fn.smoothScroll = function(selector, payload) {
// payload params
// @ (int) payload.timerValue: Determines the max time to show the smooth animation
// @ (jQuery Element) payload.scrollingElement: Determines the element to which the scroll is present
payload = payload || {};
function getScrollingElement($el) {
return payload.scrollingElement || $el.parent();
}
// Delegate event
public function getProjects($interpreter){
$result = new stdClass();
$userId = $interpreter->getUser()->user_id;
$data = $interpreter->getData()->data;
$db = Master::getDBConnectionManager();
$db->beginTransaction();
try{
// functionality here
@kamlekar
kamlekar / Fresh setup on systems.md
Last active October 6, 2021 05:47
Fresh setup on systems

Softwares

"editor.fontFamily": "Fira Code",

@kamlekar
kamlekar / Pinner.js
Last active April 5, 2016 10:33
Used to pin items in a list to top or bottom of scrolling container
function stickItems($parent, itemClass, selectClass) {
// Attach dummy element items which acts as the selected item when selected item is out of fold when scrolled
// This dummy element will be on top of the scrolling contaner
$parent.prepend('<div class="' + itemClass + ' sticky top"></div>');
// This dummy element will be on bottom of the scrolling container
$parent.append('<div class="' + itemClass + ' sticky bottom"></div>');
var $items = $('.' + itemClass),
$stickyTop = $('.' + itemClass + '.sticky.top'),
$stickyBottom = $('.' + itemClass + '.sticky.bottom');
var sb = (function () {
var eventObject = {};
document.body.addEventListener('click', function(e){
var el = e.target;
var parent = el.parentElement;
while(parent !== document.body){
for(var item in eventObject){
var elements = document.querySelectorAll(item);
for(var i = 0, ilen = elements.length; i < ilen; i++){
if(el === elements[i]){
@kamlekar
kamlekar / string-reverser.js
Created January 6, 2016 04:34
String reverser
function rev(s){
var l = s.length, r=Array(l);
for(var i=l-1;i>=0;i--)
r[i]=s[l-1-i];
return r.join('');
}
@kamlekar
kamlekar / sum.js
Last active September 5, 2015 05:35
sum of two big numbers (still in testing)
function doSum(a, b){
var aLen = ("" + a).length, bLen = ("" + b).length;
var large = Math.max(aLen, bLen);
var dummyZeroes = "";
for(var j = 0; j < large; j++) {
dummyZeroes += "0";
}
a = (dummyZeroes + a).slice(-large);
b = (dummyZeroes + b).slice(-large);
var result = "";
@kamlekar
kamlekar / date-valid.js
Created July 16, 2015 10:44
Check whether date is valid or not
function getDate(time) {
// Refer: http://stackoverflow.com/a/10589791/1577396
// Refer: http://stackoverflow.com/a/1353711/1577396
if(!time) {
return false;
}
var dateTime = new Date(time);
// Valid date
if(Object.prototype.toString.call(dateTime) === "[object Date]" && !isNaN(dateTime.getTime())){
return dateTime;
@kamlekar
kamlekar / style.css
Created December 7, 2012 10:16
Chat Application (work in progress) style.css
#chat-outline
{
background-color: gray;
width: 16%;
height: 50%;
min-height: 300px;
min-width: 200px;
max-height: 450px;
max-width: 300px;
position: fixed;