Skip to content

Instantly share code, notes, and snippets.

View khadorkin's full-sized avatar

Dima Khadorkin khadorkin

  • Mobile Roadie
  • Vilnius, Lithuania
  • 12:35 (UTC +03:00)
View GitHub Profile
@khadorkin
khadorkin / ssl.sh
Created February 12, 2018 14:46 — forked from huozhi/ssl.sh
generate ssl keys for localhost
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
# only enter the Common Name: your ip address or your domain name
@khadorkin
khadorkin / Python SimpleHTTPServer with SSL
Created February 12, 2018 14:01 — forked from rozifus/Python SimpleHTTPServer with SSL
Python SimpleHTTPServer with SSL
# useful for running ssl server on localhost
# which in turn is useful for working with WebSocket Secure (wss)
# copied from http://www.piware.de/2011/01/creating-an-https-server-in-python/
@khadorkin
khadorkin / sketch-loader.js
Created January 31, 2018 08:09 — forked from JoelBesada/sketch-loader.js
Webpack Sketch Loader
const JSZip = require('jszip')
const { parseBuffer } = require('bplist-parser')
const { isObject, each, find } = require('lodash')
const parseArchivedValue = value => {
return parseBuffer(new Buffer(value, 'base64'))
}
const parseArchivedString = obj => {
const { $objects } = parseArchivedValue(
@khadorkin
khadorkin / index.html
Created December 26, 2017 13:50 — forked from mourner/index.html
Mapbox GL JS Puppeteer benchmark
<!doctype html>
<meta charset="utf-8">
<title>Benchmark</title>
<body></body>
<style>html, body, #map { height: 100%; margin: 0; } </style>
<div id="map"></div>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.0/mapbox-gl.js'></script>
<!-- <script src="mapbox-gl.js"></script> -->
@khadorkin
khadorkin / index.js
Created October 19, 2017 23:17 — forked from cereallarceny/index.js
Server-side rendering with create-react-app (Fiber), React Router v4, Helmet, Redux, and Thunk
// Ignore those pesky styles
require('ignore-styles');
// Set up babel to do its thing... env for the latest toys, react-app for CRA
require('babel-register')({
ignore: /\/(build|node_modules)\//,
presets: ['env', 'react-app']
});
// Now that the nonsense is over... load up the server entry point
@khadorkin
khadorkin / infinite.js
Created March 22, 2017 19:50 — forked from threepointone/infinite.js
infinite scrolling pattern with react fiber (featuring intersection observers)
// inifinite scrolling of content without extra wrappers
const { render, findDOMNode } = ReactDOMFiber
class App extends React.Component {
render() {
// wrap the root element with an Intersection Observer, exposing .observe for children
return <Intersection>
<div style={{ height: 200, overflow: 'auto' }}>
<Page offset={0} count={10} />
</div>
@khadorkin
khadorkin / package.json
Created October 7, 2016 10:31 — forked from oroce/package.json
run eslint only on changed (*.js files) files using pre-commit
{
"scripts": {
"eslint": "LIST=`git diff-index --name-only HEAD | grep .*\\.js | grep -v json`; if [ \"$LIST\" ]; then eslint $LIST; fi"
},
"devDependencies": {
"pre-commit": "0.0.7",
"eslint": "~0.5.1"
},
"pre-commit": [
"eslint"
@khadorkin
khadorkin / 01_closure.js
Created September 27, 2016 09:54 — forked from skarankevich/01_closure.js
FE Test
(function() {
console.log(abc);
var abc = "abc";
console.log(myFunc());
function myFunc() {
var def = abc + 'def';
@khadorkin
khadorkin / app.js
Created September 13, 2016 19:01 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
import {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLNonNull,
GraphQLList,
GraphQLString,
} from 'graphql';
// data