Skip to content

Instantly share code, notes, and snippets.

Tomek Fijoł tomek-f

Block or report user

Report or block tomek-f

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View git nuke
git branch | egrep -v "(master|develop)" | sed 's/origin\//:/' | xargs -n 1 git branch -D
git branch | egrep -v "(master|develop)" | sed 's/origin\//:/' | xargs -n 1 git branch -d
git branch -r --merged | egrep -v "(master|develop)" | sed 's/origin\//:/' | xargs -n 1 git push origin
View negative-array-indices.js
// http://exploringjs.com/es6/ch_proxies.html#_negative-array-indices-get
function createArray(...elements) {
let handler = {
get(target, propKey, receiver) {
let index = Number(propKey);
// Sloppy way of checking for negative indices
if (index < 0) {
propKey = String(target.length + index);
}
View boolean_identities.js
// NOT Conversion
!!A == A
!!B == B
!!C == C
// AND to OR Conversion
A && B == !(!A || !B)
// OR to AND Conversion
A || B == !(!A && !B)
View de_morgans_laws.js
// These two are equivalent
!A && !B == !(A || B)
// Also these two
!A || !B == !(A && B)
View withAuthentication.jsx
function withAuthentication(WrappedComponent) {
const ModifiedComponent = (props) => {
if (!props.isAuthenticated) {
return <Redirect to="/login" />;
}
return (<WrappedComponent { ...props } />);
};
const mapStateToProps = (state) => ({
View simple-proxy.js
const express = require('express');
const request = require('request');
const {
PROXIED_HOST: proxiedHost = 'https://tomekf.pl',
PROXY_PORT: proxyPort = 1337,
LOCAL_PORT: localPort = 8000,
LOCAL_HOST: localHost = 'http://localhost',
} = process.env;
View JSONP-proxy.js
const http = require('http');
const { parse: urlParse } = require('url');
const { parse: querystringParse } = require('querystring');
const log = require('fancy-log');
const chalk = require('chalk');
const env = require('minimist')(process.argv.slice(2));
const getUrlVar = (where, item) => querystringParse(urlParse(where).query)[item];
const line = '-'.repeat(80);
View eslint-latest.md

npm

npm info "eslint-config-airbnb@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm i "eslint-config-airbnb@latest"
npm info "eslint-config-airbnb-base@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm i "eslint-config-airbnb-base@latest"

yarn (and npm)

View pipe.js
const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x);
const fn1 = s => s.toLowerCase();
const fn2 = s => s.split('').reverse().join('');
const fn3 = s => s + '!'
const newFunc = pipe(fn1, fn2, fn3);
const result = newFunc('Time'); // emit!
@tomek-f
tomek-f / wav-mp3
Created Oct 3, 2017 — forked from championofblocks/wav-mp3
Command line bash to convert all wav to mp3
View wav-mp3
for i in *.wav; do lame -b 320 -h "${i}" "${i%.wav}.mp3"; done
You can’t perform that action at this time.