Skip to content

Instantly share code, notes, and snippets.

View lucax88x's full-sized avatar

Luca Trazzi lucax88x

View GitHub Profile
@saamalik
saamalik / alias.sh
Last active April 18, 2024 08:57
Speedy K8s switching with kctx & klctx
# add to your shell startup script (e.g: $HOME/.bashrc).
# install [fzf](https://github.com/junegunn/fzf)
# e.g: brew install fzf
kctx() {
(
cd ~/.kube/ || exit 1
# shellcheck disable=SC2012
KUBE=$(ls kube-* | fzf)
[[ -n "$KUBE" ]] && ln -sf "$KUBE" config
@jaydenseric
jaydenseric / RouteIndicator.js
Last active November 29, 2023 11:34
A route change indicator for Next.js using React hooks.
import classNameProp from 'class-name-prop';
import { useRouter } from 'next/router';
import React from 'react';
import styles from './RouteIndicator.module.css';
const DONE_DURATION = 250;
export default function RouteIndicator() {
const router = useRouter();
@superjose
superjose / .gitlab-ci.yml
Last active February 19, 2024 10:22
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.
kubectl get po --all-namespaces | grep Evicted | awk '{print $2, "--namespace", $1}' | xargs kubectl delete pod
@ca0v
ca0v / debounce.ts
Last active May 17, 2024 05:58
Typescript Debounce
// ts 3.6x
function debounce<T extends Function>(cb: T, wait = 20) {
let h = 0;
let callable = (...args: any) => {
clearTimeout(h);
h = setTimeout(() => cb(...args), wait);
};
return <T>(<any>callable);
}
@jmervine
jmervine / cert_convert.sh
Created November 17, 2014 21:57
openssl: convert cert from p7b to crt (or cer)
openssl pkcs7 -print_certs -in old.p7b -out new.crt
# openssl pkcs7 -print_certs -in old.p7b -out new.cer
@johnathan-sewell
johnathan-sewell / Jasmine it in forEach.js
Created May 8, 2014 08:42
Dry Jasmine "it" blocks in forEach
describe('validation', function() {
['startDate', 'endDate'].forEach(function(key) {
it('expects ' + key + ' to be in ISO format', function() {
model.set(key, '2014-04-29T15:04:53.078Z');
expect(model.isValid()).toEqual(true);
model.set(key, '2014/04/29');
expect(model.isValid()).toEqual(false);
});
});
});
@ramondelafuente
ramondelafuente / test_sudo_and_variables.yml
Last active March 17, 2023 23:38
Testing ansible "ansible_ssh_user" and "ansible_user_id" variables with sudo
- name: Testing variables with SUDO=NO
hosts: "*"
sudo: no
tasks:
- name: "PLAYBOOK SUDO=NO, TASK SUDO=NO"
command: whoami
register: whoami_output
sudo: no
- debug: var=whoami_output.stdout
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active May 24, 2024 01:23
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@hiddentao
hiddentao / gist:7300694
Last active January 22, 2019 05:04
An improvement on the angular.module() API, making it easier to split up modules into multiple files without having to worry about only registering them once.
/**
* Workaround to make defining and retrieving angular modules easier and more intuitive.
*/
(function(angular) {
var origMethod = angular.module;
var alreadyRegistered = {};
/**