Skip to content

Instantly share code, notes, and snippets.

package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
public class MyGdxGame extends ApplicationAdapter {
@bitbutter
bitbutter / TransparentBackgroundScreenshotRecorder.cs
Last active May 19, 2024 21:59
Rendering screenshots from Unity3d with transparent backgrounds
using UnityEngine;
using System.Collections;
using System.IO;
/*
Usage:
1. Attach this script to your chosen camera's game object.
2. Set that camera's Clear Flags field to Solid Color.
3. Use the inspector to set frameRate and framesToCapture
@Oleksandr-Moik
Oleksandr-Moik / UnitTest.php
Created May 19, 2024 21:53
Extract the YouTube Video ID from a URL in PHP (Larave, test suite on Pest)
<?php
it('extracts video ID from YouTube URLs', function ($url, $expectedId) {
expect(get_youtube_video_id($url))->toBe($expectedId);
})->with([
['https://youtu.be/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['http://youtube.com/v/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['https://www.youtube.com/embed/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['https://www.youtube.com/shorts/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
@pkuecuekyan
pkuecuekyan / WKWebViewSizeToFit.swift
Last active May 19, 2024 21:53
Adjust height of WKWebView frame based on scrollHeight of the webView's content
// Since the WKWebView has no sizeToFit() method, increase the frame height of the webView to
// match the height of the content's scrollHeight
//
// The WKWebView's `navigationDelegate` property needs to be set for the delegate method to be called
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if webView.isLoading == false {
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
if let height = result as? CGFloat {
@edjdavid
edjdavid / file.md
Created October 13, 2022 12:45
Stream Windows webcam/desktop via RTSP

Can be used for streaming data (webcam or screen capture) from the Windows to WSL

Install

  1. Simple RTSP Server
  2. ffmpeg

Get the internal IP of WSL

Run from a WSL terminal

ip route list default | awk '{print $3}'
@cryptocoinserver
cryptocoinserver / AnkiCardSimilarity.py
Last active May 19, 2024 21:48
This script checks for similar cards in a deck and adds tags to them. It uses TF-IDF and cosine similarity to calculate the similarity between cards. It connects to the Anki collection with ankipandas. Anki needs to be closed while running it. For the changes to show in Anki "Tools" > "Check database" before "Browse".
import os
import re
import sqlite3
import zipfile
import numpy as np
import pandas as pd
import spacy
from ankipandas import Collection
from sklearn.feature_extraction.text import TfidfVectorizer
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active May 19, 2024 21:52
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

Note

This no longer works if you're alone in vc! Somebody else has to join you!

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory
@mrk-han
mrk-han / change-accessibility-settings-with-adb.md
Last active May 19, 2024 21:38
Enable and Disable Android Accessibility Settings from the Command Line using ADB (Font scale, talkback, color blind)

Using ADB to control Accessbility settings for easier testing with Android Emulators + Real Devices

It's a lot easier to test accessibility on the fly using ADB. This gist attempts to make the days of navigating through the Android device settings UI to change Accessibility settings obsolete.

These ADB commands will hopefully encourage Android developers to test and use their apps with common Accessiblility settings enabled.

Credit to James Nitsch for inspiring this, and for figuring out the put commands to enable these settings.

Font Scale (Font Size -- Testing Dynamic Text)

@josephrocca
josephrocca / BigMap.js
Last active May 19, 2024 21:35
BigMap - wrapper to get past the ~16 million key limit on JavaScript Maps
// only covers a small subset of the Map api!
// haven't debugged yet!
class BigMap {
constructor(iterable) {
if(iterable) throw new Error("haven't implemented construction with iterable yet");
this._maps = [new Map()];
this._perMapSizeLimit = 14000000;
this.size = 0;
}
@EarthlingDavey
EarthlingDavey / class-comments.php
Created January 30, 2020 15:27 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
/**
* Class Comments.
* Code refactored from:
* https://gist.github.com/mattclements/eab5ef656b2f946c4bfb
*
* @package Foo
*/
namespace Boop;