Skip to content

Instantly share code, notes, and snippets.

View gpr's full-sized avatar

Grégory Romé gpr

View GitHub Profile
@ScottMaclure
ScottMaclure / slack_draft_deleter.js
Last active April 23, 2024 15:49
Slack Draft Deleter
// Remove all drafts from your drafts view
// Navigate to drafts
// F12 to raise dev console
// Paste the below
(async function(x) {
for (let e = document.querySelector('[type="trash"]'); e != null; e = document.querySelector('[type="trash"]')) {
e.click();
await new Promise(resolve => setTimeout(resolve, 500))
document.querySelector('[data-qa="drafts_page_draft_delete_confirm"]').click();
await new Promise(resolve => setTimeout(resolve, 1500))
@gpr
gpr / PolymorphicAssociationWithSimpleForm.md
Last active August 29, 2018 11:47
How to manage polymorphic associations with simple_form and JQuery

Introduction

How to manage polymorphic associations with simple_form and JQuery?

This is a solution.

.
├── app
│   ├── assets
@gpr
gpr / gist:5f08a40d7bb3bd80ba78
Created January 12, 2015 10:50
Generate random bytes with Ruby
# Nothing to require
# You can define your seed or generate one using system random function
seed = srand
prng = Random.new(seed)
# Generate X bytes
X = 16
bin_str = prng.bytes(X)
@bantic
bantic / rails_route_recognizer.rb
Last active September 9, 2022 12:22
Programmatically list all routes (/paths) from within a rails app.
class RouteRecognizer
attr_reader :paths
# To use this inside your app, call:
# `RouteRecognizer.new.initial_path_segments`
# This returns an array, e.g.: ['assets','blog','team','faq','users']
INITIAL_SEGMENT_REGEX = %r{^\/([^\/\(:]+)}
def initialize
@kergoth
kergoth / README.md
Created November 22, 2012 22:05
Quick prototype of a variable filtered bitbake -e

bitbake-env: improved version of bitbake -e

To install

The script may be run from anywhere, as long as 'bitbake' can be found in your PATH.

Suggestion: alias bbe=bitbake-env

@muxcmux
muxcmux / version.rake
Created February 12, 2012 02:53
Manage your rails app version with this rake task
def valid? version
pattern = /^\d+\.\d+\.\d+(\-(dev|beta|rc\d+))?$/
raise "Tried to set invalid version: #{version}".red unless version =~ pattern
end
def correct_version version
ver, flag = version.split '-'
v = ver.split '.'
(0..2).each do |n|
v[n] = v[n].to_i
@gregd
gregd / defaults.list
Created October 22, 2011 11:50
Ubuntu 11.10 RubyMine and rails-footnotes gem
[Default Applications]
x-scheme-handler/txmt=openInMine.desktop
@anithri
anithri / Execute once
Created April 19, 2011 19:11
script and commands to open txmt links in RubyMine on Ubuntu
gconftool-2 -s /desktop/gnome/url-handlers/txmt/command '/usr/local/bin/openInMine "%s"' --type String
gconftool-2 -s /desktop/gnome/url-handlers/txmt/enabled --type Boolean true