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 / 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

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 / 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})_([^&]+)") {
Install docker CE ubuntu how sudo
# curl -sSL get.docker.io | sh
@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;
@inawrath
inawrath / example.js
Created June 26, 2018 16:03
Multiple request axios
axios.all([
axios.get('http://google.com'),
axios.get('http://apple.com')
])
.then(axios.spread((googleRes, appleRes) => {
// do something with both responses
});
@inawrath
inawrath / index.html
Last active July 19, 2018 06:23
Example ReactJS
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNext Bin Sketch</title>
<!-- put additional styles and scripts here -->
<link href="https://fonts.googleapis.com/css?family=Glass+Antiqua" rel="stylesheet" type="text/css">
<!-- CSS Reset -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
@inawrath
inawrath / clip.py
Created November 7, 2018 14:49
Copy to clipboard in IPython
from IPython.core.magic import register_line_magic
@register_line_magic
def clip(line):
global_dict = globals()
if not line in global_dict:
return
value = global_dict[line]
import os
os.system("echo '%s' | pbcopy" % str(value))
del clip
@inawrath
inawrath / settings_sublime.json
Created November 28, 2018 13:16
Permute Unique lines sublime
{ "keys": ["f8"], "command": "permute_lines", "args": {"operation": "unique"} }
@inawrath
inawrath / install_php55_ubuntu.sh
Created March 28, 2020 03:28 — forked from jniltinho/ install_php55_ubuntu.sh
Install PHP 5.5.38 on Ubuntu 16.04 64Bits
#!/bin/bash
### Install PHP 5.5.38 on Ubuntu 16.04 64Bits
### https://www.howtoforge.com/tutorial/how-to-install-php-5-6-on-ubuntu-16-04/
apt-get -y install build-essential libxml2-dev libxslt1-dev
apt-get -y install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libxml2-dev
apt-get -y install libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev
apt-get -y install libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev
apt-get -y install libfreetype6-dev libkrb5-dev libpq-dev libicu-dev