Skip to content

Instantly share code, notes, and snippets.

View linxlad's full-sized avatar

Nathan Daly linxlad

  • Bury St Edmunds, England
View GitHub Profile
@linxlad
linxlad / componentCheckerUtil.js
Last active September 6, 2018 21:34
Helper to check for: Component vs Element, Class vs Functional and Component DOM vs Composite Element.
/**
* Helper to check for:
* Component vs Element
* Class vs Functional
* Component DOM vs Composite Element
*/
import React from 'react';
export function isClassComponent(component) {
import React, { Component, PropTypes } from 'react';
import { View, Image, TextInput, Text, Dimensions, Alert } from 'react-native';
import { Font } from 'expo';
import { connect } from 'react-redux';
import { LoginButton } from '../SubComponents/LoginComponent/LoginButton';
import { loginUser } from '../../actions'
class Login extends Component {
static propTypes = {
loginUser: PropTypes.func,
@linxlad
linxlad / HomeSlice.js
Last active June 30, 2017 11:27
Homeslice Component using semantic UI
import React, { PureComponent } from 'react';
import { Container, Header, Grid, Image} from 'semantic-ui-react';
import './HomeSlice.scss';
export class HomeSlice extends PureComponent {
render() {
const {heading, image, context, reverse} = this.props;
const imageTag = <Image size="large" className="homeSlice--image" src={image}/>;
const text = context.split('<br />').map((item, key) => {
return <span key={key}>{item.trim()}<br/></span>;
@linxlad
linxlad / AddEmailAction.js
Last active June 22, 2017 14:16
React Form Redux Example
import axios from 'axios';
import {
ADD_EMAIL_STARTED,
ADD_EMAIL_FINISHED
} from '../types';
/**
* Do not use hasError callback if you are using
* componentWillReceiveProps in component.
const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const DashboardPlugin = require('webpack-dashboard/plugin');
const path = require('path');
const webpack = require('webpack');
const BUILD_DIR = path.resolve(__dirname, '../dist');
const APP_DIR = path.resolve(__dirname, 'src/');
@linxlad
linxlad / eslint.js
Created June 8, 2017 11:02
React eslint
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8,
@linxlad
linxlad / services.php
Created May 15, 2017 08:23
Deferred services in Phalcon 3.
<?php
$di->set('deferred.classes', $deferred = [
'mail.selected_adapter' => Closure,
'mail' => Closure,
'db' => Closure,
'log' => Closure,
]);
function resolve($alias)
@linxlad
linxlad / password-validation.js
Last active May 3, 2017 16:33
Find a matching password string then check if the password is not a duplicate and is still valid.
// Test data.
var userData = {
"password": "$2a$12$cZnjMBhqUI97xlKyizJh9uf43Kz5h0RC5wXVfy9WhTuth.mCbfzl.",
"password_history": [
{
"created": "2017-05-01T23:00:00.000Z",
"password": "password"
},
{
"created": "2017-04-25T23:00:00.000Z",
@linxlad
linxlad / QRLogo.php
Created February 28, 2017 10:31 — forked from NTICompass/QRLogo.php
QR Code + Logo Generator
<?php
/**
* QR Code + Logo Generator
*
* http://labs.nticompassinc.com
*/
$data = isset($_GET['data']) ? $_GET['data'] : 'http://labs.nticompassinc.com';
$size = isset($_GET['size']) ? $_GET['size'] : '200x200';
$logo = isset($_GET['logo']) ? $_GET['logo'] : FALSE;
@linxlad
linxlad / proxy.php
Last active August 12, 2019 15:48 — forked from iovar/proxy.php
Simple PHP Proxy Script
<?php
$method = $_SERVER['REQUEST_METHOD'];
if ($_GET && $_GET['url']) {
$headers = getallheaders();
$headers_str = [];
$url = $_GET['url'];
foreach ( $headers as $key => $value){
if($key == 'Host')