Skip to content

Instantly share code, notes, and snippets.

@fferri
fferri / Pd-dev-macOS.md
Created July 25, 2023 09:09
Pure-data development on macOS

Pure-data development on macOS

A few tips for pd development on macOS:

Enable get-task-allow for debugging in lldb

Pd.app is not enabled for debugging, thus the app needs to be re-signed with the get-task-allow entitlement enabled:

  1. obtain the current entitlements with:

Since communication over ROS2 across WSL2 border doesn't work out of the box, here's my notes for getting it to work.

Make sure to select cyclonedds RMW on both ends:

(Linux)

export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

(Windows)

#!/usr/bin/env python3
market, period = 'XBTEUR', 60
imgw, imgh = 22, 22
import krakenex
from pykrakenapi import KrakenAPI
api = krakenex.API()
k = KrakenAPI(api)
ohlc, last = k.get_ohlc_data(market, period)
a = ohlc.to_numpy()
a = a[:imgw,:]
correct_position(A, B, C, S) :- S = [A, _, _], \+ member(B, S), \+ member(C, S).
correct_position(A, B, C, S) :- S = [_, B, _], \+ member(A, S), \+ member(C, S).
correct_position(A, B, C, S) :- S = [_, _, C], \+ member(A, S), \+ member(B, S).
wrong_position(A, B, C, S) :- (S = [_, A, _] ; S = [_, _, A]), \+ member(B, S), \+ member(C, S).
wrong_position(A, B, C, S) :- (S = [B, _, _] ; S = [_, _, B]), \+ member(A, S), \+ member(C, S).
wrong_position(A, B, C, S) :- (S = [C, _, _] ; S = [_, C, _]), \+ member(A, S), \+ member(B, S).
two_wrong_position(A, B, C, S) :- S \= [A, _, _], S \= [_, B, _], member(A, S), member(B, S), \+ member(C, S).
two_wrong_position(A, B, C, S) :- S \= [A, _, _], S \= [_, _, C], member(A, S), member(C, S), \+ member(B, S).
# solution to puzzle https://www.youtube.com/watch?v=LyyHt7NfBxI
# "can you make 24 from 3 3 8 8 using only + - * / ( ) ?"
class Add:
def __init__(self, a, b):
self.a, self.b = a, b
def eval(self):
return self.a.eval() + self.b.eval()
def __repr__(self):
return '({!r} + {!r})'.format(self.a, self.b)
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
import json
import urllib
import urllib.request
import urllib.parse
from bs4 import BeautifulSoup
import re
from unidecode import unidecode
import youtube_dl
def dist(x, y):
return sum((xi-yi)**2 for xi,yi in zip(x,y))
class KDTree:
class Node:
def __init__(self, x, payload=None, axis=0):
self.x, self.axis, self.payload = x, axis, payload
self.l, self.r = None, None
def insert(self, x, payload=None):
#include <QtCore>
class SignalSpy {
static QThreadStorage<bool> entered;
static void signalBegin(QObject *caller, int signalIndex, void **);
static void slotBegin(QObject *caller, int index, void **);
public:
static void start();
};
We couldn’t find that file to show.
@fferri
fferri / execv_with_timeout.cc
Created February 18, 2016 15:16
execv with timeout
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <string.h>
void exec_with_timeout(char * const *argv, int timeout, int kill_signal = SIGKILL)
{
pid_t intermediate_pid = fork();
if(intermediate_pid == 0) {
pid_t worker_pid = fork();