Skip to content

Instantly share code, notes, and snippets.

View elnygren's full-sized avatar

el3ng elnygren

  • Helsinki, Finland
View GitHub Profile
@elnygren
elnygren / good_enough.css
Last active April 8, 2019 20:07
Good enough CSS (minimalist)
body {
/* https://gist.github.com/davidgilbertson/6d0313bc3c6ecb5757e822620e9ebaa4#file-good-enough-css */
color: #333;
font-family: "Helvetica", "Calibri Light", Roboto, sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
letter-spacing: 0.02em;
background-color: rgba(250, 245, 245, 0.3);
@elnygren
elnygren / fb_activity.js
Created January 9, 2017 11:08
See all fb activity
// goto `https://www.facebook.com/${username}/allactivity`
// aka the Activity Log
const getDocHeight = () => Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
)
@elnygren
elnygren / open_ssl.sh
Last active January 24, 2017 11:39
Open SSL tips
# verify SSL of a running system on Heroku, AWS etc. before pointing DNS there
openssl s_client -connect domain.com.somedns.com:443 -servername www.example.com
# verify a chain before uploading
certs openssl verify chain.cer
> chain.cer: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root CA
> error 18 at 0 depth lookup:self signed certificate # this is expected
> OK # we're ok!
@elnygren
elnygren / s3_cors
Created March 20, 2017 17:31
S3 Cors settings
echo "
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>http://www.example1.com</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
@elnygren
elnygren / infra_destroy.py
Created March 20, 2017 22:09
Destroy all VMs on UpCloud in parallel
"""
I use this for DevOps.
...ya know, when you test stuff, and need to bring everything down after.
"""
import os
import upcloud_api
import multiprocessing
manager = upcloud_api.CloudManager(os.environ.get('UPCLOUD_API_USER'), os.environ.get('UPCLOUD_API_PASSWD'))
@elnygren
elnygren / nginx.conf
Last active June 30, 2018 08:52
Nginx SSL, security and SEO configuration reference
# Configure to suit your needs,
# this won't work copypasted and requires a pretty new nginx version.
# don't leak software versions
server_tokens off;
proxy_hide_header X-Powered-By;
# Security Headers
# https://securityheaders.io
@elnygren
elnygren / ansible_module.py
Created April 15, 2017 13:10
Ansible module boilerplate
DOCUMENTATION = '''
---
module: boilerplate
short_description: This is an example boilerplate module.
description:
- Boilerplate ansible module
- Use as a base for building your own modules and learning about how ansible modules work.
author: "Elias Nygren (@elnygren)"
options:
state:
@elnygren
elnygren / react-intro-pre.md
Last active April 21, 2017 12:17
React intro by Fastdevco & Emblica pre-material

React-intro is an intro level course to React programming. Before you arrive to the event we'd like you to take care of some basic things:

  • install Node.js (preferably the most recent LTS version)
  • install npm
  • install webpack (we are using webpack 2)
  • any easy static web server (python2 or python3 has a good one for this course)

!! this is NOT a comprehensive guide, please refer to search engines and online tutorials if you encounter problems !!

@elnygren
elnygren / minimum_viable_module.py
Last active April 26, 2017 19:02
Minimum Viable Ansible Module
from ansible.module_utils.basic import *
module = AnsibleModule(
argument_spec=dict(
state=dict(choices=['present', 'absent'], default='present'),
)
)
# do something fancy here
module.exit_json(changed=True, msg='it was a great success')
@elnygren
elnygren / authentication.py
Created June 2, 2017 13:32
Django Rest Framework custom authorization header
"""
[API] uses the DRF TokenAuthentication with one customisation:
Token is read from 'X-Mirror-Authorization' instead of the 'Authorization' header.
Unfortunately, this is not a simple setting in DRF so we need to override the
contents of get_authorization_header and TokenAuthentication.authenticate.
You may refer to:
https://github.com/encode/django-rest-framework/blob/master/rest_framework/authentication.py