Skip to content

Instantly share code, notes, and snippets.

View marc-gist's full-sized avatar

Marc marc-gist

  • Toronto, Canada
View GitHub Profile
@marc-gist
marc-gist / bedside_button.yaml
Created November 25, 2023 17:30 — forked from albertnis/bedside_button.yaml
Making a custom multi-click push button using ESPHome
esphome:
name: bedside_button
platform: ESP8266
board: esp12e
wifi:
ssid: "ssid"
password: "example"
logger:
- platform: rest
name: voron24_sensor
resource: "http://192.168.8.25:7125/printer/objects/query?heater_bed&extruder&print_stats&toolhead&display_status&virtual_sdcard&temperature_sensor%20raspberry_pi&temperature_sensor%20MCU&temperature_sensor%20chamber_temp"
json_attributes_path: "$.result.status"
json_attributes:
- heater_bed
- extruder
- print_stats
- toolhead
- display_status
@marc-gist
marc-gist / merge.py
Created March 11, 2017 00:15 — forked from edelvalle/merge.py
Merging model instances in Django 1.9
from django.db import transaction
from django.apps import apps
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db.models.fields.related import ManyToManyField
@transaction.atomic()
def merge(primary_object, *alias_objects):
"""Merge several model instances into one, the `primary_object`.
Use this function to merge model objects and migrate all of the related
@marc-gist
marc-gist / social.py
Created February 23, 2017 00:35 — forked from revolunet/social.py
Sample custom pipeline for django-social-auth and Facebook backend. Goal is to ask more info to the user before creating the account and the related Customer model.
# settings.py
FACEBOOK_EXTENDED_PERMISSIONS = ['email', 'user_birthday', 'user_location']
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.misc.save_status_to_session',
'web.facebook.check_registered',
'social_auth.backends.pipeline.user.create_user',
'web.facebook.check_profile',
'social_auth.backends.pipeline.social.associate_user',
@marc-gist
marc-gist / gist:83057cb686782642724e
Created February 28, 2016 23:22 — forked from evildmp/gist:3094281
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@marc-gist
marc-gist / gist:c0359763706695a954af
Created January 26, 2016 12:58 — forked from ekampf/gist:7721226
Code to convert temperature from Arduino's temperature sensor into heatmap RGB
const int rLED = 11;
const int gLED = 9;
const int bLED = 10;
const int sensor = A0;
const float minTemp = 10.0;
const float maxTemp = 50.0;
int redV = 0;
int greenV = 0;
@marc-gist
marc-gist / sublime-shortcuts
Created April 12, 2013 03:36
Sublime Shortcuts
h1. Sublime Text 2 - Useful Shortcuts (PC)
Loosely ordered with the commands I use most towards the top. Sublime also offer "full documentation":http://www.sublimetext.com/docs/2/.
h2. Editing
| *Ctrl+C* | copy current line (if no selection) |
| *Ctrl+X* | cut current line (if no selection) |
| *Ctrl+⇧+K*| delete line |
| *Ctrl+↩* | insert line after |