Skip to content

Instantly share code, notes, and snippets.

View pinalbhatt's full-sized avatar
💭
from the desk of Pinal Bhatt

Pinal Bhatt pinalbhatt

💭
from the desk of Pinal Bhatt
View GitHub Profile
@pinalbhatt
pinalbhatt / gist:f981678b4a3f08675212992e0591a9a8
Created August 11, 2017 12:39 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@pinalbhatt
pinalbhatt / index.html
Created February 26, 2017 19:21 — forked from sommereder/index.html
IPC Renderer Service for Electron/Angular2
<script>
const electron = require('electron');
// below is just plain angular stuff
System
.config({
packages: {
angular: {
format: 'register',
defaultExtension: 'js'
@pinalbhatt
pinalbhatt / 0_reuse_code.js
Created February 13, 2016 12:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pinalbhatt
pinalbhatt / gist:2fc114f817a1d294e6ea
Last active September 12, 2015 01:36 — forked from cakebaker/gist:823574
Nicer interface for removing query string params with Node.js
var urlLib = require('url');
function UrlAdapter(urlString) {
this.urlObj = urlLib.parse(urlString, true);
// XXX remove the search property to force format() to use the query object when transforming the url object to a string
delete this.urlObj.search;
}
exports.UrlAdapter = UrlAdapter;
@pinalbhatt
pinalbhatt / rename git branch locally and remotely
Last active August 29, 2015 14:12 — forked from lttlrck/gist:9628955
Rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
#Set of commands i use to rename feature/15.0 to feature/SignupRefactor locally and remotely
#rename local feature/15.0 to feature/SignupRefactor
git branch -m feature/15.0 feature/SignupRefactor
#delete remote feature/15.0
/*
C# Generic String Parser Extension Method
Code Snippet By: Pinal Bhatt [www.PBDesk.com]
http://blogs.pbdesk.com/c-generic-string-parser-extension-method/
Working Example at http://ideone.com/ZP5xo
Usage:
string s = "32";
int i = s.As<int>();
*/
/*
C# Generic Enum Parser With Extension Methods
Code Snippet By: Pinal Bhatt [www.PBDesk.com]
*/
public static class EnumUtils
{
#region String to Enum
/*
C# Some Handy String Extension Methods
Code Snippet By: Pinal Bhatt [www.PBDesk.com]
*/
using System;
public static class StringExtensions
{
/// <summary>
@pinalbhatt
pinalbhatt / DynamicObjectNestedMemberCall.cs
Created August 3, 2014 13:26
C# Dynamic Object Nested Member Call
using System;
using System.Dynamic;
namespace WW.COM.Framework.WWConfiguration
{
public class EnvSettings : DynamicObject
{
private string Category { get; set; }
public EnvSettings()
{
@pinalbhatt
pinalbhatt / ReadingQueryStringWithJavaScript
Last active August 29, 2015 14:04
Reading Query String with JavaScript
/*
Javascript function to read QueryString parameters.
More details bloged at http://blog.pbdesk.com/2008/11/reading-query-string-with-javascript.html
JSFiddle: http://jsfiddle.net/PinalBhatt/sBkur/
*/
function GetQueryStringValue(parameterName) {
var objQRs = new Object();
window.location.search.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"),