Skip to content

Instantly share code, notes, and snippets.

@burtyish
burtyish / regex collection.txt
Last active December 30, 2015 11:35
Some useful regexs for migrating cjsx files to ES6
// require -> import
([\w{},]+)[\s]?=[\s]?require[\s]?[(]?['"]([\w\/.-]+)['"][)]?
import $1 from '$2';
// module.exports -> export default
module.exports[\s]?=[\s]?([\w]+)
export default $1;
// @ -> this.
@

The waitFor function wraps a component. This component will be rendered only once all promises in the promises iterable are resolved.

Options:

  • meanwhile: A react node which will be rendered until promises are resolved.
  • error: A react ndoe to be renderd in case any of the promises are rejected.

This is my first attempt at a higher-order component, inspired by Dan Abramov's post.

@burtyish
burtyish / uservoice-trigger.js
Created August 18, 2015 11:40
UserVoice Widget Trigger React Component
import React from 'react';
import _ from 'lodash';
const UserVoiceTrigger = React.createClass({
propTypes: {
id: React.PropTypes.string.isRequired
},
getDefaultProps() {
@burtyish
burtyish / page-visibility-service.js
Last active September 19, 2019 20:55
Page Visibility Service for a Redux/Flux app
/* Based on http://www.html5rocks.com/en/tutorials/pagevisibility/intro/ */
class PageVisibilityService {
constructor(store) {
this.store = store;
this.prop = this.getHiddenProp();
this.register();
}
getHiddenProp(){
@burtyish
burtyish / readme.md
Last active March 14, 2016 13:57
React & Redux resources
@burtyish
burtyish / Typescript
Last active April 24, 2018 07:41
Webstorm React component file templates
import React from 'react';
interface IProps {
}
export class {$NAME} extends React.Component<IProps, IState> {
public render() {
return (
);
@burtyish
burtyish / intercom.rtl.css
Last active January 3, 2018 13:35
RTL intercom alignment fix
body.rtl #intercom-container .intercom-app.intercom-app-left-aligned [class^=intercom-] {
right: auto;
}
@burtyish
burtyish / no-todos.sh
Last active April 17, 2018 10:48
pre-push git hook, prevents pushing if any new `TODO`s were added
#!/bin/sh
# Place this file in the `.git/hooks` directory
HITS=0
for FILE in `git diff origin/HEAD --name-only`; do
grep 'TODO' $FILE 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo 'New TODO found in file: ' $FILE
((HITS++))
exit 1
@burtyish
burtyish / yishai.git.zsh
Last active June 12, 2018 07:40
Custom zsh configuration. Place these files in ~/.oh-my-zsh/custom/
alias gbD="git branch -D "
alias gcom="git checkout origin/master"