Skip to content

Instantly share code, notes, and snippets.

View lordlycastle's full-sized avatar
🤙
Let it Fly!

lordlycastle

🤙
Let it Fly!
View GitHub Profile
@erickoledadevrel
erickoledadevrel / checkAndHide.gs
Last active April 9, 2022 16:53
Google Apps Script code to hide a row when a checkbox is checked.
/*
* Copyright 2019 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/
var CHECKBOX_COLUMN = 'B';
function onEdit() {
var range = SpreadsheetApp.getActiveRange();
if (range.getA1Notation().split(/\d/)[0] == CHECKBOX_COLUMN &&
@sneha-belkhale
sneha-belkhale / Fbm.cginc
Last active August 22, 2024 20:51
Fractal Brownian Motion function to include in Unity Shader
float hash (float2 n)
{
return frac(sin(dot(n, float2(123.456789, 987.654321))) * 54321.9876 );
}
float noise(float2 p)
{
float2 i = floor(p);
float2 u = smoothstep(0.0, 1.0, frac(p));
float a = hash(i + float2(0,0));
@evanshortiss
evanshortiss / without-env-var.example.js
Last active October 14, 2021 16:30
Example code running without env-var. This is how you might implement env.get(MAX_BATCH_SIZE).required().asIntPositive()
/**
* All the assertion code below the line could be replaced with
* this single line by using env-var
*/
env.get(MAX_BATCH_SIZE).required().asIntPositive()
// -----------------------------------------------
const assert = require('assert');
@erickoledadevrel
erickoledadevrel / Code.gs
Last active April 12, 2021 20:48
Walkstation booking with Apps Script
/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
@whyboris
whyboris / matplotlib.py
Last active May 12, 2021 02:47
Keras Loss & Accuracy Plot Helper Function
import matplotlib.pyplot as plt
# Plot model history more easily
# when plotting, smooth out the points by some factor (0.5 = rough, 0.99 = smooth)
# method taken from `Deep Learning with Python` by François Chollet
def smooth_curve(points, factor=0.75):
smoothed_points = []
for point in points:
@LongChau
LongChau / A set of Unity3D extension methods
Created June 14, 2018 08:18 — forked from omgwtfgames/A set of Unity3D extension methods
Some useful extension method for Unity3D
A collection of useful C# extension methods for the Unity engine.
@briandominick
briandominick / asciidoc-static.adoc
Last active November 4, 2024 02:56
Static Site Generators with AsciiDoc Support

There are 28 static site generators that support AsciiDoc sourcing.

@Shourai
Shourai / Allowing SSH on a server with an active OpenVPN client.md
Last active August 20, 2024 15:39
Allowing SSH on a server with an active OpenVPN client

If you want to SSH to a VPS which is running openVPN do the following:
source: https://serverfault.com/questions/659955/allowing-ssh-on-a-server-with-an-active-openvpn-client

Enable

The problem is that the default gateway gets changed by OpenVPN, and that breaks your current SSH connection unless you set up appropriate routes before you start OpenVPN.

What follows works for me. It uses iptables and ip (iproute2). Below, it is assumed that the default gateway interface before OpenVPN is started is "eth0". The idea is to ensure that when a connection to eth0 is made, even if eth0 is not the default gateway interface anymore, response packets for the connection go back on eth0 again.

You could use the same number for the connection mark, firewall mark and routing table. I used distinct numbers to make the diffences between them more apparent.

@0x4D31
0x4D31 / beautiful_idiomatic_python.md
Last active September 5, 2024 12:30 — forked from JeffPaine/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: