Skip to content

Instantly share code, notes, and snippets.

View rakeshtembhurne's full-sized avatar
😉
Writing a Book

Rakesh Tembhurne rakeshtembhurne

😉
Writing a Book
View GitHub Profile
diff --git a/src/app/secure/profile/myprofile.component.ts b/src/app/secure/profile/myprofile.component.ts
index cd3f9b2..d72c6fb 100644
--- a/src/app/secure/profile/myprofile.component.ts
+++ b/src/app/secure/profile/myprofile.component.ts
@@ -1,5 +1,5 @@
import {Component} from "@angular/core";
-import {LoggedInCallback, UserLoginService, UserParametersService, Callback} from "../../service/cognito.service";
+import {LoggedInCallback, UserLoginService, CognitoUtil, UserParametersService, Callback} from "../../service/cognito.service";
import {Router} from "@angular/router";
@rakeshtembhurne
rakeshtembhurne / git_new_repo_from_old.sh
Created November 18, 2016 12:14
Git: Steps to delete old repository and create new one from existing git project
git checkout -b oldroot X
TREE=`git write-tree`
COMMIT=`echo "Killed history" | git commit-tree "$TREE"`
git checkout -b newroot "$COMMIT"
git rebase --onto newroot oldroot master
# repeat for other branches than master that should use the new initial commit
git checkout master
git branch -D oldroot
git branch -D newroot
git gc # WARNING: if everything's done right, this will actually delete your history from the repo!
@rakeshtembhurne
rakeshtembhurne / scraper.js
Created November 16, 2016 12:41
NodeJS: simple example of scraping
var request = require('request');
var mysql = require('mysql');
var async = require('async');
var cheerio = require('cheerio');
var _ = require('lodash');
var domain = 'http://timesofindia.indiatimes.com/';
function getDomain() {
@rakeshtembhurne
rakeshtembhurne / bash_aliases
Created November 16, 2016 06:06 — forked from frdmn/bash_aliases
Nginx and PHP-FPM configuration + default virtual host
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart='mysql.stop && mysql.start'
alias nginx.logs.error='tail -250f /usr/local/etc/nginx/logs/error.log'
@rakeshtembhurne
rakeshtembhurne / remove_comma.js
Created November 10, 2016 12:42
JavaScript: How to remove last comma from SQL query in JavaScript
sql = sql.replace(/,\s*$/, "");

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@rakeshtembhurne
rakeshtembhurne / __FILE__.js
Created June 10, 2016 12:27 — forked from plepe/__FILE__.js
__FILE__ in JavaScript
/***
* This gist provides a __FILE__ variable, which holds the path to the file
* from which the currently running source is being executed.
*
* Usage example: alert(__FILE__);
*
* Thanks to http://ejohn.org/blog/__file__-in-javascript/ on which this gist
* is based on.
*
* Tested in Mozilla Firefox 9, Mozilla Firefox 16, Opera 12, Chromium 18
@rakeshtembhurne
rakeshtembhurne / aggregate.js
Created December 10, 2015 06:24
Aggregate data from MongoDB with Node.js and mongoose
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//Database connection
var uristring = 'mongodb://localhost/test';
var mongoOptions = { };
mongoose.connect(uristring, mongoOptions, function (err, res) {
if (err) {
console.log('Error when connecting to: ' + uristring + '. ' + err);
@rakeshtembhurne
rakeshtembhurne / string.js
Created November 18, 2015 05:45
JavaScript: Extending Core function to honor regular expression
String.prototype.regexIndexOf = function(regex, startpos) {
var indexOf = this.substring(startpos || 0).search(regex);
return (indexOf >= 0) ? (indexOf + (startpos || 0)) : indexOf;
}
String.prototype.regexLastIndexOf = function(regex, startpos) {
regex = (regex.global) ? regex : new RegExp(regex.source, "g" + (regex.ignoreCase ? "i" : "") + (regex.multiLine ? "m" : ""));
if(typeof (startpos) == "undefined") {
startpos = this.length;
} else if(startpos < 0) {
startpos = 0;
@rakeshtembhurne
rakeshtembhurne / permissions.sh
Created October 23, 2015 05:03
Shell: Default Folder and File Permissions
chmod -R u+rwX,go+rX,go-w /foo