Skip to content

Instantly share code, notes, and snippets.

View dan-osull's full-sized avatar

Dan O'Sullivan dan-osull

View GitHub Profile
@benjclark
benjclark / gist:e989373008ce935ef5509f5f61a3637e
Created October 28, 2020 14:09
colorspace css refactor
<style>
#color_analysis_content .card {
height: 300px;
justify-content: space-between;
}
</style>
<div id="color_analysis_content" ic-get-from="/data/r_analysis/recolor/ICDB000060/rondoni_HT_dors_comp.tif/" ic-trigger-on="load" class="mt-2" ic-src="/data/r_analysis/recolor/ICDB000060/rondoni_HT_dors_comp.tif/" ic-deps="ignore" ic-id="2">
<div class="row">
<!-- Original image -->
<div class="col-12 col-sm-6 col-lg-2">
@benjclark
benjclark / random-insect-name-fetch.js
Last active May 12, 2020 20:01
Reproducing intercooler.js functionality in plain ES6 for the random insect name endpoint
/**
*
* Simple reproduction of what you are doing with intercooler.js for your random insect button
* Written in ES6 javascript, i.e. will not work in some older browsers but can be written with more verbose syntax to do so if needed
* It uses the modern method of retrieving data via xhr called 'fetch' which is asynchronous and returns a promise which is what the .then() is about. You don't need to understand how promises work for now but just know that they allow asynchronous code execution. I can explain more if needed.
* You can include this js in a <script> on the page or put it in a js file and load that file on your page
* This code could be updated with a little more syntax to turn it in to a module as in the end you will likely have different modules that you want to all load in to one single js file for your page
*/
// store the random insect button in a variable (you will need to add the attribute 'data-rand-insect-btn' to the <a> in your template)
@Maescool
Maescool / docker-compose.yml
Last active April 9, 2023 18:31
Traefik V2 docker-compose example with dashboard and SSL
version: '3.3'
services:
traefik:
# The official v2.0 Traefik docker image
image: traefik:v2.0
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
@loilo
loilo / idb-backup-and-restore.md
Last active April 29, 2024 06:40
Back up and restore an IndexedDB database

Back up and restore an IndexedDB database

This gist is an ES module which provides functions to import and export data from an IndexedDB database as JSON. It's based on Justin Emery's indexeddb-export-import package, but applies some adjustments that reflect better on the current browser landscape (i.e. better developer ergonomics but no support for Internet Explorer).

Usage

For each of the provided functionalities, you need a connected IDBDatabase instance.

Export Data

import { idb } from 'some-database'
@stewartadam
stewartadam / main.py
Last active March 5, 2024 16:02 — forked from gear11/main.py
Simple Python proxy server based on Flask and Requests with support for GET and POST requests.
"""
A simple proxy server, based on original by gear11:
https://gist.github.com/gear11/8006132
Modified from original to support both GET and POST, status code passthrough, header and form data passthrough.
Usage: http://hostname:port/p/(URL to be proxied, minus protocol)
For example: http://localhost:5000/p/www.google.com
"""
import re
@malexer
malexer / sqlalchemy_upsert.py
Last active January 26, 2024 14:09
Modelling UPSERT in SQLAlchemy (well actually it is not upsert but speed improvement is significant in comparison with simple session.merge)
# Note: it is a copy of great answer by "mgoldwasser" from Stackoverflow
# Check the original answer here: http://stackoverflow.com/a/26018934/1032439
# Imagine that post1, post5, and post1000 are posts objects with ids 1, 5 and 1000 respectively
# The goal is to "upsert" these posts.
# we initialize a dict which maps id to the post object
my_new_posts = {1: post1, 5: post5, 1000: post1000}
for each in posts.query.filter(posts.id.in_(my_new_posts.keys())).all():
@doobeh
doobeh / home.html
Created January 19, 2016 14:04
More complete example of FieldList with FormField
<form method="post" action="">
{{ form.name}}
{{ form.hidden_tag() }}
<br/>
{% for entry in form.hours %}
{{ loop.index0|dow }}
{{ entry() }}
{% endfor %}
<input type="submit"/>
</form>
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@developius
developius / README.md
Last active April 25, 2024 22:15
Setup SSH keys for use with GitHub/GitLab/BitBucket etc

Create a new repository, or reuse an existing one.

Generate a new SSH key:

ssh-keygen -t rsa -C "your_email@example.com"

Copy the contents of the file ~/.ssh/id_rsa.pub to your SSH keys in your GitHub account settings (https://github.com/settings/keys).

Test SSH key:

@fanzeyi
fanzeyi / app.py
Created November 15, 2013 19:17
Simple stream file proxy with Flask and Requests
# -*- coding: utf-8 -*-
from flask import Flask
from flask import Response
from flask import stream_with_context
import requests
app = Flask(__name__)