Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / main.js
Created July 15, 2015 12:20
photoswipe disable zoom
{
zoomEl: false,
maxSpreadZoom: 1,
getDoubleTapZoom: function(isMouseClick, item) {
return item.initialZoomLevel;
}
pinchToClose: false
}
var BrowserDetector = (function() {
var exports = {};
exports.isChrome = navigator.userAgent.indexOf('Chrome') > -1;
exports.isExplorer = navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0;
exports.isFirefox = navigator.userAgent.indexOf('Firefox') > -1;
exports.isSafari = navigator.userAgent.indexOf("Safari") > -1;
exports.isOpera = navigator.userAgent.toLowerCase().indexOf("op") > -1;
if ((exports.isChrome)&&(exports.isSafari)) {exports.isSafari=false;}
if ((exports.isChrome)&&(exports.isOpera)) {exports.isChrome=false;}
@chodorowicz
chodorowicz / ProductDetail.jsx
Last active August 29, 2015 14:23
Get single item in Alt (Flux) + React
var React = require("react");
var ProductsStore = require('../../stores/ProductsStore');
function getState(id) {
var product = ProductsStore.getProduct(id);
return {
product: product
};
}
@chodorowicz
chodorowicz / webpack.config.js
Created June 23, 2015 08:56
webpack react babel config
module.exports = {
entry: [ __dirname + '/app/js/main.jsx'],
output: {
path: __dirname + '/web',
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
module.exports = {
entry: [ __dirname + '/app/js/App.jsx'],
output: {
path: __dirname + '/web',
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.jsx$/,
loader: 'jsx-loader?insertPragma=React.DOM&harmony'
@chodorowicz
chodorowicz / gulp-pipes-sharing.js
Created November 21, 2014 09:45
gulp pipe sharing using lazypipe
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var coffee = require('gulp-coffee');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var lazypipe = require('lazypipe');
// give lazypipe
var jsTransform = lazypipe()
.pipe(jshint)