Skip to content

Instantly share code, notes, and snippets.

View renatorib's full-sized avatar

Renato Ribeiro renatorib

View GitHub Profile
@renatorib
renatorib / Cash.php
Last active August 29, 2015 14:24
Printi Test - Class Cash - Minimum notes algorithm
<?php
class Cash {
/**
* Get plain available notes and his quantity (true = infinite)
* Example:
* '100' => 20 // Available 20 notes of 100
* '100' => true // Available infinite notes of 100
*
* @return array
@renatorib
renatorib / generateToken.php
Last active August 29, 2015 14:24
Function to Generate Token by length
function generateToken($length = 20, $chars = 'abcdefghijklmnopqrstuvxwyzABCDEFGHIJKLMNOPQRSTUVXWYZ1234567890'){
$return = '';
while($length > 0){
$return .= $tokens[rand(0, strlen($chars)-1)];
$length--;
}
return $return;
}
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
*
* Licensed under The MIT License
*
* Copyright (c) La Pâtisserie, Inc. (http://patisserie.keensoftware.com/)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('FormHelper', 'View/Helper');
@renatorib
renatorib / change.php
Last active August 29, 2015 14:25
Change a phrase and store in session ever X seconds
<?php
session_start();
$phrases = array(
'Schizophasia, a mental condition characterized by incoherent babbling (compulsive or intentional, but nonsensical)',
'Logorrhea, a mental condition characterized by excessive talking (incoherent and compulsive)',
'Clanging, a speech pattern that follows rhyming and other sound associations rather than meaning',
'Graphorrhea, a written version of word salad that is more rarely seen than logorrhea in people with schizophrenia.'
);
@renatorib
renatorib / api.js
Last active February 23, 2016 17:28
api
var Api = {
request: function(method, url, data, hooks){
hooks = hooks || {};
fail = hooks.fail || function(){};
done = hooks.done || function(){};
always = hooks.always || function(){};
before = hooks.before || function(){};
spinner = hooks.spinner || false;
reloadOnSuccess = hooks.reloadOnSuccess || false;
@renatorib
renatorib / operator_with_ligatures.md
Last active January 11, 2024 06:45
Using Operator Mono with Fira Code ligatures in Atom.

Using Operator Mono with Fira Code ligatures in Atom.

  1. Open your Atom's Stylesheet
    image

  2. Put this css

atom-text-editor {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
@renatorib
renatorib / Button.jsx
Last active March 10, 2017 03:32
A Button, wrong way.
import React from 'react';
import cn from 'classnames';
type Props = {
type: 'square' | 'round' | 'circle' | 'outline',
color: 'red' | 'orange' | 'green' | 'lightgray',
children: string,
};
const Button = ({ children, type = 'square', color = 'red' }: Props) => {
@renatorib
renatorib / Button.jsx
Last active March 10, 2017 03:36
A Button, wrong way. 2.
import React from 'react';
import cn from 'classnames';
type Props = {
isSquare?: boolean,
isRound?: boolean,
isCircle?: boolean,
isOutline?: boolean,
color: string,
children: string,
@renatorib
renatorib / Button.jsx
Created March 10, 2017 03:48
A Button, better way
import React from 'react';
import cn from 'classnames';
type Props = {
type?: 'normal' | 'outline',
radius?: 'square' | 'round' | 'circle',
size?: 'mini' | 'small' | 'normal' | 'large' | 'xlarge',
theme?: 'action' | 'danger' | 'warning' | 'success' | 'info' | 'grey',
children: string,
};
@renatorib
renatorib / Button.jsx
Created March 10, 2017 04:12
Composable Button
import React from 'react';
import cn from 'classnames';
type Props = {
type?: 'normal' | 'outline',
radius: 'square' | 'round' | 'circle',
size?: 'mini' | 'small' | 'normal' | 'large' | 'xlarge',
theme?: 'action' | 'grey' | 'danger' | 'warning' | 'success' | 'info',
className?: string, // ever allow pass custom className
styles?: string, // custom styles also