Skip to content

Instantly share code, notes, and snippets.

View karolzlot's full-sized avatar
🏠
Working from home

Karol Zlot karolzlot

🏠
Working from home
View GitHub Profile
@dsosby
dsosby / config-highlight.cfg
Created August 3, 2011 15:24
A dark highlighting theme for Python's IDLE IDE based on Notepad++'s Obsidian color scheme
[Obsidian]
definition-foreground = #678CB1
error-foreground = #FF0000
string-background = #293134
keyword-foreground = #93C763
normal-foreground = #E0E2E4
comment-background = #293134
hit-foreground = #E0E2E4
builtin-background = #293134
stdout-foreground = #678CB1
@ayust
ayust / bisect-merges.py
Created March 14, 2012 23:12
Git bisection across only mainline commits (a la git log --first-parent)
#!/usr/bin/env python
import json
import optparse
import os
import subprocess
import sys
def gitdir():
@allanlaal
allanlaal / countries.sql
Last active August 30, 2021 02:09 — forked from adhipg/countries.sql
uses InnoDB and UTF8, uses ISO2 code as the primary key
--
-- Table structure for table `country`
--
CREATE TABLE IF NOT EXISTS `country` (
`iso` char(2) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`nicename` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`iso3` char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
@allanlaal
allanlaal / currency.sql
Last active December 5, 2021 06:51
SQL table of World currencies (even some expired ones) Source: http://bcmoney-mobiletv.com/blog/2008/12/30/currency-codes-dropdown-and-sql-table/ Cleaned up a bit, uses InnoDB and iso currency code as the PRIMARY key
--
-- Table structure for table `currency`
--
CREATE TABLE IF NOT EXISTS `currency` (
`iso` char(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`iso`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@SuryaSankar
SuryaSankar / M2M_Association_SQLalchemy.py
Last active September 25, 2023 07:30
An example of a many to many relation via Association Object in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship, backref
from sqlalchemy.ext.associationproxy import association_proxy
import uuid
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@nuada
nuada / calculate-kinship.sh
Created March 6, 2015 12:37
Calculate kinship coefficient for set of samples in VCF
#!/bin/bash
bcftools norm -Ou -m -any $1 | # Split multi-allelic alleles
bcftools norm -Ou -f /resources/hg19/ucsc.hg19.fasta | # Normalize
bcftools annotate -Ob -x ID -I +'%CHROM:%POS:%REF:%ALT' | # Replace IDs with unique ID
plink --bcf /dev/stdin --keep-allele-order --double-id --allow-extra-chr 0 --make-bed --out variants
king -b variants.bed --kinship --prefix kinship
king -b variants.bed --individual
@tresni
tresni / gist:83b9181588c7393f6853
Last active July 16, 2024 10:26
Authy to 1Password

Moving Authy to 1Password

1Password 5.3 for OSX, 5.2 for iOS, and 4.1.0.538 for Windows support OTP. I've been using Authy for a while now, but the fact is, I haven't really been using 2FA for some time. As mentioned by 1Password in a recent blog post, having the OTP generator and password on the same device is very much not 2FA. It's just an expiring OTP, which can help, but let's not kid ourselves too much.

With that out of the way. One of the things that was interesting to me was moving my OTP out of Authy and into 1Password. I like the control I get with 1Password, but I didn't want to have to reset all my OTP right away, that would suck. So, I got to dissecting the Authy Chrome App to see what I could do.

Run the Authy Chrome app and make sure it's unlocked.

Now, enable Developer mode in Chrome. We'll need this to inspect the background application that stores al

@0xbadfca11
0xbadfca11 / 00_README.md
Last active July 23, 2024 05:27
Windows ReFS versions
@vichango
vichango / countries.sql
Last active September 1, 2021 16:08 — forked from allanlaal/countries.sql
Uses InnoDB and UTF-8. The ISO 3166-1 alpha-2 code is used as the primary key.
--
-- Table structure for table `country`
--
CREATE TABLE IF NOT EXISTS `country` (
`iso` char(2) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`nicename` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`iso3` char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,