Skip to content

Instantly share code, notes, and snippets.

View RodolfoFerro's full-sized avatar
🐍
I speak Python.

Rodolfo Ferro RodolfoFerro

🐍
I speak Python.
View GitHub Profile
@yu-iskw
yu-iskw / add.sh
Last active July 1, 2022 20:51
Example to add a airflow connection to google cloud platform
#!/bin/bash
airflow run add_gcp_connection add_gcp_connection_python 2001-01-01
@rbnpi
rbnpi / ps3.py
Last active November 2, 2020 00:15
Control Sonic PI 3 from a wireless PS3 games controller See video at https://youtu.be/8HcHKyhZaSM
#!/usr/bin/env python3
#ps3 wireless controller interface by Robin Newman July 2017
#converts controller inputs to OSC messages
#which can be output to Sonic Pi 3, running on the local computer, or on an external machine
#rtested with ps3 "afterglow" wireless controller, dongle in Pi usb socket
#needs sudo apt-get install joystick after sudo apt-get update
#also needs sudo pip3 install python-osc
#Version 2. Modified to ensure clean exit on Ubuntu
import subprocess,pygame,sys
@cschiewek
cschiewek / x11_docker_mac.md
Last active April 24, 2026 17:32
X11 in docker on macOS

To forward X11 from inside a docker container to a host running macOS

  1. Install XQuartz: https://www.xquartz.org/
  2. Launch XQuartz. Under the XQuartz menu, select Preferences
  3. Go to the security tab and ensure "Allow connections from network clients" is checked.
  4. Run xhost + ${hostname} to allow connections to the macOS host *
  5. Setup a HOSTNAME env var export HOSTNAME=`hostname`*
  6. Add the following to your docker-compose:
 environment:
# Objective
# Use non-linear curve fitting to estimate the relaxation rate of an exponential
# decaying signal.
# Steps
# 1. Simulate data (instead of collecting data)
# 2. Define the objective function for the least squares algorithm
# 3. Perform curve fitting
# 4. Compare results
@RodolfoFerro
RodolfoFerro / install.sh
Created September 27, 2016 08:59
PyGame for Python 3 Mac
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
alias brew=/usr/local/bin/brew
brew install python3
alias python=python3
brew install mercurial
brew install git
brew install sdl sdl_image sdl_mixer sdl_ttf
brew tap homebrew/headonly
brew install --HEAD smpeg
brew install portmidi
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@jindrichmynarz
jindrichmynarz / dub_techno_in_sonic_pi.rb
Created December 8, 2015 19:11
Dub techno in Sonic Pi
use_debug false
use_bpm 130
# Our mixer!
master = (ramp *range(0, 1, 0.01))
kick_volume = 1
bass_volume = 1
revbass_volume = 1
snare_volume = 0.5
hats_volume = 0.5
@mcoms
mcoms / Gemfile
Created May 6, 2015 22:42
Fruit Piano prototype with MPR121, Arduino and Sonic Pi
source 'https://rubygems.org'
gem 'osc-ruby', '1.1.1'
gem 'serialport'
@vinhkhuc
vinhkhuc / simple_mlp_theano.py
Last active December 6, 2020 05:46
Simple Feedforward Neural Network using Theano
# Implementation of a simple MLP network with one hidden layer. Tested on the iris data set.
# Requires: numpy, sklearn, theano
# NOTE: In order to make the code simple, we rewrite x * W_1 + b_1 = x' * W_1'
# where x' = [x | 1] and W_1' is the matrix W_1 appended with a new row with elements b_1's.
# Similarly, for h * W_2 + b_2
import theano
from theano import tensor as T
import numpy as np
from sklearn import datasets
@adam-p
adam-p / Local PR test and merge.md
Last active April 19, 2026 06:59
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37