Skip to content

Instantly share code, notes, and snippets.

View agilgur5's full-sized avatar

Anton Gilgur agilgur5

View GitHub Profile
@danielearwicker
danielearwicker / example.ts
Last active February 19, 2017 09:31
Remox (Redux in MobX)
import { autorun } from "mobx";
import { createStore, Action, Reducer } from "./remox"
interface Person { firstName: string; lastName: string; }
interface SetFirstName { type: "SET_FIRST_NAME", newFirstName: string; }
interface SetLastName { type: "SET_LAST_NAME", newLastName: string; }
function personReducer(state:Person, action: SetFirstName | SetLastName) {
@aripalo
aripalo / watchpack-ignore-node-modules.sh
Last active June 30, 2017 14:08
Using webpack and its polling watch feature (via watchpack) can drain CPU which is due to watchpack polling all the npm deps within node_modules folder. This is a quick hack/fix until proper fix is merged & available in watchpack.
#!/bin/bash
# Should be used until https://github.com/webpack/watchpack/pull/23 is merged and available in npm
# See https://github.com/webpack/watchpack/issues/2#issuecomment-135204573 for more info
# Ensure we have npm
if ! hash npm 2>/dev/null; then
echo 'No NPM installed!'
exit 1
fi
@megamaddu
megamaddu / fetch-helpers.js
Last active December 23, 2019 19:44
Fetch API Helpers
import fetch from 'isomorphic-fetch'
const setupRequestOptions = (options = {}, overrideMethod) => {
if (overrideMethod) options.method = overrideMethod
if (!options.headers) options.headers = {}
options.credentials = 'same-origin'
return options
}
const setupJsonRequestOptions = (options, overrideMethod) => {

tracked npm

@tracked is a decorator for Preact that makes working with state values no different than properties on your component instance.

It's one 300 byte function that creates a getter/setter alias into state/setState() for a given key, with an optional initial value. The "magic" here is simply that it works as a property decorator rather than a function, so it appears to integrate directly into the language.

tracked has no dependencies and works with any component implementation that uses this.state and this.setState().

Installation

@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
@benjick
benjick / persist.js
Created June 15, 2017 11:09
mobx-state-tree persist PoC
/* globals localStorage */
import { onSnapshot, applySnapshot } from 'mobx-state-tree';
import Storage from './storage';
export const persist = (name, store, options, schema = {}) => {
let hydrated = false;
let storage = options.storage;
if (typeof localStorage !== 'undefined' && localStorage === storage) {
@rajeevkannav
rajeevkannav / pdf2htmlEX.sh
Last active March 29, 2022 18:28
Install CMake, pkg-config,GNU Getopt,GCC,poppler,fontforge,pdf2htmlEX in Ubuntu 15.05
#!/bin/bash
# Ubuntu Developer Script For pdf2htmlEx
# Created by Rajeev Kannav Sharma
# http://rajeevkannav.github.io/
#
#
# Downloads and configures the following:
#
# CMake, pkg-config
# GNU Getopt
@jordansissel
jordansissel / Procfile
Created April 5, 2012 19:29
Jenkins on Heroku
# Only listen on http; disable ajp and https
web: java -jar jenkins.war --httpPort=$PORT --ajp13Port=-1 --httpsPort=-1
@voxxit
voxxit / USING-VAULT.md
Last active July 7, 2022 03:02
Consul + Vault + MySQL = <3
git clone https://gist.github.com/dd6f95398c1bdc9f1038.git vault
cd vault
docker-compose up -d
export VAULT_ADDR=http://192.168.99.100:8200

Initializing a vault:

vault init
@konklone
konklone / ssl.rules
Last active August 8, 2023 08:39
nginx TLS / SSL configuration options for konklone.com
# Basically the nginx configuration I use at konklone.com.
# I check it using https://www.ssllabs.com/ssltest/analyze.html?d=konklone.com
#
# To provide feedback, please tweet at @konklone or email eric@konklone.com.
# Comments on gists don't notify the author.
#
# Thanks to WubTheCaptain (https://wubthecaptain.eu) for his help and ciphersuites.
# Thanks to Ilya Grigorik (https://www.igvita.com) for constant inspiration.
server {