Skip to content

Instantly share code, notes, and snippets.

View faif's full-sized avatar

Sakis Kasampalis faif

View GitHub Profile
@faif
faif / plantuml-sequence.txt
Last active September 11, 2021 12:43
A sequence diagram in PlantUML
@startuml
hide footbox
title Bank transaction
actor Alice
Alice -> ATM: login(pin: int): boolean
ATM -> Alice: true
Alice -> ATM: deposit(amount: int): boolean
ATM -> BankAccount: deposit(amount: int): boolean
BankAccount -> ATM: true
try
{
// a CorruptFileError happens here..
}
catch (const std::exception& e)
{
// not caught when CorruptFileError is not a subclass of std::exception
}
@faif
faif / Dockerfile
Last active October 31, 2018 21:21
file with product versions
FROM alpine
COPY versions /tmp
RUN export PRODUCT_B_VERSION="$(grep product_b /tmp/versions | cut -d= -f2)" && \
printf "product b version is ${PRODUCT_B_VERSION}\n"
@faif
faif / pir.py
Created October 29, 2017 20:28
Raspberry Pi zero PIR demo
from pir import *
import time
import logging
PIR_PIN = 23
SLEEP_TIME = 5 # in seconds
def main():
pir = PassiveInfraredSensor(PIR_PIN)
logger = configure_logger()
@faif
faif / temperature.py
Last active August 2, 2019 10:45
Send MQTT messages to Adafruit IO using a Pycom board
import machine
import time
from umqtt import MQTTClient
from network import WLAN
main()
def main():

REST filter using curl

  • curl -g -X GET --header "Accept: application/json" http://localhost:3000/api/CoffeeShops?filter[where][city]=Amsterdam
  • curl -g -X GET --header "Accept: application/json" http://localhost:3000/api/CoffeeShops?filter[where][id]=2
  • curl -g -X GET --header "Accept: application/json" http://localhost:3000/api/CoffeeShops?filter[where][city]=Eindhoven&filter[limit]=1

REST filter using the explorer

  • {"where":{"id":2}}
  • {"where":{"city":"Eindhoven"}}
@faif
faif / cleancode.md
Last active January 15, 2017 22:17

Names

  • Communicate intent (no need for extra comments)
public class ParsedRequest {
}
  • Keep them up-to-date
  • Easy to pronounce
  • No encodings (hungarian notation, etc.) public interface IRequest {}
@faif
faif / walkthrough.swift
Last active August 3, 2016 13:24
A Swift walkthrough
/* Exploring core Swift
* Code excerpts: Various authors of PragPub (http://theprosegarden.com)
* https://www.objc.io/blog/archive/
* XCode version used: 7.3
*/
import UIKit
/* --------------------------functions-------------------------------- */
func fact(n: Int) -> Int {
import os
import requests
from bs4 import BeautifulSoup
"""Download photos from the public Flickr stream"""
def main():
keyword = read_keyword()
create_destination_dir(keyword)
@faif
faif / course.py
Last active November 19, 2016 17:02
'''variables'''
# assign to int
x = 5
x
type(x)
# assign to string
x = "foo"
x