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 / 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 );
@niraj-shah
niraj-shah / postReq.js
Last active August 29, 2015 14:17
NodeJS Example of POST
// include the libraries we need
var request = require('request');
var cheerio = require('cheerio');
// set some defaults
req = request.defaults({
jar: true, // save cookies to jar
rejectUnauthorized: false,
followAllRedirects: true // allow redirections
});
@niraj-shah
niraj-shah / req_install.sh
Last active August 29, 2015 14:17
Install request and cheerio using npm
# install request and cheerio.
# Use -g flag to install globally
npm install request cheerio
@niraj-shah
niraj-shah / getIP.js
Last active January 21, 2016 05:26
NodeJS example of how to scrape a webpage and retrieve the details
// include the libraries we need
var request = require('request');
var cheerio = require('cheerio');
// set some defaults
req = request.defaults({
jar: true, // save cookies to jar
rejectUnauthorized: false,
followAllRedirects: true // allow redirections
});
@niraj-shah
niraj-shah / fb_php_sdk_4.1_post.php
Created February 19, 2015 18:26
Getting started with the Facebook PHP SDK v4.1. Example of a POST request.
<?php
try {
// Be sure to ask for the publish_actions permission first
// If you provided a 'default_access_token', third parameter '{access-token}' is optional.
$response = $fb->post( '/me/feed', [
'name' => 'Facebook API: Using the Facebook PHP SDK v4.1.x',
'link' => 'https://www.webniraj.com/2015/02/19/facebook-api-using-the-facebook-php-sdk-v4-1-x/',
'caption' => 'As version v4.1 of the Facebook PHP SDK nears release (at time of writing), I though this would be a good time to explain how the new version works. Migrating your application from v4.0.x to v4.1.x will break your application.',
'message' => 'Check out my new blog post!',