Skip to content

Instantly share code, notes, and snippets.

View sunny's full-sized avatar
☀️

Sunny Ripert sunny

☀️
View GitHub Profile
@sunny
sunny / detect_unused_tables_and_columns.rb
Last active March 29, 2020 07:09
Detect unused tables and columns
# Paste this a your production console to detect which tables are empty, which
# columns are empty and which columns contain a single value.
#
# Adapted from http://blog.ianenders.com/coding/2013/07/02/detecting-unused-db-fields-in-rails.html
connection = ActiveRecord::Base.connection
connection.tables.each do |t|
puts "----> #{t}"
count_query = "SELECT COUNT(1) as count FROM #{t}"
count = connection.select_all(count_query, "Count").first['count']
<!DOCTYPE html>
<html>
<head>
<title>Générateur de titre de conférence XebiCon</title>
<link
href="https://fonts.googleapis.com/css?family=Lato&amp;display=swap"
rel="stylesheet"
/>
<style>
p {
# frozen_string_literal: true
module Finder
attr_reader :id
def initialize(**)
@id = self.class.count
end
def self.included(base)
@sunny
sunny / waver
Last active January 28, 2020 14:33
Cut wavs using ffmpeg
#!/usr/bin/env ruby
def ffprobe_duration(wav)
call(
"ffprobe " \
"'#{wav}' " \
"-show_entries format=duration " \
"-of compact=p=0:nk=1 " \
"-v 0"
)
from sgqlc.endpoint.http import HTTPEndpoint
import base64
query = '''
{
creations(limit: 20, offset: 0) {
name
url
}
}
#/bin/bash
#
# Requires:
# - figlet
# - a `:blank:` icon on Slack
#
# Install by calling:
# curl https://gist.githubusercontent.com/sunny/cd7fba906845571fd5f46f1283197bc8/raw/slack-banner.sh > ~/bin/slack-banner
#
# Usage:
@sunny
sunny / git-fetch-and-delete.rb
Created February 1, 2018 15:58
bin/git-fetch-and-delete
#!/usr/bin/env ruby
deleted_branches =
`git fetch --all --tags --prune --dry-run 2>&1 | grep deleted`
.split("\n")
.map { |line| line.split('origin/')[1] }
.select { |branch| system("git rev-parse --verify #{branch} > /dev/null 2>&1") }
deleted_branches.each do |branch|
print "Delete #{branch}? Y/n "

To install this gem, paste this line in your Gemfile:

gem "some-gem-name"

To install this gem, paste these lines in your Gemfile:

# Adds some things to your Rails app
gem "some-gem-name"
# XML Parsing library, required for our RSS feed reader
gem "nokogiri"