Skip to content

Instantly share code, notes, and snippets.

View jion's full-sized avatar

Manuel Schnidrig jion

View GitHub Profile
@jion
jion / README.md
Last active July 12, 2023 15:50
Sensitive configuration for relativenumbers mode

Toggleable Relative Numbering for Vim

This Vim configuration snippet introduces a feature that allows users to easily toggle between "relative" and "absolute" line number modes in Vim.

In "relative" line number mode, the lines are numbered relative to the cursor's current position, which can be helpful when making movements or operations that are relative to the current line. In "absolute" line number mode, Vim displays the actual line numbers, just like most other text editors.

The user can toggle between these two modes by pressing a combination of keys (<leader>`). The script remembers the user's preference and applies it to whichever window (a.k.a buffer) the cursor is currently in. This means that if a user prefers relative numbering, as they navigate between different windows, each will switch to relative numbering as they come into focus.

In addition, there are specific rules in place for certain buffer types, like terminal buffers, to disable line numbering altogether.

@jion
jion / csv_columns_subset.py
Last active April 2, 2022 23:58
Helper to filter CSV columns you need
#!/usr/bin/python3
import csv
import sys
csv_reader = csv.DictReader(sys.stdin)
csv_writer = csv.DictWriter(sys.stdout, fieldnames=[h for h in csv_reader.fieldnames if h in sys.argv[1:]])
csv_writer.writeheader()
for row in csv_reader:
csv_writer.writerow({f: row[f] for f in sys.argv[1:]})
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from . import models
from . import utils
def send_messages(request, merchant_id):
merchant = get_object_or_404(models.Merchant, id=merchant_id)
customers = models.Customer.objects.filter(merchant=merchant)
@jion
jion / keybase.md
Created March 31, 2020 14:45
Proof of Github Account

Keybase proof

I hereby claim:

  • I am jion on github.
  • I am jion (https://keybase.io/jion) on keybase.
  • I have a public key ASAAnImfrjIzNzVkkvWL0MGhHNPDwifv-jLhvHuGakExIwo

To claim this, I am signing this object:

@jion
jion / celery.sh
Created April 24, 2019 23:44 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@jion
jion / LoggerRedirection.py
Created May 25, 2018 16:22
Allows to redirect all the messages on a specific logger to another specified logger
import logging
class RedirectLoggingHandler(logging.Handler):
def __init__(self, dest_logger):
logging.Handler.__init__(self)
self.dest_logger = dest_logger
def emit(self, record):
try:
record.name = self.dest_logger.name
@jion
jion / is_braces_balanced.py
Last active February 18, 2018 17:59
Exercise that I had to do in a live sharing-code interview
def is_balanced(input_string):
pending_braces = list()
open_braces, closing_braces = '[{(', ']})'
for c in input_string:
if c in open_braces:
index = open_braces.index(c)
pending_braces.append(closing_braces[index])
continue
@jion
jion / keybase.md
Created September 20, 2017 16:01
Keybase proof

Keybase proof

I hereby claim:

  • I am jion on github.
  • I am jion (https://keybase.io/jion) on keybase.
  • I have a public key ASDUc4CSKKREq-BgEzVIvFuWMj2zWla5fu7rQyWr485_OQo

To claim this, I am signing this object:

@jion
jion / .tmux.conf
Created May 25, 2017 00:41 — forked from v-yarotsky/.tmux.conf
Mac OS X tmux config
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
@jion
jion / BEM Explanaition.html
Created February 23, 2017 18:18
BEM Explanaition
<div class="modal"> <!-- "Bloque. es el nombre del componente. se usa esta sintaxis: tu-vieja -->
<div class="modal__title"> <!-- Elemento. es una parte de las que compone al blouqe. usas bloque__elemento" -->
Esto es el titulo del modal
</div>
<div class="modal__footer"> <!-- Otro element. es el fotter que tiene los botones -->
<div class="button">Cancelar</div> <!-- dentro podes usar "minicomponentes" genéricos. aca quedaría medio choto usar "modal__button" porque todos los buttons son iguales en el sitio -->
<div class="button--primary">ACEPTAR</div> <!-- modificator. Es una variación del bloque/elemento origuinal. En este caso es el mismo estilo del botón, solo que, pongámosle, es de color azul o rojo mientras que el botón común es blanco" -->
</div>
</div>