Skip to content

Instantly share code, notes, and snippets.

@behreajj
behreajj / bmesh_tut_18_convex_hull_fib_sphere.py
Created July 26, 2020 13:26
Fibonacci Sphere Convex Hull
from bpy import data as D, context as C
import bmesh
import math
def fibonacci_points(count=32, radius=0.5):
"""
Distributes points on a sphere according to
the golden ratio, (1.0 + sqrt(5.0)) / 2.0.
"""
@akey7
akey7 / amplitude_modulator.py
Created June 28, 2020 20:28
Writes and amplitude modulated waveform to a .wave file.
# Import libraries
import numpy as np
from scipy.io.wavfile import write
# Properties of the wav
sps = 44100 # DON'T change
carrier_hz = 440.0
modulator_hz = 0.25
ac = 1.0
@akey7
akey7 / sine_to_sounddevice.py
Created June 28, 2020 20:22
Plays a sine wave generated in NumPy to the sound device.
# Use the sounddevice module
# http://python-sounddevice.readthedocs.io/en/0.3.10/
import numpy as np
import sounddevice as sd
import time
# Samples per second
sps = 44100
@akey7
akey7 / numpy_sine_to_wav_file.py
Created June 28, 2020 20:20
This creates a sine wave in NumPy and writes it to a wave file.
import numpy as np
from scipy.io.wavfile import write
sps = 44100
freq_hz = 440.0
duration_s = 3.0
t_samples = np.arange(sps * duration_s)
waveform = np.sin(2 * np.pi * freq_hz * t_samples / sps)
waveform *= 0.3
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
import numpy as np
import matplotlib.pyplot as plt
#Carrier wave c(t)=A_c*cos(2*pi*f_c*t)
#Modulating wave m(t)=A_m*cos(2*pi*f_m*t)
#Modulated wave s(t)=A_c[1+mu*cos(2*pi*f_m*t)]cos(2*pi*f_c*t)
A_c = float(input('Enter carrier amplitude: '))
f_c = float(input('Enter carrier frquency: '))
A_m = float(input('Enter message amplitude: '))
@tamask
tamask / log.py
Created August 8, 2018 00:44
Route system output (stdout/stderr) of Blender to the app console (put in scripts/startup)
import os
import sys
import bpy
output = None
input = None
info = None
error = None
write = None
@sheljohn
sheljohn / colours-old.py
Last active May 3, 2024 03:59
Print with colors in most shells (Python, standalone)
# Python 2, class
# Author: J.Hadida (jhadida87 at ggooglemail)
class ColorPrinter:
"""
Usage:
cprint = ColorPrinter()
cprint.cfg('c','m','bux').out('Hello','World!')
cprint.rst().out('Bye now...')
@AtulKsol
AtulKsol / psql-error-fix.md
Last active April 10, 2024 07:41
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@jacobmischka
jacobmischka / ds4led
Created December 30, 2015 04:20
Changes color for ds4 controller lightbar on linux and gives permissions so games can change it too if they support it.
#!/bin/bash
# This isn't really that safe to blindly run,
# as it uses sudo to change system file permissions.
# Hopefully it shouldn't break anything though.
# Usage: ds4led [r value] [g value] [b value]
# or `ds4led orange` to set it to orange.
DS4="0003:054C:05C4.*"
cd /sys/class/leds