Skip to content

Instantly share code, notes, and snippets.

View cnmoro's full-sized avatar
🎯
Focusing

Carlo Moro cnmoro

🎯
Focusing
View GitHub Profile
@cnmoro
cnmoro / Java create temporary io.File
Created August 12, 2019 01:58
Java create temporary io.File
String text = "This is a text to be written on the temporary file.";
File tempFile = File.createTempFile("tempFilePrefix", "tempFileSuffix", null);
FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(text.getBytes());
@cnmoro
cnmoro / Regex Split Csvs With Quotes Inside Cells
Created September 18, 2019 16:25
Regex Split Csvs With Quotes Inside Cells
,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)
@cnmoro
cnmoro / Zero-tier fix auth token error
Created September 19, 2019 13:56
Zero-tier fix auth token error
zerotier-cli: missing authentication token and authtoken.secret not found (or readable) in /var/lib/zerotier-one
cd /var/lib/zerotier-one
sudo chmod +rwx authtoken.secret
zerotier-cli join ################
@cnmoro
cnmoro / Python Remover Acentos
Created October 3, 2019 15:57
Python Remover Acentos
import re
import unicodedata
def strip_accents(text):
try:
text = unicode(text, 'utf-8')
except (TypeError, NameError):
pass
text = unicodedata.normalize('NFD', text)
text = text.encode('ascii', 'ignore')
@cnmoro
cnmoro / x11vnc-stack-smashing-detected-solution.mk
Last active October 8, 2019 13:49 — forked from mangoliou/x11vnc-stack-smashing-detected-solution.mk
x11vnc `stack smashing detected` solution.
# Install x-related to compile x11vnc from source code.
sudo apt-get update
sudo apt-get install -y libxtst-dev libssl-dev libjpeg-dev
# Grep source code.
wget http://x11vnc.sourceforge.net/dev/x11vnc-0.9.14-dev.tar.gz
gzip -dc x11vnc-0.9.14-dev.tar.gz | tar -xvf -
cd x11vnc-0.9.14/
./configure --prefix=/usr/local CFLAGS='-g -O2 -fno-stack-protector -Wall'
@cnmoro
cnmoro / Linux Tmux Commands
Last active October 14, 2019 18:51
Linux Tmux Commands
#Create
tmux new -s NAME_OF_TERMINAL
#Detach
$tmux> tmux detach
#Send command
tmux send -t NAME_OF_TERMINAL 'command here' C-m
#Kill
@cnmoro
cnmoro / JS Map Distinct
Created October 16, 2019 17:04
JS Map Distinct
let uniqueValues = array.map(v => v.property)
.filter((value, index, self) => self.indexOf(value) === index);
@cnmoro
cnmoro / Fix 'Uncaught ReferenceError: global is not defined'
Created October 17, 2019 19:45
Fix 'Uncaught ReferenceError: global is not defined'
Add to index.html head:
<script>
if (global === undefined) {
var global = window;
}
</script>
@cnmoro
cnmoro / Remove duplicate lines from text file
Created October 22, 2019 13:06
Remove duplicate lines from text file
sort -u file.csv > newfile.csv
@cnmoro
cnmoro / MongoDB Kill all operations
Created October 22, 2019 13:31
MongoDB Kill all operations
db.currentOp().inprog.forEach(function(cop){db.killOp(cop.opid)})