Skip to content

Instantly share code, notes, and snippets.

View rvillas's full-sized avatar

rvillas rvillas

View GitHub Profile
@rvillas
rvillas / demo.html
Last active August 29, 2015 14:01 — forked from zenlor/demo.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script type='text/javascript' src='lazyload.js'></script>
<style type='text/css'>
body {
@rvillas
rvillas / db.rake
Last active August 29, 2015 14:10 — forked from hopsoft/db.rake
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
%w(rubygems sequel fileutils yaml active_support/inflector).each{|g| require g}
require File.join(File.dirname(__FILE__), "downmark_it")
module WordPress
def self.import(database, user, password, table_prefix = "wp", host = 'localhost')
db = Sequel.mysql(database, :user => user, :password => password, :host => host, :encoding => 'utf8')
%w(_posts _drafts images/posts/featured).each{|folder| FileUtils.mkdir_p folder}
@rvillas
rvillas / pngquant_all
Created May 21, 2015 23:25
pngquant an entire folder
find . -name '*.png' -exec pngquant --ext .png --force {} \;
@rvillas
rvillas / pg_install.sh
Created May 21, 2015 23:33
install pg gem with postgres.app
gem install pg -v '0.18.1' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
@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';
@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 / 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 / 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 / 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: