Skip to content

Instantly share code, notes, and snippets.

Misha Reyzlin gryzzly

Block or report user

Report or block gryzzly

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
@gryzzly
gryzzly / electron-3.0.2-facebook-login.js
Created Oct 5, 2018
Electron 3 + Facebook login with `webRequest.onBeforeRequest` instead of webContents `"did-get-redirect-request"`
View electron-3.0.2-facebook-login.js
ipcMain.on('facebook-sign-on', function onFacebookSignOn(
event,
repromptFacebook,
) {
const options = {
client_id: FACEBOOK_CLIENT_ID,
scope: 'public_profile,email',
redirect_uri: 'https://www.facebook.com/connect/login_success.html',
auth_type: repromptFacebook ? 'rerequest' : '',
View bash+git+integrations.bash
source ~/.git-prompt.sh
#[18:39:16] ~/railscode/dostuff (dev)$
export PS1='\[$(tput setaf 4)\]┌\[$(tput sgr0)\] \[\033[0;36m\][\t]\[\033[0m\] \[\033[0;32m\]\w\[\033[0m\]\[\033[0;33m\]$(__git_ps1)\[\033[0m\]\n\[$(tput setaf 4)\]└\[$(tput sgr0)\] '
source ~/git-completion.bash
@gryzzly
gryzzly / getBoundingBox-center-distance.js
Created Jul 17, 2017
Get bbox from coordinates and distance
View getBoundingBox-center-distance.js
/**
* Get bounding box from set of coordinates [lat,lng] and distance in (deg) adopted to JS
*
* @param {number} distance - distance (deg) from the point represented by centerPoint
* @param {array} centerPoint - two-dimensional array containing center coords [latitude, longitude]
* @description
* Computes the bounding coordinates of all points on the surface of a sphere
* that has a great circle distance to the point represented by the centerPoint
* argument that is less or equal to the distance argument.
* Technique from: Jan Matuschek <http://JanMatuschek.de/LatitudeLongitudeBoundingCoordinates>
@gryzzly
gryzzly / HTMLWebpackPlugin-inline-source.js
Created Feb 17, 2016
A version of HTMLWebpackPlugin that can inline the assets sources
View HTMLWebpackPlugin-inline-source.js
var minifyJS = require('uglify-js').minify;
var minifyHTML = require('html-minifier').minify;
// TODO: use lodash.template when Travis
// updates npm version to >= 3
var _ = require('lodash');
var path = require('path');
var fs = require('fs');
function toMinifiedSource(compilation, path) {
return minifyJS(
@gryzzly
gryzzly / index.js
Last active Aug 29, 2015
requirebin sketch
View index.js
var createRedux = require('redux').createRedux;
var reducer = function (state, action) {
return state;
};
var redux = createRedux(reducer);
redux.dispatch({
type: 'FOO',
payload: {}
});
@gryzzly
gryzzly / Pagination.js
Last active Dec 9, 2016
React Pagination (similar to Github’s pagination)
View Pagination.js
'use strict';
import React, {PropTypes} from 'react';
import classNames from 'classnames';
function last(list) {
return list[list.length - 1];
}
function areAdjacent(prev, curr) {
return last(prev).index + 1 === curr[0].index;
@gryzzly
gryzzly / index.js
Created Jun 18, 2015
requirebin sketch
View index.js
var items = [
{ key: 'mishacloudcom' },
{ key: 'jamescloudcom' },
{ key: '#feedbackcloudcom' },
{ key: '#lalala.comfreenode' },
{ key: '#emberjsfreenode' },
{ key: '#reactjsfreenode' },
{ key: '#devcloud.com' },
{ key: '#ircv3-devcloud.com' },
{ key: '#devfreenode' }
@gryzzly
gryzzly / debounced-input.js
Last active Dec 15, 2016
Ember Debounced Input
View debounced-input.js
//
// To be used like this:
//
//
// {{debounced-input
// placeholder="1000000"
// value=propertyName
// debounceWait=300 <-- debounce wait value
// fireAtStart=false <-- corresponds to Ember.run.debounce’s 4th param, if false, will run at the end of wait period
// class="form-control" <-- all regular text input attributes work
View gist:b09e3159b8b7bfaf8e94

Example of a tedious task when using backbone MVC

You have three components each of which might have certain state. These components depend on one particular component that emits events. These three views have to all define the emitting component as a dependency and manually subscribe to the events in order to sync the state.

var View = require('lib/View'),
    source = require('source'); 
    
module.exports = View.extend({
@gryzzly
gryzzly / logical OR vs array::some.md
Last active Aug 29, 2015
logical OR vs array::some
View logical OR vs array::some.md
return !!(// double negation is required since logical operators dont always return Booleans
  ENV_VAR || 
  SomeLongStore.get('key') ||
  SomeConfig.get('layer', 'sub-layer') === 'required-value' ||
  this.anotherLongCondition()
)

vs

You can’t perform that action at this time.