Skip to content

Instantly share code, notes, and snippets.

View crazyguitar's full-sized avatar
🎯
Focusing

CHANG-NING TSAI crazyguitar

🎯
Focusing
View GitHub Profile
@crazyguitar
crazyguitar / MacOSX_ssh_forwarding.md
Created October 12, 2023 20:30 — forked from gwarf/MacOSX_ssh_forwarding.md
Using ssh forwarding (Agent and X11) on MacOS X

SSH Forwarding on MacOS X

Forwarding SSH agent

Configure ~/.ssh/config

# Allow Agent forwarding for a specific host (by security)
Host remotehost
  ForwardAgent yes
@crazyguitar
crazyguitar / README.md
Created August 17, 2023 23:35 — forked from P4UL-M/README.md
Changing playback sound speed in realtime with python and multiprocessing

Changing playback sound speed in realtime with python and multiprocessing

This is a script to change the sound speed in real time like for example background music in pygame.

The script generates the raw data of a sound file each time there is space in the queue. The sample will scale to the desired speed which you can modify with sound_Factor.

To play the music, you just need to get buffers from the queue and pass them to your music stream. Exemple for pygame :

# musique update
if channel.get_queue() == None:
@crazyguitar
crazyguitar / asyncio_loop_in_thread.py
Created May 12, 2023 16:24 — forked from dmfigol/asyncio_loop_in_thread.py
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable
@crazyguitar
crazyguitar / app.py
Created May 4, 2023 16:51 — forked from mivade/app.py
Websockets with Flask via aiohttp
"""Simple demo of using Flask with aiohttp via aiohttp-wsgi's
WSGIHandler.
"""
import asyncio
from aiohttp import web
from aiohttp_wsgi import WSGIHandler
from flask import Flask, render_template
@crazyguitar
crazyguitar / ffmpeg.md
Created March 29, 2023 23:26 — forked from liangfu/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@crazyguitar
crazyguitar / client.cpp
Created March 8, 2023 22:24 — forked from Flast/client.cpp
Graceful Restart with Boost.Asio
#define BOOST_RESULT_OF_USE_DECLTYPE
#include <chrono>
#include <thread>
#include <boost/mpi.hpp>
#include <iostream>
#include <sstream>
#include <utility>
@crazyguitar
crazyguitar / ansible_local_playbooks.md
Created March 1, 2023 17:05 — forked from alces/ansible_local_playbooks.md
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local 127.0.0.1 playbook.yml
  • using inventory:
127.0.0.1 ansible_connection=local
@crazyguitar
crazyguitar / ConsumerProducerQueue.h
Created February 11, 2023 17:05 — forked from dpressel/ConsumerProducerQueue.h
C++ 11 Consumer Producer Buffer with a single Condition Variable
#ifndef __CONSUMERPRODUCERQUEUE_H__
#define __CONSUMERPRODUCERQUEUE_H__
#include <queue>
#include <mutex>
#include <condition_variable>
/*
* Some references in order
*
@crazyguitar
crazyguitar / LICENSE
Created January 16, 2023 08:33 — forked from yamnikov-oleg/LICENSE
Shared (interprocess) mutexes on Linux
MIT License
Copyright (c) 2018 Oleg Yamnikov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@crazyguitar
crazyguitar / Makefile
Created January 16, 2023 08:29 — forked from sehe/Makefile
Boost shared memory lockfree circular buffer queue
all:consumer producer
CPPFLAGS+=-std=c++03 -Wall -pedantic
CPPFLAGS+=-g -O0
CPPFLAGS+=-isystem ~/custom/boost/
LDFLAGS+=-L ~/custom/boost/stage/lib/ -Wl,-rpath,/home/sehe/custom/boost/stage/lib
LDFLAGS+=-lboost_system -lrt -lpthread
%:%.cpp