Skip to content

Instantly share code, notes, and snippets.

View WMTAndroidJaymin's full-sized avatar

Jaymin Panchal WMTAndroidJaymin

View GitHub Profile
@harpalsinh-jadeja
harpalsinh-jadeja / Validate.js
Created August 14, 2017 13:35
React-native Validation using validate.js
import validation from 'validate.js'
export default function validate(fieldName, value) {
var constraints = {
email: {
presence: true,
format: {
pattern: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
message: 'Invalid email id',
}
@WMTAndroidJaymin
WMTAndroidJaymin / loop.scss
Created July 12, 2017 11:17 — forked from ntassone/loop.scss
SASS - Loop through array to create class sets.
//Set Variables
$button-white: #ffffff;
$button-green: #44ca00;
$button-green-dark: #369a12;
$button-blue: #a6d1f9;
$button-blue-dark: #14283e;
$button-gray: #eeeeee;
$button-red: #9e0b0f;
//Create Array
@jayminpanchal
jayminpanchal / ClassFactory.php
Created June 24, 2017 18:03
Create Class object from class name
class ClassFactory
{
function __construct($namespace = '')
{
$this->namespace = $namespace;
}
public function make($source)
{
$name = $this->namespace . '\\' . $source;
@JaydipZala
JaydipZala / Soap.java
Created March 15, 2017 05:46
Okhttp Soap
public class Soap {
private static final String BASE_URL = "base_url";
private static String RESULT_OK = "200";
private static String getAbsiluteURL(String postFixUrl) {
return BASE_URL + postFixUrl;
}
private static String getConnectionErrorResponse(Context context)
@verticalgrain
verticalgrain / app.js
Last active April 26, 2022 15:37
React Router V4 Redirect after form submission
import React, { Component } from 'react'
import { Redirect } from 'react-router'
export default class ContactForm extends Component {
constructor () {
super();
this.state = {
fireRedirect: false
}
}
@paulsturgess
paulsturgess / service.js
Last active February 2, 2024 17:24
An example Service class wrapper for Axios
import axios from 'axios';
class Service {
constructor() {
let service = axios.create({
headers: {csrf: 'token'}
});
service.interceptors.response.use(this.handleSuccess, this.handleError);
this.service = service;
}
@sheharyarn
sheharyarn / request.js
Last active August 24, 2023 14:55
Axios Request Wrapper for React (https://to.shyr.io/axios-requests)
/**
* Axios Request Wrapper
* ---------------------
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
*/
import axios from 'axios'
@mmazzarolo
mmazzarolo / NavBar.android.js
Last active June 7, 2020 14:46
React-Native toolbar on Navigation-Experimental (for both Android and iOS)
import React, { Component } from 'react'
import { StyleSheet } from 'react-native'
import Icon from 'react-native-vector-icons/Ionicons'
export default class NavBar extends Component {
static propTypes = {
title: React.PropTypes.string,
onLeftPress: React.PropTypes.func,
showDrawer: React.PropTypes.bool
}
@justasm
justasm / NonPersistentCookieJar.java
Last active April 21, 2019 10:03
OkHttp 3 non-persistent CookieJar with an ACCEPT_ALL policy
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
@slamus
slamus / Style.js
Last active March 29, 2018 23:15
Responsive Design in React Native - Style
import React from "react-native";
import Dimensions from 'Dimensions';
// Precalculate Device Dimensions for better performance
const x = Dimensions.get('window').width;
const y = Dimensions.get('window').height;
// Calculating ratio from iPhone breakpoints
const ratioX = x < 375 ? (x < 320 ? 0.75 : 0.875) : 1 ;
const ratioY = y < 568 ? (y < 480 ? 0.75 : 0.875) : 1 ;