Skip to content

Instantly share code, notes, and snippets.

View Abreto's full-sized avatar
🔋
Charging

Abreto Fu Abreto

🔋
Charging
View GitHub Profile

Adopted from here https://topaxi.codes/use-npm-without-root-or-sudo-rights/

I'm saving this as a gist and modifying it to ensure that if the original blog post disappears it lives on somewhere.

Added some notes for Ubuntu 18.04 and similar.

Today we're going to setup our npm installation to be used without root or sudo rights.

By default, if you install packages globally with npm, npm tries to install them into a system directory (i.e. /usr/local/lib/node_modules). With the next steps, we're going to use your home directory for those files.

@Abreto
Abreto / certbot-wildcard.sh
Last active February 16, 2020 14:57
for wildcard domains
#!/usr/bin/env sh
# certbot certonly --manual --preferred-challenges=dns-01 --server=https://acme-v02.api.letsencrypt.org/directory
set -x
new () {
docker run --rm -it \
-v "$(pwd)":/etc/letsencrypt \
certbot/certbot \
@Aerijo
Aerijo / example.tex
Last active January 16, 2021 08:43
LaTeX commands for Hoare logic
\documentclass[a4paper]{article}
\input{./hoare.tex}
\begin{document}
\begin{hoare}
\heq[a]{m * (a-b) > 0}{n := a-b}{m * n > 0}{\A}
\heq[b]{1 * (a-b) > 0}{m := 1}{m * (a-b) > 0}{\A}
\heq[c]{a > b}{m := 1}{m * (a-b) > 0}{\PrE(b)}
\heq[d]{a > b}{m := 1; n := a-b}{m * n > 0}{\Seq(c, a)}
\end{hoare}
@juanpabloaj
juanpabloaj / logging_env.py
Last active August 17, 2024 17:49
python logging, log level with environment variable
import os
import logging
LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper()
logging.basicConfig(level=LOGLEVEL, format="%(asctime)s %(message)s")
@gaearon
gaearon / modern_js.md
Last active October 25, 2024 06:12
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@zuyu
zuyu / ubuntu-install-gcc-6
Last active June 30, 2024 11:38
Install gcc 6 on Ubuntu
sudo apt update && \
sudo apt install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt update && \
sudo apt install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
gcc -v
@asmateus
asmateus / instructions.md
Last active October 24, 2024 06:53
Simple Slurm configuration in Debian based systems

Slurm Configuration Debian based Cluster

Here I will describe a simple configuration of the slurm management tool for launching jobs in a really simplistic cluster. I will assume the following configuration: a main node (for me it is an Arch Linux distribution) and 3 compute nodes (for me compute nodes are Debian VMs). I also assume there is ping access between the nodes and some sort of mechanism for you to know the IP of each node at all times (most basic should be a local NAT with static IPs)

Basic Structure

Slurm management tool work on a set of nodes, one of which is considered the master node, and has the slurmctld daemon running; all other compute nodes have the slurmd daemon. All communications are authenticated via the munge service and all nodes need to share the same authentication key. Slurm by default holds a journal of activities in a directory configured in the slurm.conf file, however a Database management system can be set. All in all what we will try to do is:

  • Install `munge
@danielsharvey
danielsharvey / convert_cpbitmap
Last active September 15, 2022 14:32
Converting iPhone iOS '.cpbitmap' images to PNGs
#!/usr/bin/python
from PIL import Image,ImageOps
import struct
import sys
if len(sys.argv) < 3:
print "Need two args: source_filename and result_filename\n";
sys.exit(0)
filename = sys.argv[1]
result_filename = sys.argv[2]
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active November 18, 2024 23:23
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@ruzickap
ruzickap / aws_create_site.yml
Created February 16, 2017 12:35
Ansible playbook which creates instances and tag volumes
---
- name: Create Instance in AWS
hosts: localhost
connection: local
gather_facts: false
vars:
aws_access_key: "xxxxxx"
aws_secret_key: "xxxxxx"
security_token: "xxxxxx"