Skip to content

Instantly share code, notes, and snippets.

View sgsfak's full-sized avatar

Stelios Sfakianakis sgsfak

  • Heraklion Greece
  • 03:29 (UTC +03:00)
  • LinkedIn in/sgsfak
View GitHub Profile
@sgsfak
sgsfak / Uninstall-pkg.md
Created June 3, 2021 11:51 — forked from githubutilities/Uninstall-pkg.md
Uninstall pkg manually in OS X

Mac Uninstall pkg Manually

  • using pkgutil
# list all your installed packages
pkgutil --pkgs

# show your package info
pkgutil --pkg-info 
@sgsfak
sgsfak / burger.html
Created May 6, 2021 21:28
An animated "burger" menu
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Burger menu</title>
<style>
:root {
--burger-line-width: 26px;
--burger-line-height: 4px;
@sgsfak
sgsfak / leetcode-Report-Contiguous-Dates.sql
Last active July 11, 2020 12:28
Leetcode: report-contiguous-dates
-- Problem description found at https://code.dennyzhang.com/report-contiguous-dates
-- Schema and test data:
-- CREATE TABLE Failed(fail_date DATE);
-- CREATE TABLE Succeeded(success_date DATE);
-- INSERT INTO Failed VALUES ('2018-12-28'), ('2018-12-29'), ('2019-01-04'), ('2019-01-05');
-- INSERT INTO Succeeded VALUES ('2018-12-30'),('2018-12-31'),('2019-01-01'),('2019-01-02'),('2019-01-03'),('2019-01-06');
WITH RECURSIVE
tasks(dt, state) AS
(SELECT success_date, 'succeeded'

Get all COVID-19 trials:

curl https://clinicaltrials.gov/api/query/study_fields?fields=NCTId,Condition,OverallStatus,BriefTitle&expr=COVID-19&field=ConditionMeshTerm&fmt=csv

API docs

def is_vcf(vcffile):
"""Checks whether the given filename is a VCF file, handling
also the case of gzipped ones"""
import re
import gzip
try:
with open(vcffile, 'rb') as fp:
buf = fp.read(80)
if (buf[0] == 0x1F and
buf[1] == 0x8B and
@sgsfak
sgsfak / Comparing data formats.md
Last active January 30, 2020 17:19
A comparison of CBOR, MessagePAck, CSV, and JSON encoding for some measurement data
@sgsfak
sgsfak / PEMtoPublicKey.java
Last active February 13, 2019 21:52
Convert PEM and (RSA) public keys back and forth
import java.security.Security;
import java.security.spec.X509EncodedKeySpec;
import java.security.KeyFactory;
import java.security.spec.RSAPublicKeySpec;
import java.security.PublicKey;
class PEMtoPublicKey {
public static void public static void main(String[] args) {
@sgsfak
sgsfak / webcam_capture.cpp
Created October 5, 2018 14:27 — forked from mik30s/webcam_capture.cpp
Simple C++ program to capture a webcam frame in Linux
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <linux/ioctl.h>
#include <linux/types.h>
#include <linux/v4l2-common.h>
#include <linux/v4l2-controls.h>
#include <linux/videodev2.h>
#include <fcntl.h>
#include <unistd.h>
@sgsfak
sgsfak / frequency_stack.c
Last active September 19, 2018 05:35
Maximum Frequency Stack, see https://leetcode.com/problems/maximum-frequency-stack/description/ using a data structure similar to 'treap'
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
typedef int TYPE;
typedef struct list_node {
struct list_node* next;
int x;
@sgsfak
sgsfak / lists.c
Last active September 12, 2018 14:49
Some basic (single-linked) list manipulation (reverse, etc.)
#include <stdio.h>
#include <stdlib.h>
/**
* Definition for singly-linked list.
* */
struct ListNode {
int val;
struct ListNode *next;
};