Skip to content

Instantly share code, notes, and snippets.

@cunla
cunla / keybase-gpg-git.md
Created May 20, 2022 20:17
keybase-gpg-git signing

Set up Keybase.io, GPG & Git to sign commits on GitHub

This is a step-by-step guide on how to create a GPG key on keybase.io, adding it to a local GPG setup and use it with Git and GitHub.

Although this guide was written for macOS, most commands should work in other operating systems as well.

There's a video published by Timothy Miller explaining some parts of this guide. Discussion on Hacker News.

Note: If you don't want to use Keybase.io, follow [this guide][1] instead. For manually transferring keys to different hosts, check out this [answer on Stack Overflow][2].

@cunla
cunla / slack-crawler.py
Last active April 5, 2022 14:26
Crawl slack channel for threads and and all msgs in thread.
from datetime import datetime
import json
import logging
import os
from collections import namedtuple
from typing import Dict, Union, Tuple, List
from dotenv import load_dotenv, find_dotenv
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
@cunla
cunla / coverage badges
Last active January 21, 2024 19:56
coverage badges
coverage badges
test.json - wiwik
django-rq-scheduler-32.json - https://github.com/cunla/django-rqscheduler with django3.2/python3.9
django-rq-scheduler-4.json - https://github.com/cunla/django-rqscheduler with django4/python3.10
set tabstop=2
set expandtab
set shiftwidth=2
package com.backbase.interview.course.controller;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

Keybase proof

I hereby claim:

  • I am cunla on github.
  • I am danielmoran (https://keybase.io/danielmoran) on keybase.
  • I have a public key whose fingerprint is 5EE7 4D9D 1454 BBAE 0EA7 57EE 2A74 F32F A0A7 E28C

To claim this, I am signing this object:

@cunla
cunla / is_scramble.py
Created August 27, 2020 01:26
Is one string a scramble of another string (leetcode)
def is_scramble(s1: str, s2: str) -> bool:
if len(s1) != len(s2):
return False
if len(s1) == 0 or s1 == s2:
return True
sorted_s1 = sorted(s1)
sorted_s2 = sorted(s2)
if sorted_s1 != sorted_s2:
return False
@cunla
cunla / min_cost_for_tickets.py
Created August 27, 2020 00:58
Minimum Cost For Tickets interview problem
import sys
from typing import List
cost_options = [1, 7, 30]
def mincost_tickets(days: List[int], costs: List[int]) -> int:
"""
In a country popular for train travel, you have planned some train travelling one year in advance. The days of the year that you will travel is given as an array days. Each day is an integer from 1 to 365.
@cunla
cunla / coin_change.py
Created August 27, 2020 00:26
Coin change problem
import sys
from typing import List
def coin_change(coins: List[int], amount: int) -> int:
"""
Returns the minimum number of coins required to generate amount.
Complexity O(amount * len(coins))
:param coins:
:param amount: