Skip to content

Instantly share code, notes, and snippets.

View .bashrc
#process mgmt
alias process='ps aux | grep -v grep | grep '
alias c='clear'
alias cc='pbcopy <'
# npm scripts
alias ni='npm i'
alias nic='rm -rf node_modules && npm i'
xtabbas / SnapCarousel.swift
Created May 10, 2020
A carousel that snap items in place build on top of SwiftUI
View SnapCarousel.swift
// SnapCarousel.swift
// prototype5
// Created by xtabbas on 5/7/20.
// Copyright © 2020 xtadevs. All rights reserved.
import SwiftUI
andywer /
Last active Oct 16, 2021
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

fson /
Created Oct 18, 2015
Rapid prototyping with Relay (Reactive 2015 lightning talk proposal)

This is a proposal for a lightning talk at the Reactive 2015 conference.

NOTE: If you like this, star the Gist - the amount of stars decides whether it makes the cut!

Rapid prototyping with Relay

Relay makes data fetching in React apps simpler, by letting you declare the data needs of your components instead of writing complex imperative code. React, Relay, GraphQL and the other complementary tools are changing how apps are built.

sebmarkbage / Enhance.js
Last active Sep 11, 2021
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
componentDidMount() {
this.setState({ data: 'Hello' });
render() {
t2 / application.rb
Created Dec 12, 2011
Formatting Rails form elements for Twitter Bootstrap error validation
View application.rb
ActionView::Base.field_error_proc = do |html_tag, instance|
html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe
# add nokogiri gem to Gemfile
elements = Nokogiri::HTML::DocumentFragment.parse(html_tag).css "label, input"
elements.each do |e|
if e.node_name.eql? 'label'
html = %(<div class="clearfix error">#{e}</div>).html_safe
elsif e.node_name.eql? 'input'
if instance.error_message.kind_of?(Array)
html = %(<div class="clearfix error">#{html_tag}<span class="help-inline">&nbsp;#{instance.error_message.join(',')}</span></div>).html_safe