Skip to content

Instantly share code, notes, and snippets.

View massahud's full-sized avatar

Geraldo Massahud massahud

View GitHub Profile
@massahud
massahud / Portable Node.js andNPM on windows.md
Last active April 30, 2024 17:47
Portable Node.js and NPM on windows
  1. Get node binary (node.exe) from http://nodejs.org/download/
  2. Create the folder where node will reside and move node.exe to it
  3. Download the last zip version of npm from http://nodejs.org/dist/npm
  4. Unpack the zip inside the node folder
  5. Download the last tgz version of npm from http://nodejs.org/dist/npm
  6. Open the tgz file and unpack only the file bin/npm (without extension) directly on the node folder.
  7. Add the the node folder and the packages/bin folder to PATH
  8. On a command prompt execute npm install -g npm to update npm to the latest version

Now you can use npm and node from windows cmd or from bash shell like Git Bash of msysgit.

@massahud
massahud / Remove date from jupyter exported pdf.md
Created December 2, 2022 14:31
Remove date from jupyter exported pdf

Remove date from jupyter exported pdf

Add \date{} to share/jupyter/nbconvert/templates/latex/base.text.j2 anywhere before /maketitle (e.g. before the title block)

If you want to control it using the notebook metadata, add this instead:

    ((* if nb.metadata.get('nodate', false) *))
    \date{}
    ((* endif *))
@massahud
massahud / CODE PUNS.md
Last active November 29, 2022 13:19
Code Puns

Code Puns

echo "export GPG_TTY=$(tty)" >> ~/.zshrc
echo "pinentry-program $(which pinentry-curses)" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent
source ~/.zshrc
echo test | gpg --clearsign
@massahud
massahud / ChunkSpliterator.java
Created June 2, 2022 14:28
Chunk spliterator - transforms Stream<X> into Stream<List<X>>
import java.util.ArrayList;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class ChunkSpliterator<T> implements Spliterator<List<T>>
{
@massahud
massahud / NQueens.java
Last active December 26, 2021 01:45
N-Queens problem implementation with backtracking
/**
* N-Queens is the problem to plane N chess queens into a NxN board without
* in a way that no queen threats another one.
* This implementation uses recursion and backtracking to find the solution.
*/
public class NQueens {
/**
* Tries to place N queens into an NxN chess board
*
@massahud
massahud / eclipselink.md
Last active October 28, 2021 13:16
Wildfly 10.1.0
@massahud
massahud / bitmask.go
Last active May 3, 2021 10:17
Bitmask using iota in go. Playground link: https://play.golang.org/p/jKuDcNVt-iK
package main
import "fmt"
const (
A int8 = 1 << iota
B
C
)
@massahud
massahud / README.MD
Last active September 22, 2020 21:05
Minecraft bedrock server on aws lightsail
  1. create an lightsail OS Only Ubuntu instance
  2. turn on port forwarding of UDP
  3. set static ip
  4. ssh into the instance
  5. create and cd to /minecraft directory
  6. wget and unzip the latest bedrock server for ubuntu (https://www.minecraft.net/en-us/download/server/bedrock)
  7. create a run.sh (chmod 755) script with the following code:
#!/bin/bash
LD_LIBRARY_PATH=. ./bedrock_server
@massahud
massahud / tolocalestring.js
Created December 14, 2016 11:53
Date to locale string in javascript
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
let year = 'numeric';
let month = '2-digit';
let day = '2-digit';
let hour = '2-digit';
let minute = '2-digit';
let second = '2-digit';
let hour12 = false;
let weekday = 'short';
let era = 'narrow';