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 / gist:d86c83645088cc829752d288a5763f39
Created November 28, 2023 04:34 — forked from arbabnazar/gist:6b9909cfba52ac066512ba5d1c1a1080
Example for Ansible git-module and ssh agent forwarding
# files/env:
Defaults env_keep += "SSH_AUTH_SOCK"
# tasks/main.yml
- name: ensure sudo keeps SSH_AUTH_SOCK in environment
copy: src=env
dest=/etc/sudoers.d/env
mode=0440
owner=root
group=root
@crazyguitar
crazyguitar / ssh_forwarding_cheatsheet.md
Created November 27, 2023 17:32 — forked from jezeniel/ssh_forwarding_cheatsheet.md
SSH Agent Forwarding cheatsheet

Using the ssh agent

The following would show a similar output if a key is already added to your agent, and you are good to go.

$ ssh-add -l
2048 d7:8e:3d:03:9c:4f:f8:9d:04:0f:11:c5:24:e1:2f:3a rsa w/o comment (RSA)

The following will show if no agent is running.

@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
*