Skip to content

Instantly share code, notes, and snippets.

View derme302's full-sized avatar

Chris derme302

View GitHub Profile
@derme302
derme302 / detect_notch.gml
Created January 16, 2024 20:39
Handle Notched Phones in GameMaker by ChatGPT4
// This function returns true if the device has a notch, false otherwise
function device_has_notch()
{
// Get the device model name
var device_model = device_get_model();
// Check if the device model is one of the known notched iPhones
var notched_iphones = ["iPhone X", "iPhone XS", "iPhone XS Max", "iPhone XR", "iPhone 11", "iPhone 11 Pro", "iPhone 11 Pro Max", "iPhone 12", "iPhone 12 Mini", "iPhone 12 Pro", "iPhone 12 Pro Max"];
return array_find_index(notched_iphones, device_model) != -1;
}
@derme302
derme302 / gitlab_group_mirror.py
Created November 13, 2023 07:04
[Bing AI/ChatGPT] Mirror a GitLab group to a GitLab group on another instance
import gitlab
from git import Repo
import subprocess
# Source GitLab instance
source_url = 'https://source.gitlab.com'
source_token = 'your-source-token'
source_group_id = 1234
# Destination GitLab instance
import glob
import time
import paho.mqtt.publish as mqtt
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'
def read_temp_raw():
@derme302
derme302 / git-sync.sh
Created September 1, 2022 22:57
Sync a folder with Git and add a message with the timestamp
#!/bin/bash
git pull
git add --all
git commit -asm "`date +'%a %d %b %Y %H:%M:%S'`"
git push
@derme302
derme302 / bing.py
Created June 7, 2022 23:34
Download wallpaper from Bing
import requests
from requests.exceptions import RequestException
from lxml import etree
from io import BytesIO
BING_URL = "https://www.bing.com/"
def bing_get_wallpaper_url(debug = True):
@derme302
derme302 / scaling.gml
Created May 28, 2022 22:20
Automatically set all the views in all your Game Maker Studio 2 rooms so that you only need to call it once at the start of the game.
// Reference: https://gamemaker.io/en/blog/the-basics-of-scaling-the-game-view
function display_scale_all_rooms() {
var base_w = 1024;
var base_h = 768;
var max_w = display_get_width();
var max_h = display_get_height();
var aspect = display_get_width() / display_get_height();
if (max_w < max_h) {
// portait
var VIEW_WIDTH = min(base_w, max_w);
@derme302
derme302 / README.md
Last active October 29, 2023 08:19
Install rtl_433 for a SDR-RTL Dongle on a Raspberry Pi
@derme302
derme302 / .gitignore
Created February 24, 2015 02:02
Windows/Mac gitignore
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
@derme302
derme302 / ds_grid_import_array
Created January 29, 2015 10:04
Import a array into a ds_grid
///ds_grid_import_array(ds_grid, array)
var grid = argument[0];
var arr = argument[1];
// Calculate array Size
var height = array_height_2d(arr);
var width = 0;
for (var i = 0; i < height; i++) {
if (array_length_2d(arr, i) > width)
width = array_length_2d(arr, i);
@derme302
derme302 / CSVReader.cs
Created January 28, 2015 04:51
Allows a CSV to be imported into Unity
// Built on http://bravenewmethod.com/2014/09/13/lightweight-csv-reader-for-unity/
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public class CSVReader
{
static string SPLIT_RE = @",(?=(?:[^""]*""[^""]*"")*(?![^""]*""))";