Skip to content

Instantly share code, notes, and snippets.

View sirgallifrey's full-sized avatar
⛱️
I should update my bio....

Adilson Schmitt Junior sirgallifrey

⛱️
I should update my bio....
View GitHub Profile
import Input from './input';
import Label from './label';
import FormGroup from './form-group';
export default function Field ({children, name, inline, ...props}) {
return (
<FormGroup inline={ inline }>
<Label inline={ inline } htmlFor={ name }>{ label }</Label>
<Input inline={ inline } { ...props } id={ name }>
{ children }
@sirgallifrey
sirgallifrey / fetchData.js
Created August 5, 2017 02:10
is loged In HOC
import React from 'react';
import Loader from '../components/loader';
export default function fetchData(url, options) {
return (Component) => class fetchComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
finished = false;
data = null;
@sirgallifrey
sirgallifrey / input-field.js
Created August 3, 2017 05:23
high-order component
import React from 'react';
import withLabel from './with-label';
import Input from 'input';
export default withLabel(Input);
@sirgallifrey
sirgallifrey / card.js
Created August 3, 2017 04:04
props.children composition
import React from 'react';
function Card (props) {
return (
<div className={`card ${props.className}`}>
{ props.children }
</div>
);
}
@sirgallifrey
sirgallifrey / field.js
Last active August 3, 2017 00:39
specialized components
import React from 'react';
import Label from './label';
import Input from './input';
function Field (props) {
return (
<div className="form-group">
<Label>{props.label}</Label>
<Input type={props.type} onChange={props.onChange} value={props.value}/>
</div>
@sirgallifrey
sirgallifrey / server.js
Created January 31, 2017 20:02
always feed user info into Vision's .view context
server.ext('onPreResponse', (request, reply) => {
const response = request.response;
if (response.variety && response.variety === 'view') {
response.source.context = response.source.context || {};
if (request.auth.isAuthenticated) {
response.source.context.user = {
name: request.auth.credentials.name
};
}
@sirgallifrey
sirgallifrey / server.js
Created December 15, 2016 22:17
Hapi query validation of array
'use strict';
const Hapi = require('hapi');
const Joi = require('joi');
const server = new Hapi.Server();
server.connection({ port: 3000 });
server.route({
@sirgallifrey
sirgallifrey / server.js
Created October 26, 2016 02:38
Hapijs - modifying responses with API calls
'use strict';
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ port: 3000 });
// our route with normal output
server.route({
function getComputerChoice() {
var choice = Math.random();
if (choice < 0.34) {
return "rock";
} else if(choice <= 0.67) {
return "paper";
} else {
return "scissors";
}
//Author: Adilson Schmitt Junior ,aka SirGallifrey
//This script is just to show how you could resize a objet to fit a orthographic camera fustrum size.
using UnityEngine;
using System.Collections;
public class ScaleObjectToCamera : MonoBehaviour {
public float widthPerc = 1.0f;