Skip to content

Instantly share code, notes, and snippets.

View o-y's full-sized avatar
🦄

zv o-y

🦄
View GitHub Profile
@keineahnung2345
keineahnung2345 / cantor.py
Created October 1, 2021 14:30
Cantor pairing function for three integers(negative allowed)
# https://www.vertexfragment.com/ramblings/cantor-szudzik-pairing-functions/
# https://stackoverflow.com/questions/38965931/hash-function-for-3-integers
# https://math.stackexchange.com/questions/222709/inverting-the-cantor-pairing-function
def normalize(x):
# this function make cantor pairing function work for negative numbers
return 2*x if (x>=0) else (-2*x-1)
def normalize_inv(x):
return x//2 if (x % 2 == 0) else -(x+1)//2
@kherge
kherge / Example.java
Last active November 22, 2023 11:14
Null Coalescing in Java
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.Optional;
public class Example {
public static void main(String []args) {
// Create a series of nullable objects.
Test a = new Test();
@hilkeheremans
hilkeheremans / .drone.yml
Created April 28, 2016 11:13
Drone CI with nodejs, npm and private modules
# drone.yml for node js CI with npm login
# Don't forget to configure DRONE_SERVER and DRONE_SERVER
# Now create a secrets.yml (OUTSIDE of your repo!!) (see other file)
# then run drone secure --repo <drone_repo_name> --in <path>/secrets.yml
build:
unit_tests:
image: risingstack/alpine:3.3-v4.2.6-1.1.3
commands:
- npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
- npm install
@squarism
squarism / iterm2.md
Last active June 27, 2024 00:50
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@gre
gre / easing.js
Last active June 27, 2024 15:37
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {