Skip to content

Instantly share code, notes, and snippets.

View cuevasclemente's full-sized avatar
💭
Writing if statements. Then, else.

Clemente Cuevas cuevasclemente

💭
Writing if statements. Then, else.
  • Erudite AI
  • Montreal, QC
View GitHub Profile
@cuevasclemente
cuevasclemente / config.fish
Created April 19, 2021 18:39
My config.fish base
function l
ls
end
set -x PATH /Users/clemente/.cargo/bin /usr/local/bin $PATH
pyenv init - | source
function show_git_branch
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
@cuevasclemente
cuevasclemente / install_pyenv.sh
Created December 15, 2020 21:20
Install pyenv stuff in bigsur
bash -c 'CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.7.4'
@cuevasclemente
cuevasclemente / parse_wikipedia_xml.py
Created April 29, 2019 18:05
Parse Wikpedia Articles (after extraction with wikiextractor, but if you strip punctuation from all tokens this might work with raw wikipedia xml export)
with open("./wikipedia_articles_text") as f:
article_text = f.read()
articles = article_text.split("</doc>")
documents = []
for i, article in enumerate(articles):
lines = article.split("\n")
if i == 0:
title = lines[1]
text = "\n".join(lines[3:])
@cuevasclemente
cuevasclemente / 40-libinput.conf
Created November 3, 2018 22:54
My /etc/X11/xorg.conf.d/40-libinput.conf for my Elecom HUGE trackbacll
Section "InputClass"
Identifier "touchpad"
Driver "libinput"
Option "Name" "ELECOM TrackBall Mouse HUGE TrackBall"
# Normal Mapping
Option "ButtonMapping" "3 2 2 4 5 6 7 1 1 10 11 12 13 14 15 16"
# FPS Mapping
#Option "ButtonMapping" "1 2 3 4 5 6 7 1 3 10 11 12 13 14 15 16"
EndSection
@cuevasclemente
cuevasclemente / default_env.sh
Created February 13, 2018 21:21
Get default value for PATH and other variables
export PATH=$(getconf PATH)
@cuevasclemente
cuevasclemente / parse_wiki_files.py
Created June 26, 2017 21:47
Parse Wikipedia XML Extracted Files
import argparse
from os import path
def parse_wiki_file(output_location, filename):
with open(filename) as f:
txt = f.read()
docs = txt.split("</doc>")
split_by_line = [doc.split("\n") for doc in docs]
with_title = [{"title": docs[0][1], "body": "\n".join(docs[0][3:])}] + [{
@cuevasclemente
cuevasclemente / get_host_from_ip.sh
Created March 28, 2017 21:50
Getting the hostname of a machine on the local network
#!/bin/sh
nmblookup -A $1
@cuevasclemente
cuevasclemente / wiki_separated.awk
Created March 21, 2017 17:45
Awk for parsing through wikipedia articles separated by lines of five equal signs
# articles look like:
# Title
# Article text...
# ....
# =====
# FS="\n", set the field separator to be newlines, used to get the title (which will be $2)
# RS="=====" set the record separtor to be five equal signs
# gsub("/", "_", $2): replace all forward slashes with underscores in the title line, needed so that we don't upset anyone
# if statement checks to see if there is already a file with the title we're looking at
@cuevasclemente
cuevasclemente / 70-synaptics.conf
Created March 13, 2017 18:41
My X11 Synaptics config
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
Option "TapButton1" "1"
Option "FingerLow" "29"
Option "FingerHigh" "34"
Option "FingerPress" "73"
Option "HorizTwoFingerScroll" "1"
Option "TapButton2" "3"
@cuevasclemente
cuevasclemente / get_host_ip.sh
Created March 2, 2017 18:34
Dirty script to get an ip address by hostname for an ssh server using avahi
#!/bin/bash
hostname=""
avahi-browse _ssh._tcp -r -t | awk "c&&c--;/$HOSTNAME/{c=2}" | grep 'address'