Skip to content

Instantly share code, notes, and snippets.

local stateFirstLoad = true
local stateToolHeld = false
function RunResinRadar()
if stateFirstLoad then
stateFirstLoad = false
print("Initializing Resin Detector.")
ListenToGameEvent("weapon_switch", OnSwitch, itemTable)
@rchanou
rchanou / nameof-hacks.ts
Last active September 2, 2018 16:25
TypeScript "nameof" Hacks
// see issue: https://github.com/Microsoft/TypeScript/issues/1579
function nameOf<T>(obj: T) {
let name: string;
const makeCopy = (obj: any): any => {
const copy = {};
for (const key in obj) {
defineProperty(copy, key, {
get() {
name = key;
@rchanou
rchanou / LICENSE
Last active January 8, 2018 22:08
This license applies to all public gists: https://gist.github.com/rchanou
MIT License
Copyright (c) 2017 Ronald Chanou
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@rchanou
rchanou / get-hue-from-hash.js
Created March 30, 2017 07:11
Get Hue From Hash
export const getHueFromHash = hash => {
let hue = 0;
for (var i in hash) {
hue += Math.pow(hash.charCodeAt(i), 2);
}
return hue % 360;
};
@rchanou
rchanou / SemiControlledInput.js
Last active January 4, 2021 02:35
Semi-Controlled Input
export default class Input extends React.Component {
static defaultProps = {
onChange() {},
onFocus() {},
onBlur() {}
};
constructor(props) {
super();
this.state = {
@rchanou
rchanou / es2015-app-boilerplate.html
Last active January 8, 2018 22:10
Boilerplate HTML for app that can use ES2015+/NPM modules (useful for quick one-off apps and experimenting)
<head>
<script type="text/javascript"> var process = { env: { NODE_ENV: 'production' } }; </script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.13.0/polyfill.min.js" integrity="sha256-1xJxekKA6MkBUKinJgsgPe3sTGMsKK6MzTzr+hKxMfI=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.15.0/babel.min.js" integrity="sha256-mxaL+9zRy1U6ZxZsba9703g+UH0v8Tjo/GUhpGpAjSc=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js" integrity="sha256-KJq4gv89+lNKzudhvvq6QJDLlFycaheMHYEf3UnTa2c=" crossorigin="anonymous"></script>
<script type='text/babel' data-presets='es2015,stage-0'>
'use strict';
(async () => {
// example of requesting an npm module import