Skip to content

Instantly share code, notes, and snippets.

View dridk's full-sized avatar

sacha schutz dridk

View GitHub Profile
@dridk
dridk / RangeSlider.py
Last active February 1, 2024 08:59
The following code creates a range slider as a Qt widget with a native looks and feel
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2.QtGui import *
import sys
class RangeSlider(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
@adefelicibus
adefelicibus / split-vcf-by-sample.sh
Created January 31, 2017 18:29
Split a vcf file by samples
for file in *.vcf*; do
for sample in `bcftools view -h $file | grep "^#CHROM" | cut -f10-`; do
bcftools view -c1 -Oz -s $sample -o ${file/.vcf*/.$sample.vcf.gz} $file
done
done
@PoisonAlien
PoisonAlien / readBam.C
Last active November 9, 2023 21:21
reading bam files in C using htslib
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <htslib/sam.h>
int main(int argc, char *argv[]){
samFile *fp_in = hts_open(argv[1],"r"); //open bam file
bam_hdr_t *bamHdr = sam_hdr_read(fp_in); //read header
bam1_t *aln = bam_init1(); //initialize an alignment
@akhenakh
akhenakh / tools.py
Created June 19, 2012 14:47
flask jsonify with support for MongoDB from tools import jsonify
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
raise ImportError
import datetime
from bson.objectid import ObjectId
from werkzeug import Response
@pachacamac
pachacamac / google_speech_recognition.rb
Created December 11, 2011 10:52
google speech recognition with ruby
require 'rest_client'
require 'json'
a = `sox -d --norm -t .flac - silence -l 1 0 1% 1 6.0 1% rate 16k`
#a = `arecord -q -d 3 -c 1 -f S16_LE -r 22050 -t wav | flac - -f --totally-silent -o-`
r = RestClient.post 'https://www.google.com/speech-api/v1/recognize?lang=en-US', a,
:content_type => 'audio/x-flac; rate=16000'
if j = JSON.parse(r)
(p j; `espeak 'you said: #{j['hypotheses'].first['utterance']}'`)
end