Skip to content

Instantly share code, notes, and snippets.

import React, { Component, PropTypes } from 'react';
import stringToClassName from '../helpers/stringToClassName';
export default class FieldInput extends Component {
static propTypes = {
input: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.string,
onChange: PropTypes.func
}),
@thomasmaclean
thomasmaclean / AlertWrapper.js
Last active December 27, 2017 16:29
Redux Alert system
import React, { Component, PropTypes } from 'react';
const enhanceWithClickOutside = require('react-click-outside');
class AlertWrapper extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
onClickOutside: PropTypes.func
};
@thomasmaclean
thomasmaclean / FilterString.sol
Created October 6, 2017 17:28
Solidity contract that filters out non-ASCII characters and allow only non-boundary, single-spaces
pragma solidity ^0.4.11;
contract FilterString {
// Filters out non-ASCII characters and allow only non-boundary, single-spaces
function _filter(string str) public returns (string) {
bytes memory bytesStr = bytes(str);
bytes memory valid = new bytes(bytesStr.length);
uint chr = 0;
uint ltrim = 0;
for (uint i = 0; i < bytesStr.length; i++) {
@thomasmaclean
thomasmaclean / StringToLower.sol
Last active May 19, 2020 21:40
Ethereum/Solidity toLower() equivalent, to transform strings to lowercase
pragma solidity ^0.4.11;
contract StringToLower {
function _toLower(string str) internal returns (string) {
bytes memory bStr = bytes(str);
bytes memory bLower = new bytes(bStr.length);
for (uint i = 0; i < bStr.length; i++) {
// Uppercase character...
if ((bStr[i] >= 65) && (bStr[i] <= 90)) {
// So we add 32 to make it lowercase