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 / 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 / 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 / Chat.cs
Created December 5, 2012 12:26
These are my files related to SignalR chat application which I have created by going through the Quick Hub documentation tutorial.(work still in progress)
/*
* Please add your Valuable comments in between the codes where there is a need of modification
* So that I can have a clear goal.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
@kamlekar
kamlekar / Chat.cs
Created December 7, 2012 10:11
Chat Application (work in progress) Chat.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR.Hubs;
using System.Threading.Tasks;
using System.Collections.Concurrent;
namespace serverNameExample
{
@kamlekar
kamlekar / default.aspx
Created December 7, 2012 10:12
Chat Application (work in progress) default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="serverNameExample._default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.8.2.js" type="text/javascript"></script>
<script src="Scripts/jquery.signalR-1.0.0-alpha2.min.js" type="text/javascript"></script>
<!-- If this is an MVC project then use the following -->
<!-- <script src="~/signalr/hubs" type="text/javascript"></script> -->
@kamlekar
kamlekar / User.cs
Created December 7, 2012 10:13
Chat Application (work in progress) User.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR.Hubs;
namespace serverNameExample
{
public class User
{
@kamlekar
kamlekar / file.js
Created December 7, 2012 10:15
Chat Application (work in progress) file.js
//Added References
/*
* jquery-1.6.4.min.js
* jquery.signalR-1.0.0-alpha2.min.js
*/
var showChatName = new Boolean();
showChatName = true;
var chatUsername = window.prompt("Enter Username:", "");
@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;
@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 / 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');