Skip to content

Instantly share code, notes, and snippets.

@lttr
lttr / vue3-docs-to-eink.sh
Created January 18, 2024 13:18
I wanted to read the VueJS docs on my eink tablet. HTML seems to work even better then EPUB in Boox NeoReader app.
#!/usr/bin/env bash
set -e
TEMPORARY="vue-docs.md"
GUIDE_PATH="./src/guide/"
OUTPUT_EPUB="vue-docs.epub"
OUTPUT_HTML="vue-docs.html"
git clone --depth=1 https://github.com/vuejs/docs
@JakeCoxon
JakeCoxon / distribute.py
Created December 24, 2020 21:32
Blender addon to distribute objects along an axis
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
@Oxeren
Oxeren / MySingletonSO.cs
Last active February 15, 2024 04:57
Auto singleton Unity ScriptableObject. Derive your class from this class (and use your class as the generic type), create an instance in the Resources folder (name of the instance must be the same as the name of your class). Then you will be able to access the singleton via static Instance property without having to add boilerplate code.
// Example Scriptable Object. Instance must be placed in Resources folder and have the same name as the class, type of generic parameter must be your class.
using UnityEngine;
[CreateAssetMenu(fileName = "MySingletonSO")]
public class MySingletonSO : SingletonScriptableObject<MySingletonSO>
{
// Here goes your data. This class can be called by the static Instance property, which will automatically locate the instance in the Resources folder.
}
@fguillen
fguillen / my_wrapper_creator.rb
Last active May 19, 2019 05:55
Providing an `around_action` like functionality in arbitrary Ruby classes
module MyWrapperCreator
def my_method_wrapper(method_name)
original_method = instance_method(method_name)
define_method(method_name) do |*args, &block|
puts "wrapper :: INI"
result = original_method.bind(self).call(*args, &block)
puts "wrapper :: END"
result
@fernandoaleman
fernandoaleman / mysql2-mojave.md
Last active February 7, 2024 19:19
Install mysql2 on MacOS Mojave

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

@tntmeijs
tntmeijs / unitythreedimensionalperlinnoise.cs
Last active February 19, 2024 01:52
A 3D implementation using the 2D Perlin noise function of Unity3D.
public static float Noise3D(float x, float y, float z, float frequency, float amplitude, float persistence, int octave, int seed)
{
float noise = 0.0f;
for (int i = 0; i < octave; ++i)
{
// Get all permutations of noise for each individual axis
float noiseXY = Mathf.PerlinNoise(x * frequency + seed, y * frequency + seed) * amplitude;
float noiseXZ = Mathf.PerlinNoise(x * frequency + seed, z * frequency + seed) * amplitude;
float noiseYZ = Mathf.PerlinNoise(y * frequency + seed, z * frequency + seed) * amplitude;
@JamesMcMahon
JamesMcMahon / lerp.rb
Created May 4, 2016 19:43
Lerp code in Ruby, just for reference
def lerp(start, stop, step)
(stop * step) + (start * (1.0 - step))
end
@brianr
brianr / gist:319cd1a3b6d3d4bf2980
Last active October 1, 2015 15:21
rollbar instrumentation for angular js exception handler
angular.module('exceptionOverride', []).factory('$exceptionHandler', function() {
return function(exception, cause) {
Rollbar.error(exception, {cause: cause});
throw exception;
};
});
@whity-82
whity-82 / gist:5403900
Last active December 2, 2023 02:18
Sample of drawing text with Gosu & Ruby.
require 'gosu'
class GameWindow < Gosu::Window
def initialize
super 640, 480, false
self.caption = "Gosu Tutorial Game"
@font = Gosu::Font.new(self, Gosu::default_font_name, 20)
end
@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created July 25, 2012 07:58
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time