Skip to content

Instantly share code, notes, and snippets.

View dennisfen's full-sized avatar

Dennis dennisfen

  • Vienna, Austria
  • 09:18 (UTC +02:00)
View GitHub Profile
@dennisfen
dennisfen / blueEnable_ALARM_non_mainline.md
Created September 6, 2020 19:03 — forked from shenghaoyang/blueEnable_ALARM_non_mainline.md
Bluetooth support on Raspberry Pis running Arch Linux ARM with non-mainline kernel.

Enabling bluetooth

[Pi 3B (Non-Plus) / Pi Zero W ONLY]

As of kernel package, linux-raspberrypi-4.14.59-1, support for notifying the kernel of the Broadcom bluetooth device through the device tree has been enabled.

There is no longer a need for btattach, which makes the lives of everyone easier. There is also no need to fall back to hciattach for better performance, as the

@dennisfen
dennisfen / list.c
Created July 2, 2017 16:44
Removing linked list entry with good taste
void remove_list_entry (entry) {
// we will use indirect pointer to traverse the list
indirect = &head;
// search the list for needed entry using indirect pointer for traversal
while ((*indirect) != entry) {
indirect = &(*indirect)->next;
}
// entry and indirect pointer point to the same location
@dennisfen
dennisfen / Makefile
Last active June 8, 2017 07:32
Sending file descriptors over sockets
all:
gcc -std=c11 -O0 -ggdb -o work main.c
@dennisfen
dennisfen / Makefile
Created June 5, 2017 19:00
Shell-like command piping
all:
gcc -std=c11 -O0 -ggdb -o shell shell.c
@dennisfen
dennisfen / Makefile
Created June 5, 2017 18:47
Derivative of a polynomial
all:
g++ -std=c++14 -o derivative derivative.cpp
@dennisfen
dennisfen / solution.cpp
Last active May 5, 2023 11:22
Номер треугольного числа
#include <iostream>
#include <ios>
#include <regex>
#include <cstdlib>
#include <string>
#include <errno.h>
#include <cmath>
std::string parse_input(const std::string& input) {
std::cout << std::boolalpha;
class session {
tcp::socket socket_;
array<unsigned char, 1024> data_;
//...
void do_read() {
socket_.async_read_some (buffer(data_),
[this](std::error_code ec, std::size_t n) {
// do stuff
//...
do_read();
@dennisfen
dennisfen / ping.py
Created October 26, 2016 16:58
Easy way to potykat palochkoy host in python
# it calls unix ping util and checks its return status
import subprocess
def pingIt(host):
try:
output = subprocess.check_output("ping -c 1 " + host, shell=True)
except Exception, e:
return False
return True
@dennisfen
dennisfen / sort_merge.cpp
Created October 20, 2016 12:18
Naive recursive merge sort
#include <vector>
#include <random>
using namespace std;
void print_vector(const vector<int>&);
vector<int> merge(const vector<int>&, const vector<int>&);
vector<int> merge_sort_recursive(const vector<int>& v) {
if (v.size() <= 1)
@dennisfen
dennisfen / 71-xusbdfwu.rules
Created October 14, 2016 13:54
Xilinx Platform Cable USB
## /etc/udev/rules.d/71-xusbdfwu.rules
# version 0003
ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0008", MODE="666"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0007", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusbdfwu.hex -D $tempnode"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0009", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xup.hex -D $tempnode"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000d", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_emb.hex -D $tempnode"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000f", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xlp.hex -D $tempnode"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0013", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xp2.hex -D $tempnode"
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0015", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb