Skip to content

Instantly share code, notes, and snippets.

View sushant-jadhav's full-sized avatar

Sushant Jadhav sushant-jadhav

View GitHub Profile
@sushant-jadhav
sushant-jadhav / database_transaction.php
Created December 28, 2019 05:54
Database Transaction in Laravel controller
public function create(Request $request)
{
$validator = Validator::make($request->all(), [
'username' => 'required|unique:users|max:255',
'email' => 'required|unique:users|max:255',
'amount' => 'required',
]);
if ($validator->fails()) {
return redirect()->route('user.index')
@sushant-jadhav
sushant-jadhav / LoginController.php
Created November 30, 2019 17:59
Laravel LoginController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
@sushant-jadhav
sushant-jadhav / LoginController.php
Created November 30, 2019 17:59
Laravel LoginController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
@sushant-jadhav
sushant-jadhav / app.js
Created November 29, 2019 07:51
Offline Message component usage.
import React, {useEffect} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
Platform,
StatusBar
} from 'react-native';
@sushant-jadhav
sushant-jadhav / offlineMessageSign.js
Created November 29, 2019 07:33
Check the internet connection in react native application. Also it will show the message when network is not available or not connected to the internet.
import React, { PureComponent } from 'react';
import { View, Text, Dimensions, StyleSheet } from 'react-native';
import NetInfo from "@react-native-community/netinfo";
const { width } = Dimensions.get('window');
function MiniOfflineSign() {
return (
<View style={{flex:0.05}}>
<View style={styles.offlineContainer}>
@sushant-jadhav
sushant-jadhav / OfflineMessage.js
Last active November 29, 2019 07:31
Check the internet connection in react native application and show the message when network is not available or not connected to the internet.
import React, { PureComponent } from 'react';
import { View, Text, Dimensions, StyleSheet } from 'react-native';
import NetInfo from "@react-native-community/netinfo";
const { width } = Dimensions.get('window');
class OfflineMessage extends PureComponent {
state = {
isConnected: true,
unsubscribe: ''
@sushant-jadhav
sushant-jadhav / sectionlistview.js
Created July 31, 2019 07:36
Section List View in React Native application with react native elements and react native paper packages
import React, {Fragment,Component} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
SectionList,
FlatList,
ActivityIndicator,
@sushant-jadhav
sushant-jadhav / WireUpEventsjQuery.js
Created September 13, 2016 13:40
Wire Up Events in jQuery to detect onbeforeunload,unload & onhashchange events on browser window
var timeout;
function warning() {
timeout = setTimeout(function () {
//saveProjectPreview();
}, 1000);
//saveProjectPreview ();
return "You are leaving the page";
}
@sushant-jadhav
sushant-jadhav / angular_outside_service_access.js
Created August 20, 2016 10:22
Angular Service Access Outside Controller
//put this code in jquery
var elem = angular.element(document.querySelector('[ng-controller]'));
var injector = elem.injector();
//get the service.
var contentService = injector.get('Your-Service');
//now use contentService to access service
@sushant-jadhav
sushant-jadhav / valueDivisibleBy7.py
Last active July 31, 2016 11:11
Rhezo is obsessed with the number 7 7 and likes numbers that are divisible by 7 7. He has a big number of N N digits and Q Q questions. In each of the question, he wants to find if the number formed by the string between indices L i Li and R i Ri is divisible by 7 7 or not. As he is very weak at programming, you should help him in this task. Inp…
import sys
def find_between( s, first, last ):
start = int(first)-1;
end = int(last)
num = s[start:end]
return int(''.join(map(str,num)))
def divisible(num):
if(num%7==0):