Skip to content

Instantly share code, notes, and snippets.

View agrcrobles's full-sized avatar

Garcia agrcrobles

  • Barcelona
View GitHub Profile
@JSchaenzle
JSchaenzle / CreateAccount.jsx
Last active April 21, 2018 14:47
React Form Validation
const fieldValidations = [
ruleRunner("name", "Name", required),
ruleRunner("emailAddress", "Email Address", required),
ruleRunner("password1", "Password", required, minLength(6)),
ruleRunner("password2", "Password Confirmation", mustMatch("password1", "Password"))
];
export default class CreateAccount extends React.Component {
constructor() {
// ...
@khanlou
khanlou / Fonts.swift
Created October 6, 2016 21:10
Print all fonts in Swift 3
UIFont.familyNames.forEach({ familyName in
let fontNames = UIFont.fontNames(forFamilyName: familyName)
print(familyName, fontNames)
})
@orta
orta / add_flow.sh
Last active February 22, 2019 17:39
Add flow to all your JS files
#!/bin/bash
# Based on http://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files
for i in *.js
do
if ! grep -q @flow $i
then
(echo "" & echo "/* @flow */") > flowificator
cat flowificator $i >$i.new && mv $i.new $i
rm flowificator
import React from "react";
import { withRouter } from "react-router";
class Test extends React.Component {
constructor(props) {
super(props);
this.state = {
};
}
componentWillReceiveProps(nextProps) {
@nuitsjp
nuitsjp / MockExtensions.cs
Created December 22, 2016 10:05
You can easily publish PropertyChanged events from the Moq.
public static class MockExtensions
{
public static IReturnsResult<T> NotifyPropertyChanged<T, TResult>(this Mock<T> mock, Expression<Func<T, TResult>> expression, TResult setupValue) where T : class, INotifyPropertyChanged
{
var memberExpression = expression.Body as MemberExpression;
if (memberExpression == null) throw new ArgumentException("expression.Body is not MemberExpression");
var returnResult = mock.Setup(expression).Returns(setupValue);
mock.Raise(m => m.PropertyChanged += null, new PropertyChangedEventArgs(memberExpression.Member.Name));
@Vadorequest
Vadorequest / MyComponent.js
Last active December 5, 2017 19:42
HOC component to get the history using React-Router v4 (alpha)
import withRouter from './utils/withRouter';
const MyComponent = ({ history }) =>
<button onClick={() => history.goBack()}>Back</button>
export default compose(
withRouter,
)(MyComponent);
var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
@fdidron
fdidron / App.js
Last active April 11, 2023 13:54
React Router v4 Auth
//Usage
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import Route from './AuthRoute';
import Login from './Login';
import Private from './Private';
export default () =>
<Router>
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A