Skip to content

Instantly share code, notes, and snippets.

View pwittchen's full-sized avatar
🎯
Focusing

Piotr Wittchen pwittchen

🎯
Focusing
View GitHub Profile
@pwittchen
pwittchen / ifconfig.js
Created January 17, 2017 16:23
executing shell command via JS - on Linux nodejs ifconfig.js; on macOS node ifconfig.js
var process = require('child_process');
process.exec('ifconfig',function (err,stdout,stderr) {
if (err) {
console.log("\n"+stderr);
} else {
console.log(stdout);
}
});
@pwittchen
pwittchen / using-rxjs-instead-of-flux-with-react.md
Created January 16, 2017 13:11 — forked from justinwoo/using-rxjs-instead-of-flux-with-react.md
Using RxJS instead of Flux with React to organize data flow

Reposted from Qiita

For almost a year now, I've been using this "flux" architecture to organize my React applications and to work on other people's projects, and its popularity has grown quite a lot, to the point where it shows up on job listings for React and a lot of people get confused about what it is.

Why I'm tired of using and teaching flux

There are a billion explainations on the internet, so I'll skip explaining the parts. Instead, let's cut to the chase -- the main parts I hate about flux are the Dispatcher and the Store's own updating mechanism.

If you use a setup similar to the examples in facebook/flux, and you use flux.Dispatcher, you probably have this kind of flow:

@pwittchen
pwittchen / git-aliases.md
Created January 11, 2017 15:55 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@pwittchen
pwittchen / render-react-with-rxjs.md
Created December 12, 2016 09:29 — forked from zxbodya/render-react-with-rxjs.md
React with RxJS, reactive way :)

Observable React elements with RxJS

Note: if you want to skip history behind this, and just looking for final result see: rx-react-container

When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.

But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...

Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.

@pwittchen
pwittchen / brainfuck.py
Created December 7, 2016 19:34 — forked from elliotchance/brainfuck.py
Write Your Own Brainfuck Compiler
import sys
import ply.yacc as yacc
import ply.lex as lex
tokens = (
'INCREMENT',
'DECREMENT',
'SHIFT_LEFT',
'SHIFT_RIGHT',
'OUTPUT',
@pwittchen
pwittchen / readIp.sh
Created September 6, 2016 10:31
get ip used in local network (works on OS X)
ifconfig | grep inet | awk 'END{print}' | awk '{print $2}'
for(final Annotation annotation : this.getClass().getAnnotations()) {
final Class<? extends Annotation> annotationType = annotation.annotationType();
final boolean classIsAnnotated = annotationType.equals(MyCustomAnnotation.class);
}
@pwittchen
pwittchen / hybris_banner.txt
Created May 30, 2016 13:45
Hybris ASCII art
__ __ _ _ _
/ / __ __ \ \ | |__ _ _| |__ _ __(_)___
| | \ \ / / | | | '_ \| | | | '_ \| '__| / __|
| | \ V / | | | | | | |_| | |_) | | | \__ \
| | \ \ | | |_| |_|\__, |_.__/|_| |_|___/
\_\ \_\ /_/ |___/
@pwittchen
pwittchen / killProcessByName.sh
Created May 10, 2016 10:16
Killing Linux process by name
ps aux | grep outlook | awk '{print $2}' | xargs kill -9
@pwittchen
pwittchen / static_server.js
Created April 27, 2016 13:42 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);