Skip to content

Instantly share code, notes, and snippets.

@selimslab
selimslab / sensor.c
Last active August 7, 2019 20:15
TSL-2561 light sensor library for Nordic nRF 51822
#include < stdio.h >
#include "boards.h"
#include "app_util_platform.h"
#include "app_uart.h"
#include "app_error.h"
#include "nrf_drv_twi.h"
#include "nrf_delay.h"
#include "main.h"
/* Define version of GCC. */
<style>
:root{
--main: hsl(230, 44%, 55%);
--secondary: hsl(230, 44%, 55%)
}
body{
background-color: var(--main)
}
html{
from collections import defaultdict
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
@selimslab
selimslab / async-crawler.py
Last active May 10, 2020 18:06
a concurrent crawler in 100 lines
import asyncio
import logging
import collections
import urllib.parse
from pprint import pprint
import aiohttp
import bs4
class AsyncCrawler:
func climbStairs(n int) int {
memo := map[int]int{
1:1,
2:2,
}
var climb func(n int) int
climb = func (n int) int {
_, ok := memo[n];
if !ok {
from django.apps import AppConfig
class UsersConfig(AppConfig):
name = "users"
#include "headers/audio.h"
#define fifo_threshold 96 //Audio out fifo
/****************************************************************************************
* For playing the audio contained in passed array
****************************************************************************************/
void play_audio(int audio[],int audio_len)
{
int fifospace;
@selimslab
selimslab / robot.cpp
Created May 23, 2020 12:33
a mobile robot. obstacle avoiding, path-finder. built using Raspberry Pi, ROS, C++, and A* algorithm
#include <iostream>
#include <tuple>
#include <cmath>
const double PI = 3.141592653589793238463;
using namespace std;
class RobotController {
float robotRadius = 0.1;
@selimslab
selimslab / server.py
Last active May 23, 2020 19:16
a concurrent web server in 100 lines, using UNIX fork() syscall, following https://ruslanspivak.com/lsbaws-part1/
# coding: utf-8
"""
a simple concurrent web server
socket -> bind -> listen -> accept -> loop
"""
import socket
import os
import time
import signal

You are a professional robber planning to rob houses along a street.

Each house has a certain amount of money stashed.

Meanwhile, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

q1: max robbery ?

q2: what if houses form a circle so the first and last are neighbors ?