Skip to content

Instantly share code, notes, and snippets.

View inawrath's full-sized avatar

Iván Nawrath Castillo inawrath

View GitHub Profile
@inawrath
inawrath / onblur.jsx
Created April 16, 2018 11:44 — forked from pstoica/OnBlurComponent.jsx
onBlur for entire react component
var HelloMessage = React.createClass({
render: function() {
return <div tabIndex="1" onBlur={this.onBlur}>
Hello <input type="text" value="wat"/>
</div>;
},
onBlur: function(e) {
var currentTarget = e.currentTarget;
Install docker CE ubuntu how sudo
# curl -sSL get.docker.io | sh
@inawrath
inawrath / gist:3341b56a98cd1f349965ff87ac4cd6ab
Created June 14, 2017 20:49
Enabling URL token validation varnish
Enabling URL token validation
Last updated December 15, 2016
Token validation allows you to create URLs that expire. Tokens are generated within your web application and appended to URLs in a query string. Requests are authenticated at Fastly's edge instead of your origin server. When Fastly receives a request for the URL, the token is validated before serving the content. After a configurable period of time, the token expires.
Adding custom VCL
To enable token validation, you'll need to create a Varnish configuration named vcl_recv and add the following example code to it.
IMPORTANT: The ability to upload custom VCL code is disabled by default when you sign up. To enable this ability for your account, contact support@fastly.com and request it.
/* make sure there is a token */
if (req.url !~ ".+\?.*token=(\d{10,11})_([^&]+)") {

Varnish 4

curl -s https://packagecloud.io/install/repositories/varnishcache/varnish41/script.deb.sh | sudo bash

Fix poll param in varnish configuration

sudo nano /usr/share/varnish/reload-vcl

@inawrath
inawrath / delete_all_keys
Last active May 22, 2017 18:15
Delete all keys from a regular expression in redis
eval "local _prefix = ARGV[1];\nlocal _keys = redis.call('keys', _prefix);\nfor i, _key in ipairs(_keys) do\n redis.call('del', _key);\nend" 0 REGEX