Skip to content

Instantly share code, notes, and snippets.

View Strajk's full-sized avatar
🐣
knock knock…

Pavel 'Strajk' Dolecek Strajk

🐣
knock knock…
View GitHub Profile
var Thing = React.createClass({
render () {
return (
<div>
{stuff.map(thing => ( // <-- use ( not {
<OtherThing thing={thing}/>
))}
</div>
);
}
var React = require('react');
var $ = require('jquery');
require('jquery-ui');
var Dialog = React.createClass({
componentDidMount: function() {
this.portalNode = this.getDOMNode();
this.$portal = $(this.portalNode);
this.$portal.dialog({
autoOpen: false,
// I'll have a entry point for the server app, like server.js,
// and and entry for the client app, like client.js
// in server.js I do this:
IS_CLIENT = false;
// in client.js I do this:
IS_CLIENT = true;
// Then anywhere in your code you can do this:
@sibelius
sibelius / Codemod RN24 to RN25.md
Last active November 9, 2016 13:09
Codemod React Native 24 imports to RN25 imports

README

Why this transform is necessary?

Until React Native 24, you import React from 'react-native' package, but this will change on RN 25, you will need to import React from 'react'. You probably have many files that does this, so I've created a codemod to save you a bunch of time

How to use this

  • Install jscodeshif
@froots
froots / Car.js
Last active June 6, 2018 23:27
Stubbing module dependencies in ES2015 unit tests using Sinon.js or TestDouble.js.
// in /src directory
import {kphToMph} from './convert';
class Car {
constructor(speed) {
this.speed = speed;
}
getSpeedInMph() {
@btnwtn
btnwtn / 50.js
Last active September 18, 2019 16:09
Automat dat +50 clapping on Medium.com
(() => {
const up$ = new MouseEvent("mouseup", { bubbles: true });
const down$ = new MouseEvent("mousedown", { bubbles: true });
const node = document.querySelector(
`.js-postActionsFooter button[data-action="multivote"]`
);
let attempts = 0;
@yyuu
yyuu / circle.rb
Last active December 7, 2019 13:10
A simple script to convert Circle CI configurations from circle.yml (1.0) to .circleci/config.yml (2.0)
#!/usr/bin/env ruby
require "fileutils"
require "shellwords"
require "yaml"
CIRCLE1_DEFAULT_CACHE_DIRECTORIES = [
"vendor/bundle",
"~/.m2",
"~/.bundle",
@vegasje
vegasje / usability.md
Last active March 9, 2020 19:30
PLEASE DO NOT USE THIS. See http://userium.com/ instead.

PLEASE DO NOT USE THIS. See http://userium.com/ instead.

Usability Checklist

User Experience

  • Personalized features. Currency, language, country specific deals, taxes, or delivery options are changed based on user's location.
  • Registering provides value to users. For example a "Free Trial" button communicates a clear benefit, but a "Register" button doesn't. Unnecessary registration is avoided.
@panthomakos
panthomakos / benchmark.rb
Created May 3, 2012 20:06
Benchmark Your Bundle
#!/usr/bin/env ruby
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
]
@brenopolanski
brenopolanski / npm-list-globally.md
Created November 1, 2016 19:34
Listing globally installed NPM packages and version
npm list -g --depth=0