Skip to content

Instantly share code, notes, and snippets.

View guillermo-carrasco's full-sized avatar

Guillermo Carrasco guillermo-carrasco

View GitHub Profile
@guillermo-carrasco
guillermo-carrasco / simNGS_unique_ids.patch
Created May 13, 2013 16:13
Unique read IDs for simLibrary
diff -ru simNGS.orig/src/simlibrary.c simNGS/src/simlibrary.c
--- simNGS.orig/src/simlibrary.c 2013-05-13 17:45:17.000000000 +0200
+++ simNGS/src/simlibrary.c 2013-05-13 18:06:41.000000000 +0200
@@ -33,12 +33,13 @@
#define QUOTE(A) Q_(A)
#define DEFAULT_COV 0.055
#define DEFAULT_OUT "fasta"
+#define DEFAULT_UNIQUE "not"
#define DEFAULT_INSERT 400
#define DEFAULT_NCYCLE 45
@guillermo-carrasco
guillermo-carrasco / deinterleave.c
Created May 18, 2013 14:27
FASTQ files deinterleaver.
/*
Deinterleave FASQ files containing both reads from a paired-end read.
The script makes the following assumption:
* FASTQ format (4 lines per read), and the two reads (fordward and reverse) in a row.
USAGE: :/deinterleave file.fastq f.file.fastq r.file.fastq
RESULT: f.file.fastq r.file.fastq containing fordward and backward reads, respectively
Can deinterleave FASTQ files of any size, does not consume memory. The execution time is
I/O bounded.
@guillermo-carrasco
guillermo-carrasco / gist:6623249
Created September 19, 2013 13:10
Redis Handler test
import logging
from logbook.queues import RedisHandler
h = RedisHandler(key='python_agent')
l = logging.getLogger('redis')
l.addHandler(h)
l.warn('hejjjjjj')

In this step we'll create a swarm cluster from two nodes. You should've received access to two nodes in AWS.

  1. SSH in to the first node: ssh -i docker_demo.pem ubuntu@IP1
  2. Figure out the internal IP address of the node: ifconfig and check the eth0 address (10.0....)
  3. Initialize the Swarm cluster: `docker swarm init --listen-addr INTERNAL_IP --advertise-addr INTERNAL_IP
  4. Open a new tab and SSH to the other node: ssh -i docker_demo.pem ubuntu@IP2
  5. Check the internal IP of that node: ifconfig and eth0
  6. Join to the cluster with the command the previous command printed out. Before executing the command, you need to the extend it with the --listen-addr and --advertise-addr parameters (using the internal IP of the second node): docker swarm join TOKEN --listen-addr 10.0.... --advertise-addr 10.0..... node1...
  7. Get back to the first node and verify the results: docker node ls
version: 1
formatters:
custom_format:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
filters:
myapp:
name: myapp
handlers:
console:
class: logging.StreamHandler
import logging
parent_log = logging.getLogger('parent')
child_1 = logging.getLogger('parent.child_1')
child_2 = logging.getLogger('parent.child_2')
import yaml
import logging
import logging.config
with open('config.yaml', 'r') as f:
conf = yaml.load(f)
logging.config.dictConfig(conf)
myapp = logging.getLogger('myapp')
@guillermo-carrasco
guillermo-carrasco / select_random_card.py
Last active July 8, 2020 06:58
Select a random Machine Learning card
import glob
import os
import random
if not os.path.exists('selected.txt'):
open('selected.txt', 'a').close()
with open('selected.txt', 'r') as f:
selected = f.read().splitlines()
@guillermo-carrasco
guillermo-carrasco / update_requirements.py
Last active October 28, 2021 08:35
Update all versions of a requirements.txt file to the latest ones (or just list the resulting file with -d)
import argparse
import logging
import re
import subprocess
import sys
from pathlib import Path
from typing import List
def fetch_latest_version(library):
@guillermo-carrasco
guillermo-carrasco / whatsapp.py
Last active June 7, 2023 19:40
Whatsapp chat parser class
import re
from collections import Counter
from datetime import datetime
import emoji
import pandas as pd
class WhatsappChat:
DATE_FORMAT = "[%m/%d/%y, %H:%M:%S]"