Skip to content

Instantly share code, notes, and snippets.

View Shilo's full-sized avatar

Shilo Shilo

View GitHub Profile
@Shilo
Shilo / aspect_fit_bounds_in_bounds.js
Last active August 21, 2018 04:44
Javascript snippet to aspect fit bounds in bounds.
aspectFitBoundsInBounds(src, dest, center=true) {
let WIDTH_KEY = "width";
let HEIGHT_KEY = "height";
let largerSide = src.height > src.width ? HEIGHT_KEY : WIDTH_KEY;
let smallerSide = largerSide == HEIGHT_KEY ? WIDTH_KEY : HEIGHT_KEY;
let aspectRatio = src[smallerSide]/src[largerSide];
src[largerSide] = dest[largerSide];
src[smallerSide] = dest[largerSide]*aspectRatio;
@Shilo
Shilo / youtube_big_theater_mode_injection.js
Last active July 13, 2018 11:43
YouTube.com "big theater mode" injection. Gives the video full height when in theater mode.
(function() {
var coverNavBar = true;
var css = `
ytd-watch:not([fullscreen])[theater] #player.ytd-watch {
height: ` + (coverNavBar?'':'calc(') + '100vh' + (coverNavBar?'':' - 56px)') + ` !important;
max-height: none !important;` + (coverNavBar?`
position: relative;
margin-top: -56px;
z-index: 9999;
@rene-d
rene-d / colors.py
Last active May 11, 2025 10:55
ANSI color codes in Python
# SGR color constants
# rene-d 2018
class Colors:
""" ANSI color codes """
BLACK = "\033[0;30m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
BROWN = "\033[0;33m"
BLUE = "\033[0;34m"
@gaearon
gaearon / modern_js.md
Last active April 14, 2025 19:22
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@danielpronych
danielpronych / nightbot_commands_selected.md
Created November 21, 2017 21:23
Selected Nightbot commands

Nightbot Commands (Selected)

Basic Counter (execute works for mod-only)

!commands add !countercmd -ul=moderator "The current counter is $(count) ."

Reset Counter Command (execute works for mod-only)

!commands add !resetcountercmd -ul=moderator -a=!commands edit !countercmd -c=0

@matthewzring
matthewzring / markdown-text-101.md
Last active May 12, 2025 17:30
A guide to Markdown on Discord.

Markdown Text 101

Want to inject some flavor into your everyday text chat? You're in luck! Discord uses Markdown, a simple plain text formatting system that'll help you make your sentences stand out. Here's how to do it! Just add a few characters before & after your desired text to change your text! I'll show you some examples...

What this guide covers:

@whaison
whaison / CSharpReNameFileNameExtention_And_Meta.cs
Last active May 30, 2019 23:24
Unity AssetDatabase.RenameAsset(path, newName); can not rename extension CSharpReNameFileNameExtention_And_Meta(string path,string newName) can chenge extension
static public void CSharpReNameFileNameExtention_And_Meta(string path,string newName)
{
string[] pathArr = path.Split("/"[0]);
string tempStr = "";
for (int i = 0; i < pathArr.Length-1; i++)
{
tempStr = tempStr + pathArr[i]+"/";
}
string renameDir = tempStr;
@Guendeli
Guendeli / ToastMessage.cs
Created September 28, 2016 10:08
a script to show Toast Messages on Android Unity3D Apps
using UnityEngine;
public class ToastMessage : MonoBehaviour
{
string toastString;
string input;
AndroidJavaObject currentActivity;
AndroidJavaClass UnityPlayer;
AndroidJavaObject context;
@Shilo
Shilo / svn_ignore.sh
Created September 6, 2016 03:08
Terminal command to add svn ignores via ".gitignore" file.
svn propset svn:ignore -RF .gitignore .
@Shilo
Shilo / NavigationController.m
Last active July 16, 2016 12:57
iOS - Dynamically load navigation bar title image with interpolation. How to use: Set navigation title as "{image_name_here}"
#define NAV_PORTRAIT_HEIGHT 44
- (void)viewDidLoad {
[super viewDidLoad];
[self loadNavigationBarTitleImage];
}
- (void)loadNavigationBarTitleImage {
NSString *title = self.navigationItem.title;
NSInteger prefixLength = NAV_TITLE_IMAGE_PREFIX.length;