Skip to content

Instantly share code, notes, and snippets.

View Shilo's full-sized avatar

Shilo Shilo

View GitHub Profile
@Shilo
Shilo / file-size.pipe.ts
Created November 2, 2016 01:15 — forked from JonCatmull/file-size.pipe.ts
Angular2 + TypeScript file size Pipe/Filter. Convert bytes into largest possible unit. e.g. 1024 => 1 KB
import { Pipe, PipeTransform } from '@angular/core';
/*
* Convert bytes into largest possible unit.
* Takes an precision argument that defaults to 2.
* Usage:
* bytes | fileSize:precision
* Example:
* {{ 1024 | fileSize}}
* formats to: 1 KB
@Shilo
Shilo / spoilerAlert.plugin.js
Last active December 18, 2017 13:28 — forked from NanoAi/spoilerAlert.plugin.js
spoilerAlert.plugin.js
//META{"name":"spoilerAlert"}*//
/*@cc_on
@if (@_jscript)
// _jscrupt stolen (not really) from noodlebox#0155!
// Offer to self-install for clueless users that try to run this directly.
var shell = WScript.CreateObject("WScript.Shell");
var fs = new ActiveXObject("Scripting.FileSystemObject");
var pathPlugins = shell.ExpandEnvironmentStrings("%APPDATA%\\BetterDiscord\\plugins");
var pathSelf = WScript.ScriptFullName;
@Shilo
Shilo / gist:b3f581ef937dfc22466ca579176492d2
Created January 4, 2018 05:42 — forked from ozh/gist:4131243
Create dot files/directories (ie .file) on Windows

#How to create a .file or .folder on Windows

There are several ways

1. Rename

  • Create file.txt
  • Rename to .file., the last dot will be dropped, you'll have .file

Works the same with a file or a directory.

@Shilo
Shilo / angle-between-points.js
Created September 4, 2018 06:57 — forked from conorbuck/angle-between-points.js
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};
@Shilo
Shilo / preserve-pixelation.scss
Created December 23, 2019 09:13 — forked from tombennet/preserve-pixelation.scss
Preserve pixelation when scaling pixel art with CSS - https://builtvisible.com/image-scaling-in-css/
@mixin pixelated {
-ms-interpolation-mode: nearest-neighbor; // IE 7+ (non-standard property)
image-rendering: -webkit-optimize-contrast; // Safari 6, UC Browser 9.9
image-rendering: -webkit-crisp-edges; // Safari 7+
image-rendering: -moz-crisp-edges; // Firefox 3.6+
image-rendering: -o-crisp-edges; // Opera 12
image-rendering: pixelated; // Chrome 41+ and Opera 26+
}
@Shilo
Shilo / cross-browser-opacity.css
Created December 23, 2019 09:21 — forked from arnoldc/cross-browser-opacity.css
css: cross browser opacity
selector {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
-moz-opacity: 0.3;
-khtml-opacity: 0.3;
opacity: 0.3;
}
public boolean isColorDark(int color){
double darkness = 1-(0.299*Color.red(color) + 0.587*Color.green(color) + 0.114*Color.blue(color))/255;
if(darkness<0.5){
return false; // It's a light color
}else{
return true; // It's a dark color
}
}
@Shilo
Shilo / mac-keycodes
Created May 27, 2022 12:09 — forked from eegrok/mac-keycodes
Mac virtual keycodes
from: http://www.meandmark.com/keycodes.html
Virtual Keycodes for the Mac QWERTY Layout
Keycodes are in hexadecimal. A blank entry means either there is no key assigned to that keycode or I was unable to find the assigned key.
Keycode Key
0x00 A
0x01 S
0x02 D
0x03 F
@Shilo
Shilo / Clamp.swift
Created June 8, 2022 15:08 — forked from leemorgan/Clamp.swift
clamp() in Swift
///Returns the input value clamped to the lower and upper limits.
func clamp<T: Comparable>(value: T, lower: T, upper: T) -> T {
return min(max(value, lower), upper)
}
//-----------------------------------------------
// Example usage
let proposedIndex = 6
@Shilo
Shilo / Gists.md
Created June 25, 2022 00:57 — forked from BoQsc/Gists.md
How to search my own Gists