Skip to content

Instantly share code, notes, and snippets.

View mbaljeetsingh's full-sized avatar
:octocat:
Born to express not impress

Baljeet Singh mbaljeetsingh

:octocat:
Born to express not impress
View GitHub Profile
@mbaljeetsingh
mbaljeetsingh / encodeDecode
Created May 16, 2014 07:01
Simple Encoder Decoder Javascript
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Simple Encoder Decoder Javascript</title>
<style id="jsbin-css">
</style>
@mbaljeetsingh
mbaljeetsingh / gdriveCDN
Last active August 29, 2015 14:02
Using Google Drive As CDN
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Google CDN Example</title>
<link rel="stylesheet" href="https://googledrive.com/host/0B9tQ5z-2ysgYenY1Rk5BQlA4TkE/style.css">
</head>
<body>
<p>Google CDN Example</p>
@mbaljeetsingh
mbaljeetsingh / CycleDivJquery
Created July 6, 2014 15:34
Cycle through two divs jquery
<div style="text-align: center">
<span id="block1" style="font-size: 200px;color:#FF0000">ਵਾਹਿ</span>
<span id="block2" style="font-size: 200px; margin-left: 125px; color:#FF0000">ਗੁਰੂ</span>
</div>
<script>
jQuery(document).ready(function($) {
var shortIntervalTime = 1 * 200;
var longIntervalTime = 1 * 500;
@mbaljeetsingh
mbaljeetsingh / Git CheatSheet
Created August 2, 2014 09:10
Git CheatSheet
git init
git status
git add
git commit
git log
.gitignore files
git branch
git checkout
gitk
git remote add origin {url}
@mbaljeetsingh
mbaljeetsingh / app.js
Created September 10, 2014 07:10
Angular Login POST request
var app = angular.module('angularPostPHP', []);
app.controller('loginCtrl', function ($scope, $http) {
$scope.login = function () {
var request = $http({
method: "post",
url: "login.php",
data: {
@mbaljeetsingh
mbaljeetsingh / JScallBack
Created October 14, 2014 15:06
Javascript Callback Function
// A dummy function that callback after 1 second (simulating some processing work)
function dummy(i, callback) {
setTimeout(function() {
// After 1 second, we callback with a result
callback('slow result')
}, 1000);
}
// Incorrect version
@mbaljeetsingh
mbaljeetsingh / jQueryInternalLinks
Created October 23, 2014 03:44
jQuery Internal Links
@mbaljeetsingh
mbaljeetsingh / renderWithngWatch
Created October 27, 2014 11:52
Watching screen resolution changes to render different divs.
//Watching screen resolution changes to render different divs.
$scope.$watch(function(){
return window.innerWidth;
}, function(newValue) {
if(newValue < 767){
$rootScope.renderMobileView = true;
}
else{
$rootScope.renderMobileView = false;
@mbaljeetsingh
mbaljeetsingh / script.js
Last active August 29, 2015 14:17
Add selected class to active list item link AngularJS
.config(function($stateProvider, $urlRouterProvider) {
//
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("/state1");
//
// Now set up the states
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
@mbaljeetsingh
mbaljeetsingh / Browser Notepad
Created June 23, 2013 09:11
Simplest browser notepad which changes colour as you type.
data:text/html, <html><head><link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'><style type="text/css"> html { font-family: "Open Sans" } * { -webkit-transition: all linear 1s; }</style><script>window.onload=function(){var e=false;var t=0;setInterval(function(){if(!e){t=Math.round(Math.max(0,t-Math.max(t/3,1)))}var n=(255-t*2).toString(16);document.body.style.backgroundColor="#ff"+n+""+n},1e3);var n=null;document.onkeydown=function(){t=Math.min(128,t+2);e=true;clearTimeout(n);n=setTimeout(function(){e=false},1500)}}</script></head><body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;">