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 / 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
@niraj-shah
niraj-shah / VerifyCsrfToken.php
Last active October 31, 2016 04:30
Laravel 5.x CSRF Middleware with custom redirect
<?php
namespace App\Http\Middleware;
use Closure;
use Redirect;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
@niraj-shah
niraj-shah / AndroidManifest.xml
Created December 7, 2015 21:25
Complete AndroidManifest file for Parse Push Notification Customisation
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="4" android:versionName="1.0" package="com.webniraj.cordova" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:name="com.webniraj.cordova.App" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher
@niraj-shah
niraj-shah / AndroidManifest.xml
Created December 7, 2015 21:11
AndroidManifest Parse Push Notification Icon
<meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/push_icon" />
@niraj-shah
niraj-shah / jquery_fix.js
Last active December 4, 2015 14:01
jQuery Mobile iOS 9.x fix for Cordova / Trigger.io
if ( device.platform == 'iOS' && parseFloat( device.version ) >= 9 ) {
// fix for iOS 9 only or it will break Android
$.mobile.hashListeningEnabled = true;
$.mobile.pushStateEnabled = false;
}
@niraj-shah
niraj-shah / encrypt_and_decrypt.php
Created September 9, 2015 14:16
Public/Privacy Key Encryption and Decryption example using PHP
<?php
$string = "I'm using PHP to encrypt and decrypt data!";
$publicKey = file_get_contents( 'public.pub' );
openssl_public_encrypt( $string, $encrypted, $publicKey );
$encrypted = base64_encode( $encrypted );
@niraj-shah
niraj-shah / pub_priv_keys.php
Created September 9, 2015 14:11
Create Private and Public Keys using PHP
<?php
$config = array(
"digest_alg" => "sha512",
"private_key_bits" => 4096,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
);
// Create the private and public key
$result = openssl_pkey_new( $config );