Skip to content

Instantly share code, notes, and snippets.

@azlan
azlan / node-migrate.fish
Last active December 28, 2023 07:50
nodejs repo migration
# https://github.com/nodesource/distributions/wiki/How-to-migrate-to-the-new-repository (for bash)
# Remove the GPG keyring file associated with the old repository
sudo rm /etc/apt/keyrings/nodesource.gpg
# Remove the old repository's list file
sudo rm /etc/apt/sources.list.d/nodesource.list
# Define the desired Node.js major version
set NODE_MAJOR 20
# Update local package index
@azlan
azlan / wgg.go
Created September 1, 2023 03:14
package main
import (
"fmt"
"log"
"os"
"os/exec"
"strings"
)
@azlan
azlan / rsa.js
Last active July 12, 2023 14:08
// https://en.wikipedia.org/wiki/RSA_(cryptosystem)
// Least common multiple
function lcm(a, b) {
let min = (a > b) ? a : b;
while (true) {
if (min % a === 0 && min % b === 0) {
break;
}
min++;
#!/usr/bin/env fish
set TMP_DIR "/tmp"
function get_latest_go_version
set GO_DEV_DL_PAGE "https://go.dev/dl/"
set LATEST_VERSION (curl -sL $GO_DEV_DL_PAGE | grep -oP 'go\d+(\.\d+)+\.linux-amd64\.tar\.gz' | awk -F '.linux-amd64.tar.gz' '{print $1}' | sort -V | tail -n 1 | sed 's/go//')
echo $LATEST_VERSION
end
@azlan
azlan / update_go.sh
Last active May 4, 2023 02:45
update go
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: ./update_go.sh version (example 1.20.4)"
exit 1
fi
GO_VERSION=$1
GO_ARCHIVE="go${GO_VERSION}.linux-amd64.tar.gz"
GO_DOWNLOAD_URL="https://go.dev/dl/${GO_ARCHIVE}"
@azlan
azlan / weather.html
Created August 6, 2016 10:47
weather
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>z</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<button onclick='getWeather()'>Get weather</button>
<?php
$array = array(1,2,3,2,4,5,4);
sort($array);
$new_array = array();
$duplicate = -1;
$x = 0;
for ($x = 0; $x < count($array)-1; $x++) {
if ($array[$x] != $array[$x+1] && $array[$x] != $duplicate) {
array_push($new_array,$array[$x]);
'atom-text-editor':
'alt-l': 'editor:split-selections-into-lines'