Skip to content

Instantly share code, notes, and snippets.

@sebcode
sebcode / gist:4a43760ab4abaf078f987f1dd94d4178
Created April 6, 2017 18:17
Replace @autoBind decorator with class instance properties
// https://github.com/andreypopp/autobind-decorator
// https://github.com/facebook/codemod
// Example replacement:
// - @autobind onClick(e: SyntheticEvent) {
// + onClick = (e: SyntheticEvent) => {
codemod -m -d . --extensions js \
'@autobind\ ([a-zA-Z0-9]+)\(([^)]*)\)' \
'\1 = (\2) =>'
@geoffreydhuyvetters
geoffreydhuyvetters / react_fiber.md
Last active January 13, 2023 06:49
What is React Fiber? And how can I try it out today?
@jsdf
jsdf / immutableJSFormatter.js
Last active May 19, 2022 10:51
Chrome devtools formatter for Immutable-js
const immutableJSFormatter = {
header(x) {
if (x && x.toJS) return ['span', {}, x.toString()];
return null;
},
hasBody(x) {
return x && x.toJS;
},
body(x) {
return ['span', {}, JSON.stringify(x.toJS(), null, 2)];
@andrewgleave
andrewgleave / ContentEditableLabel.js
Last active September 15, 2016 09:32
An editable React.js label element based on the contenteditable attribute
/** @jsx React.DOM */
'use strict';
var React = require('react');
var ContentEditableLabel = React.createClass({
propTypes: {
tag: React.PropTypes.func,
@branneman
branneman / better-nodejs-require-paths.md
Last active April 25, 2024 13:21
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@ToastShaman
ToastShaman / SftpServiceTest.java
Created November 13, 2013 18:40
Using an embedded Apache MINA SSHD server in a unit test to verify that your code is able to upload a file through SFTP. This unit tests uses JSch as the client to speak to an embedded Apache MINA sftp server and verifies that the upload of a text file was successful.
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@mdaniel
mdaniel / Vagrantfile
Last active February 21, 2021 10:30
Provision a virtual machine for building ChromeOS using Vagrant <http://www.vagrantup.com>. Just download this into a directory, name it ``Vagrantfile`` (if it isn't already), run ``vagrant up`` followed by ``vagrant ssh`` and you'll see two shell scripts there, ready to sync up the ChromeOS source code.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu1204_64"
@thomseddon
thomseddon / gist:4703810
Last active December 27, 2016 02:58 — forked from nobuf/gist:3419910
Supporting placeholder on IE9 with AngularJS (without jQuery) > Removed jQuery dependency > Slight optimisation in retrieving placeholder text
angular.module('test', [])
.directive('placeholder', function($timeout){
var i = document.createElement('input');
if ('placeholder' in i) {
return {}
}
return {
link: function(scope, elm, attrs){
if (attrs.type === 'password') {
return;
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@admackin
admackin / .bashrc
Last active February 10, 2022 22:06
Sane SSH_AUTH_SOCK handling for Screen and Tmux, so that new SSH agents created by subsequent logons are still usable.
_ssh_auth_save() {
ln -sf "$SSH_AUTH_SOCK" "$HOME/.ssh/ssh-auth-sock.$HOSTNAME"
}
alias screen='_ssh_auth_save ; export HOSTNAME=$(hostname) ; screen'
alias tmux='_ssh_auth_save ; export HOSTNAME=$(hostname) ; tmux'