Skip to content

Instantly share code, notes, and snippets.

View elnygren's full-sized avatar

el3ng elnygren

  • Helsinki, Finland
View GitHub Profile
@elnygren
elnygren / gitlab_mv.py
Created August 11, 2016 06:30
Move git projects the hard way
from subprocess import call
OLD_URLS = [
'git@git.old-git.com:someone/some-project.git'
]
NEW_URLS = [
'git@git.new-git.com:someone/some-project.git'
]
@elnygren
elnygren / ssl_status_pyopenssl.py
Created August 19, 2016 12:38
SSL certificate status with pyOpenSSL
from OpenSSL import SSL
import sys, os, select, socket
def parse_name(name):
return {
'common_name': name.commonName
}
def verify_cb(conn, cert, errnum, depth, ok):
@elnygren
elnygren / emblica_shared_source_license.py
Created September 5, 2016 12:24
EMBLICA SHARED SOURCE LICENSE
EMBLICA SHARED SOURCE LICENSE
version 1.0, 5 September 2016
Copyright (c) 2016 Emblica. <http://emblica.fi>
Everyone is permitted to copy and distribute verbatim
copies of this license document, but changing it is
not allowed.
TERMS AND CONDITIONS
@elnygren
elnygren / logging.py
Created September 26, 2016 10:09
Sane Python logging
# Setting up python logging is a pain in the but
# ...until you found this gist.
import logging
from logging.config import dictConfig as LOGGING_CONFIG
LOG_LEVEL = logging.INFO
LOGGING_CONFIG({
'version': 1,
'formatters': {
@elnygren
elnygren / poor_man_airdrop.sh
Last active January 2, 2017 15:14
Poor man's airdrop (send a file to a friend)
#
# RECEIVE DATA:
#
nc -lp <PORT> > data_from_someone
# gzipped, monitor with pv
nc -lp 6666 | gzip -d | pv > data_from_someone
@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 / 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 !!