Skip to content

Instantly share code, notes, and snippets.

View ckalegi's full-sized avatar

Cameron Kalegi ckalegi

View GitHub Profile
@ulisesantana
ulisesantana / .zshrc
Last active January 10, 2023 10:30
Raspberry Pi init script
# Prevent from using the custom alias on 3rd party scripts. Must be at the top of the file
[ -z "$PS1" ] && return
# alias
alias blog='cd ~/projects/blog'
alias blog-posts='cd ~/projects/blog/content/blog'
alias .zshrc='nvim ~/.zshrc'
alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias wifi='nmcli device show wlan0'
function cd {
@random-robbie
random-robbie / install_go_pi.sh
Created April 26, 2018 14:16
Install Go Lang 1.10.1 on Raspberry Pi 3
wget https://storage.googleapis.com/golang/go1.10.1.linux-armv6l.tar.gz
sudo tar -C /usr/local -xvf go1.10.1.linux-armv6l.tar.gz
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
source ~/.bashrc
@tendoasan
tendoasan / bash_basics.sh
Last active June 5, 2018 06:08
[Bash 简要命令] #Bash
#!/bin/bash
##############################################################################
# BASH BASICS
##############################################################################
env # displays all environment variables
echo $SHELL # displays the shell you're using
echo $BASH_VERSION # displays bash version
@bcnzer
bcnzer / postman-pre-request.js
Last active April 23, 2024 19:26
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive;
echo "[*] Starting Install... [*]"
echo "[*] Upgrade installed packages to latest [*]"
echo -e "\nRunning a package upgrade...\n"
apt-get -qq update && apt-get -qq dist-upgrade -y
apt full-upgrade -y
apt-get autoclean
echo "[*] Install stuff I use all the time [*]"
@blvkoblsk
blvkoblsk / ansi-colors.py
Created August 18, 2017 05:42
ANSI COLORS - PYTHON BASH SCRIPT + MODULE
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
""" An efficient and simple ANSI colours module (and also a powerfull script), with functions to print text using colours.
About the convention for the names of the colours :
* for the eight colours black, red, green, yellow, blue, magenta, cyan, white:
* the name in minuscule is for colour **with bold** (example 'yellow'),
* the name starting with 'B' is for colour **without bold** (example 'Byellow'),
* the name starting with a capital letter is for the background colour (example 'Yellow').* for the special effects (blink, italic, bold, underline, negative), **not always supported** :
const countryCodes = {
US: 'United States',
CA: 'Canada',
NG: 'Nigeria',
GB: 'United Kingdom',
};
const sales = [
{ code: 'US', count: 233 },
@akirattii
akirattii / background.js
Created December 2, 2016 03:45
Message passing of Chrome Extension example
/*****************************************************************
* onMessage from the extension or tab (a content script)
*****************************************************************/
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.cmd == "any command") {
sendResponse({ result: "any response from background" });
} else {
sendResponse({ result: "error", message: `Invalid 'cmd'` });
}
@jherax
jherax / filterArray.js
Last active February 23, 2024 12:59
Filters an array of objects with multiple match-criteria.
/**
* Filters an array of objects using custom predicates.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria
* @return {Array}
*/
function filterArray(array, filters) {
const filterKeys = Object.keys(filters);
return array.filter(item => {
@datchley
datchley / app.js
Last active September 20, 2022 01:22
"Getting Functional with Javascript" Blog post source files
/**
* Primary application logic for our Functional Programming blog example
* See related blog series at: http://www.datchley.name/tag/functional-programming/
* Version: 2.0
*/
// A simple, resuable comparison for '>='
function greaterThanOrEqual(a, b) {
return a >= b
}