Skip to content

Instantly share code, notes, and snippets.

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 Apr 19, 2021
My config.fish base
View config.fish
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 Dec 15, 2020
Install pyenv stuff in bigsur
View install_pyenv.sh
bash -c 'CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.7.4'
@cuevasclemente
cuevasclemente / parse_wikipedia_xml.py
Created Apr 29, 2019
Parse Wikpedia Articles (after extraction with wikiextractor, but if you strip punctuation from all tokens this might work with raw wikipedia xml export)
View parse_wikipedia_xml.py
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 Nov 3, 2018
My /etc/X11/xorg.conf.d/40-libinput.conf for my Elecom HUGE trackbacll
View 40-libinput.conf
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 Feb 13, 2018
Get default value for PATH and other variables
View default_env.sh
export PATH=$(getconf PATH)
@cuevasclemente
cuevasclemente / parse_wiki_files.py
Created Jun 26, 2017
Parse Wikipedia XML Extracted Files
View parse_wiki_files.py
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 Mar 28, 2017
Getting the hostname of a machine on the local network
View get_host_from_ip.sh
#!/bin/sh
nmblookup -A $1
@cuevasclemente
cuevasclemente / wiki_separated.awk
Created Mar 21, 2017
Awk for parsing through wikipedia articles separated by lines of five equal signs
View wiki_separated.awk
# 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 Mar 13, 2017
My X11 Synaptics config
View 70-synaptics.conf
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 Mar 2, 2017
Dirty script to get an ip address by hostname for an ssh server using avahi
View get_host_ip.sh
#!/bin/bash
hostname=""
avahi-browse _ssh._tcp -r -t | awk "c&&c--;/$HOSTNAME/{c=2}" | grep 'address'