Skip to content

Instantly share code, notes, and snippets.

View rvillas's full-sized avatar

rvillas rvillas

View GitHub Profile
@rvillas
rvillas / shiftinSquares.pde
Created August 24, 2022 22:47 — forked from beesandbombs/shiftinSquares.pde
shiftin’ squares
// by dave @beesandbombs
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
@rvillas
rvillas / cubes.pde
Created August 24, 2022 22:40 — forked from beesandbombs/cubes.pde
cube / cubes
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@rvillas
rvillas / hexes.pde
Created August 24, 2022 22:26 — forked from beesandbombs/hexes.pde
hexes
// by dave @beesandbombs
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
@rvillas
rvillas / background.js
Created July 8, 2021 18:23 — forked from muralikg/background.js
puppeteer screen capture demo. Currently records 10 second video. Change the timeout in background.js with your own logic to stop the recording when necessary. Try with `node export.js`
/* global chrome, MediaRecorder, FileReader */
chrome.runtime.onConnect.addListener(port => {
let recorder = null
port.onMessage.addListener(msg => {
console.log(msg);
switch (msg.type) {
case 'REC_STOP':
console.log('Stopping recording')
if (!port.recorderPlaying || !recorder) {
@rvillas
rvillas / README.md
Created January 15, 2020 21:37 — forked from dbuezas/README.md
Pie charts labels

This variation of a donut chart demonstrates how to add labels with lines. Clicking on the button changes the displayed data. Check Pie Chart with Labels and Missing Data to see how to handle transitions with missing/new data.

@rvillas
rvillas / ffmpeg.md
Created January 15, 2020 02:29 — forked from protrolium/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:

@rvillas
rvillas / perlintextdisplacement.pde
Created April 9, 2019 16:14 — forked from marcedwards/perlintextdisplacement.pde
Perlin noise text displacement
//
// Perlin noise text displacement.
// Created using Processing 3.5.3.
//
// Code by @marcedwards from @bjango.
//
PGraphics textbuffer;
void setup() {
@rvillas
rvillas / regexCheatsheet.js
Created January 10, 2019 20:49 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@rvillas
rvillas / gist:51ec4722f79c42b2619c
Created June 10, 2015 00:10
rake task to terminate postgresql connections
# http://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection
namespace :db do
desc "Fix 'database is being accessed by other users'"
task :terminate => :environment do
ActiveRecord::Base.connection.execute <<-SQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
@rvillas
rvillas / gist:0fa6ed09eabdd3f275f6
Created June 9, 2015 23:53
pg connections cheat
-- postgresql
-- list all open connections
SELECT * FROM pg_stat_activity;
-- close all open connections
select pg_terminate_backend(pid) from pg_stat_activity where datname='bow_production';