Skip to content

Instantly share code, notes, and snippets.

View yashprit's full-sized avatar
💭
I may be slow to respond.

Yashprit yashprit

💭
I may be slow to respond.
View GitHub Profile
@yashprit
yashprit / gist:e682ba9415745d7f8cc008e90b92109e
Created March 5, 2018 06:53 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@yashprit
yashprit / control_flow.go
Last active August 29, 2015 14:17
Hello Golang
//playground runner https://play.golang.org/p/FkoEDVPB1n
package main
import (
"fmt"
)
func main() {
z := iKnowNamedReturs()
/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TO
var doctors = [
{ number: 1, actor: "William Hartnell", begin: 1963, end: 1966 },
{ number: 2, actor: "Patrick Troughton", begin: 1966, end: 1969 },
{ number: 3, actor: "Jon Pertwee", begin: 1970, end: 1974 },
{ number: 4, actor: "Tom Baker", begin: 1974, end: 1981 },
{ number: 5, actor: "Peter Davison", begin: 1982, end: 1984 },
{ number: 6, actor: "Colin Baker", begin: 1984, end: 1986 },
{ number: 7, actor: "Sylvester McCoy", begin: 1987, end: 1989 },
{ number: 8, actor: "Paul McGann", begin: 1996, end: 1996 },
{ number: 9, actor: "Christopher Eccleston", begin: 2005, end: 2005 },

When installing gulp:

1.-npm install gulp -g You need to unlock permissions in your home directory

  1. sudo chown -R `whoami` ~/.npm You also need write permissions to the node_modules directory, like Xilo says, so if it still isn't working, try:

  2. sudo chown -R `whoami` /usr/local/lib/node_modules If you are still seeing errors, you may also need to correct /usr/local permissions:

@yashprit
yashprit / node-webkit_local_development.md
Last active August 29, 2015 14:08
Node Webkit local development

Text taken from here

Sublime Text 2 is a great cross-platform editor for building node-webkit apps, you can download it here:

###Mac OS X

Download node-webkit.app and place it in /Applications folder From the Sublime Text 2 menu select Tools -> Build System -> New Build System Enter the following code:

# Node-WebKit CheatSheet
# Download: https://github.com/rogerwang/node-webkit#downloads
# Old Versions: https://github.com/rogerwang/node-webkit/wiki/Downloads-of-old-versions
# Wiki: https://github.com/rogerwang/node-webkit/wiki
# How: https://github.com/rogerwang/node-webkit/wiki/How-node.js-is-integrated-with-chromium
# 1. Run your application.
# https://github.com/rogerwang/node-webkit/wiki/How-to-run-apps
@yashprit
yashprit / bad_request.js
Created October 12, 2014 09:35
Error handling in NodeJS
//sub object, filename = badrequest.js
var Exception = require('./exception')
, inherits = require('util').inherits;
function BadRequest(message, uiMessage){
var code = 400;
Exception.call(this, code, message, uiMessage);
}
inherits(BadRequest, Exception);
@yashprit
yashprit / nodejs_app_structure
Last active August 29, 2015 14:07
Node js file structure
.
├── Gemfile
├── Rakefile
├── app
│   ├── controller
│   ├── dao
│   ├── middleware
│   ├── util
│   └── views
├── app.js
@yashprit
yashprit / cleaning_git.md
Last active August 29, 2015 14:06
Cleaning up git repository
  1. Check the size du .git/object or git count-objects -v
  2. find unwanted files git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch filename' --prune-empty -f -- --all
  3. Reclaim space
rm -rf .git/refs/original/\n
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now