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 / FormErrorsSerializer.php
Last active August 18, 2023 11:20 — forked from Graceas/FormErrorsSerializer.php
Symfony 2 Form Error Serializer. May be used for AJAX form validation. Allows tree and flat array styles for errors.
<?php
namespace OpenObjects\Bundle\CoreBundle\Service;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormError;
use Symfony\Component\Validator\ConstraintViolation;
/**
@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')
@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) {
@linxlad
linxlad / example.go
Created April 10, 2016 18:54 — forked from yanmhlv/example.go
simple DRY controller. golang github.com/labstack/echo example
package main
import (
"fmt"
"net/http"
"reflect"
"strconv"
"github.com/jinzhu/gorm"
"github.com/labstack/echo"
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)