Skip to content

Instantly share code, notes, and snippets.

View leventebalogh's full-sized avatar

Levente Balogh leventebalogh

View GitHub Profile
@leventebalogh
leventebalogh / package.json
Last active August 27, 2020 10:41
How to use "nohoist" in Yarn workspaces for multiple packages
{
"name": "your-project",
"version": "0.0.1",
"private": true,
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/pkgA/**"
@leventebalogh
leventebalogh / mocha.sh
Created May 26, 2017 13:26
Watch Tests with Mocha & Babel & React & Enzyme
mocha --watch \
--compilers js:babel-core/register \
--compilers jsx:babel-register \
--require ./.mocha-setup.js \
--recursive ./src/**/*.test.js
@leventebalogh
leventebalogh / Button.test.js
Created May 26, 2017 13:16
Button.test.js - A sample React Component test file
import React from 'react';
import Button from './Button.jsx';
import { expect } from 'chai';
import { shallow } from 'enzyme';
describe('foo', () => {
it('contains spec with an expectation', () => {
expect(shallow(<Button />).contains(<span>FooBar</span>)).to.equal(true);
});
});
@leventebalogh
leventebalogh / Button.jsx
Last active May 26, 2017 13:14
Button.jsx
// @flow
import React from 'react';
type props = {
text: string,
color: 'red' | 'blue' | 'green'
}
export default function Button (props: props) {
return (
@leventebalogh
leventebalogh / generate-component
Last active May 25, 2017 11:50
A script for generating React Components
#! /usr/bin/env node
/**
* Usage:
* 1. "$ chmod +x ./generate-component" ==> make it executable
* 2. "$ cp ./generate-component ~/bin/generate-component && export PATH=~/bin:$PATH" ==> add it to the PATH
* 3. "$ generate component <component-name> <target-path>" ==> run it
*
* Component Layout:
*
@leventebalogh
leventebalogh / passwords.sh
Created October 9, 2016 19:58
Storing passwords (fast and not the safest solution)
# Create a symlink to either /usr/local/bin, /usr/bin, or just add
# the container directory to the PATH.
# Run the script to open and edit your passwords.
FILE="$HOME/passwords.txt"
ENCRYPTED_FILE="$HOME/passwords.txt.gpg"
# Read in passwords
read -s -p "Enter password: " PASSWORD
@leventebalogh
leventebalogh / .gulp-completion.sh
Last active June 12, 2020 14:31
Fast Gulp auto completion
# Adds basic, but really fast autocompletion for gulp.
#
# NOTE!
# Only the tasknames will be autocompleted.
#
# Why?
# ----
# Default gulp completion is really-really slow, hard to work with.
# However this solution is quite dump, it covers 90% of my workflow.
#