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 / index.html
Created July 21, 2022 04:26
Replicate Bootstrap Grid with CSS Flexbox
<div class="row">
<div class="col-2"></div>
<div class="col-7"></div>
<div class="col-3"></div>
</div>
# Add new line at the end of the file
for file in chapters/*
do
if [ -s "$file" ] && [ "$(tail -c1 "$file"; echo x)" != $'\nx' ]; then
echo "" >>"$file"
fi
done
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"useTabs": false,
"arrowParens": "always"
}
@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 / index.html
Last active March 22, 2016 16:17
Add selected class to active nav item AngularJS (ui-router)
<div class="container" ng-controller="HeaderController">
<h1>This is my demo ui-router app.</h1>
<div class="navbar">
<a class="navbar-brand" href="#">ui-router</a>
<ul class="nav navbar-nav">
<li class="active">
<a ng-class="getClass('/state1')" ui-sref="state1">State1</a>
</li>
<li>
<a ng-class="getClass('/state2')" ui-sref="state2">State2</a>
@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 / jQueryInternalLinks
Created October 23, 2014 03:44
jQuery Internal Links
@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 / 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 / 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}