Skip to content

Instantly share code, notes, and snippets.

View chodorowicz's full-sized avatar

Jakub Chodorowicz chodorowicz

View GitHub Profile
@chodorowicz
chodorowicz / LoginStore.js
Last active August 29, 2015 14:25
alt bind public methods strategies
class LoginStore {
constructor() {
this.isLoggedIn = false;
this.bindActions(LoginActions);
this.name = 'John';
this.surname = 'Snow';
this.exportPublicMethods({
getIsLoggedIn: () => this.isLoggedIn,
getFullName: () => this.getFullName(),
@chodorowicz
chodorowicz / gist:c4657d7f1fd353a7bd8b
Last active August 29, 2015 14:27 — forked from BinaryMuse/gist:3b0a4ba166ac81840cab
Async fetches initiated by the store when necessary
// Component
var AnswerDisplay = React.createClass({
mixins: [FluxMixin, StoreWatchMixin("answer")],
getStateFromFlux() {
var flux = this.getFlux(),
answerStore = flux.store("answer");
return {
@chodorowicz
chodorowicz / gist:77db61059b7238717233
Created December 8, 2015 12:30
check position on input number
const arrowCodesVertical = [38, 40];
const arrowCodesHorizontal = [37, 39];
console.log(event.keyCode);
// console.log(this.myTextInput);
let s = window.getSelection();
let len = s.toString().length;
let isLeftEdge, isRightEdge;
s.modify('extend', 'backward', 'character');
if (len < s.toString().length) {
// It's not at the beginning of the input, restore previous selection
@chodorowicz
chodorowicz / keybase.md
Created February 12, 2016 13:41
keybase.md

Keybase proof

I hereby claim:

  • I am chodorowicz on github.
  • I am chodorowicz (https://keybase.io/chodorowicz) on keybase.
  • I have a public key whose fingerprint is 7ED3 1C65 07A7 920E 5D0B 2F56 B703 B90B C3D0 6739

To claim this, I am signing this object:

@chodorowicz
chodorowicz / redux-ecosystem.md
Last active February 9, 2017 00:41
From Alt to Redux ecosystem (redux-actions, redux-thunk, react-redux, redux-saga)

From Alt to Redux ecosystem (redux-actions, redux-thunk, react-redux, redux-saga)

Jakub Chodorowicz

Young/Skilled

@chodorowicz
github.com/chodorowicz
@chodorowicz
chodorowicz / webpack.config.js
Created April 28, 2016 08:34
wepback exports sample config
var config = {
resolve: {
alias: {
waypoints: 'waypoints/lib/noframework.waypoints',
},
},
module: {
loaders: [
{
test: /node_modules\/waypoints\/lib\/noframework\.waypoints\.js$/,
@chodorowicz
chodorowicz / main.js
Last active June 29, 2016 18:13
Load HTML using pjax with CSS fade in / out transition
var $pjaxContainer = $('.js-pjaxContainer');
function pjaxLoad(target) {
$.pjax({
url: target,
container: '.js-pjaxContainer',
fragment: '.js-pjaxContainer',
});
}
@chodorowicz
chodorowicz / browsersync.js
Last active September 1, 2018 14:27
BrowserSync custom host domain + snippet options
const browserSync = require('browser-sync').create();
const port = process.env.PORT || 8080;
const customDomain = environment.DEV_DOMAIN ? `${environment.DEV_DOMAIN}` : 'localhost';
browserSync.init('**/*.css', {
logPrefix: 'Showroom:',
proxy: `localhost:${port}`,
open: false,
host: customDomain,
port: 3000,
ghostMode: false, /* don't mirror interactions in other browsers */
@chodorowicz
chodorowicz / gulpfile.js
Created May 27, 2016 14:24
Lost PostCSS Sass + Gulp setup
var gulp = require('gulp');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var browserSync = require('browser-sync');
var lost = require('lost');
gulp.task('sass', function () {
gulp.src('./frontend/sass/main.scss')
.pipe(sass().on('error', sass.logError))
@chodorowicz
chodorowicz / watch.sh
Created June 2, 2016 20:40
fswatch + xargs + duck + export variables to environment to go around xargs 255 bytes limit when expanding command
export syncpath="/path/to/folder/"
export remotepath="sftp://aaa@000.000.000.000:2222/remote/path/"
export duckParameters="-y -existing overwrite -p PASSWORD --upload";
fswatch -0 ${syncpath} | xargs -0 -I % -t bash -c 'f="%"; rel=${f#"${syncpath}"}; duck ${duckParameters} ${remotepath}${rel} "${f}"; echo ${rel};'