Skip to content

Instantly share code, notes, and snippets.

View kalpesh-fulpagare's full-sized avatar
🎯
RubyOnRails, GoLang, AngularJS Developer

Kalpesh Fulpagare kalpesh-fulpagare

🎯
RubyOnRails, GoLang, AngularJS Developer
  • Scalefusion
  • Pune, India
View GitHub Profile
@kalpesh-fulpagare
kalpesh-fulpagare / alias.sh
Last active January 4, 2016 21:48
Ubuntu bash alias
# Edit .bashrc file with
$ cd
$ nano ~/.bashrc
# Add following lines if not present, if commented uncomment these lines
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
$("form.validate:not([novalidate])").each(function() {
formValidations = {
errorElement: "span",
errorClass: "errorField",
rules: {},
messages: {}
};
$(this).find("input, select, textarea").each(function() {
if ($(this).data("rules") !== undefined) {
formValidations['rules'][$(this).attr('name')] = $(this).data("rules");
@kalpesh-fulpagare
kalpesh-fulpagare / postgres_install.sh
Last active August 29, 2015 13:55
Installing postgres in ubuntu
# https://help.ubuntu.com/10.04/serverguide/postgresql.html
$ sudo apt-get install postgresql postgresql-contrib
# To enable TCP/IP connections, edit the file /etc/postgresql/9.1/main/postgresql.conf
# and locate the line #listen_addresses = 'localhost' and
# change it to: listen_addresses = 'localhost'
$ sudo nano /etc/postgresql/9.1/main/postgresql.conf
@kalpesh-fulpagare
kalpesh-fulpagare / common.js.coffee
Last active August 29, 2015 13:55
My common js methods
flashTimer = null
$(document).ready ->
c = undefined
CommonJs =
settings:
domInputs: ->
$("input[type='text'], input[type='email'], input[type='password']")
init: ->
c = @settings
@kalpesh-fulpagare
kalpesh-fulpagare / sublime_packages.js
Last active August 29, 2015 13:55
Installing package manager
https://sublime.wbond.net/installation#st3
The simplest method of installation is through the Sublime Text console. The console is accessed via the ctrl+` shortcut or the View > Show Console menu. Once open, paste the appropriate Python code for your version of Sublime Text into the console.
SUBLIME TEXT 3
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
SUBLIME TEXT 2
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.subl
@kalpesh-fulpagare
kalpesh-fulpagare / server.js
Last active August 29, 2015 13:57
RoR app with Wordpress on Nginx
$ cd /var/www
$ ll
drwxr-xr-x 5 root root 4096 Mar 7 12:52 wp
Installing php5-fpm
sudo apt-get install php5-fpm
php5-fpm configuration.Open up www.conf:
sudo nano /etc/php5/fpm/pool.d/www.conf
@kalpesh-fulpagare
kalpesh-fulpagare / nano.md
Last active August 29, 2015 13:57
Nano Shortcuts

Search text

Ctrl + W Type Text 'TEXT TO SEARCH'
Press 'Enter'
Press Alt + W to find next occurrence of text

Cut copy Paste

Select: ALT + M + A
Cut selected text/Current Line: Ctrl + K Copy: ALT + 6

@kalpesh-fulpagare
kalpesh-fulpagare / image_preview.js
Last active August 29, 2015 14:11
Angular Directive to Show File Upload image thumbnail
angular.module('image-preview-demo',[]).directive('imgPreviewElem', [function () {
return {
restrict: 'AE',
link: function(scope, elem, attrs) {
console.log("directive called")
elem.bind('change', function () {
var file=elem[0].files[0],
imageType=/(image.jpeg|image.png|image.jpg)/,
imgElementId = attrs.imgPreviewElem;
@kalpesh-fulpagare
kalpesh-fulpagare / PostgressCheatsheet.sql
Last active October 23, 2021 18:59
Postgres Useful commands.
sudo -u postgres psql -d template1 -c "CREATE USER kalpesh WITH PASSWORD 'password' CREATEDB;"
sudo -u postgres psql -d template1 -c "CREATE DATABASE sample_db OWNER kalpesh;"
sudo -u postgres psql -d template1 -c "CREATE USER kalpesh CREATEDB;"
sudo -u postgres -H psql -d template1
/* =========================== Users =========================== */
/* Create User with password */
CREATE USER kalpesh WITH PASSWORD 'kalpesh';
/* Drop User */
@kalpesh-fulpagare
kalpesh-fulpagare / heroku-db.csv
Created February 8, 2016 12:39
Heroku DB Table - Export CSV
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 30 in line 1.
heroku pg:psql --app APP_NAME
\copy (SELECT users.id, CONCAT(first_name, ' ', middle_name, ' ', last_name) AS full_name, username, dob, gender, address_line_1, address_line_2, province, zipcode, email, phone_number, minor, roles.name as role, avatar_url, email_frequency, sign_in_count, license_code, city, elise_points, used_points, contact_person, phone, website, chamber_of_commerce_no, notes FROM users LEFT JOIN roles on role_id=roles.id) TO users-8feb-2016.csv CSV HEADER DELIMITER ','