Skip to content

Instantly share code, notes, and snippets.

View niraj-shah's full-sized avatar
🏠
Working from home

Niraj Shah niraj-shah

🏠
Working from home
View GitHub Profile
@niraj-shah
niraj-shah / MyController.php
Created March 8, 2016 09:30
Putting Laravel Validation into a Controller
<?php namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Input;
use Auth;
use View;
use Session;
use Validator;
use Redirect;
@niraj-shah
niraj-shah / release-signing.properties
Last active September 10, 2017 02:05
Create the release-signing.properties file in the platforms/android folder to setup Release Signing
# location of keystore
storeFile=/path/to/app.keystore
# Key alias
keyAlias=alias_name
# Store password
storePassword=Password1
# Key password
@niraj-shah
niraj-shah / startswith.php
Last active February 19, 2016 12:26
Laravel 5.x Custom Validation Rule: startswith
// validate that mobile number starts with '07'
$rules = [
'mobile' => 'required|numeric|startswith:07',
];
// custom validator called startswith
Validator::extend('startswith', function( $attribute, $value, $parameters ) {
return substr( $value, 0, strlen( $parameters[0] ) ) == $parameters[0];
});
@niraj-shah
niraj-shah / password_validator.php
Last active February 19, 2016 12:26
Laravel 5.x Custom Validation Rules
// Remember to include the required classes, e.g. Hash, Validator, Redirect, User model
// define validation rules, 'password' will be our custom rule
$rules = [
'current_password' => 'required|password',
'password' => 'required|confirmed|min:6',
];
// custom rule for 'password'
Validator::extend('password', function( $attribute, $value, $parameters ) {
@niraj-shah
niraj-shah / using_mongo.sh
Created February 1, 2016 10:52
MongoDB Commands
# Start MongoDB Shell
mongo
# Get MongoDB version
mongo --version
# Show Mongo Databases (from MongoDB Shell)
show dbs
# Create DB `parse` and Insert Data to `users` collection
@niraj-shah
niraj-shah / install_mongo.sh
Created February 1, 2016 10:30
Update APT to get latest MongoDB packages and instal latest version of software
# Import the Public Key for Official MongoDB Repo
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
# Update apt-get to get latest MongoDB packages
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
# Update apt-get package list with new repo details
sudo apt-get update
# Install the latest version of MongoDB
@niraj-shah
niraj-shah / install_node.sh
Created February 1, 2016 10:17
Commands to Install NodeJS 4.x / 5.x and build tools
# Install NodeJS 4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install NodeJS 5.x
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Optional - Needed to compile and install native add-ons
sudo apt-get install -y build-essential
@niraj-shah
niraj-shah / verification.sh
Created January 31, 2016 14:30
Parse Server Verification using cURL
# Save data using Parse API
curl -X POST \
-H "X-Parse-Application-Id: YOUR_APP_ID" \
-H "Content-Type: application/json" \
-d '{"name":"Niraj Shah","score":"1337"}' \
http://localhost:1337/parse/classes/GameScore
# Retrieve all the entries in GameScore
curl -X GET \
-H "X-Parse-Application-Id: YOUR_APP_ID" \
@niraj-shah
niraj-shah / app.js
Created January 31, 2016 14:06
Parse Server Express App
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/myapp',
appId: '{YOUR_APP_ID}',
@niraj-shah
niraj-shah / install_parse.sh
Created January 31, 2016 14:02
Install NodeJS Modules for ParseServer
# Install required nodejs packages
npm install parse-server express