Skip to content

Instantly share code, notes, and snippets.

@rokcarl
rokcarl / README.md
Last active Feb 26, 2021
Get GeoNode on 3.1 working with HTTPS, custom certs.
View README.md
  1. Put certs in /etc/ssl/: maps.company.com.pem and maps.company.com.key.
  2. Put nginx.conf in the root of the project.
  3. Apply the diff for docker-compose.yml.
  4. Add your .env file.
  5. Run project with docker-compose up -d.
@rokcarl
rokcarl / change-url-parameters.py
Last active Mar 3, 2021
Update URL parameters in Python 3.
View change-url-parameters.py
import urllib.parse
url = "http://stackoverflow.com/search?q=question"
params = {'lang':'en','tag':'python'}
url_parts = list(urllib.parse.urlparse(url))
query = dict(urllib.parse.parse_qsl(url_parts[4]))
query.update(params)
url_parts[4] = urllib.parse.urlencode(query)
View cron_inside_docker.sh
CRON_TEXT="
0 1 * * * cmd1 2>&1
0 */4 * * * cmd2 2>&1
"
printf "${CRON_TEXT}" | crontab -u zengrc -
cron
View git-checkout-PR.sh
echo "Type the PR number, e.g. 358."
read PR_NO
git fetch upstream pull/$PR/head:pr-$PR;
git checkout pr-$PR;
@rokcarl
rokcarl / 0_reuse_code.js
Created Dec 28, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View m.py
from __future__ import print_function
from functools import wraps
class Fish(object):
def __new__(cls, *args, **kwargs):
o = super(Fish, cls).__new__(cls, *args, **kwargs)
o.type = 'goldfish'
for name, val in vars(cls).items():
@rokcarl
rokcarl / gist:0844ffb917facb8b5822
Created Dec 31, 2014
github_read_file_from_private_repo.py
View gist:0844ffb917facb8b5822
import requests
auth = ('username', 'password')
filepath = '/views/index.py'
result = requests.get('https://api.github.com/repos/:company/:repo/contents{}'.format(filepath), auth=auth).json()