Skip to content

Instantly share code, notes, and snippets.

View alfuken's full-sized avatar

Bohdan Schepansky alfuken

View GitHub Profile
@blocknotes
blocknotes / setup.md
Last active February 27, 2024 07:11
ActiveAdmin Trix editor setup (tested with Rails 6.0.3.3)
  • Setup the Rails project with ActiveAdmin using Webpacker: rails g active_admin:install --use_webpacker
  • Setup Trix editor for ActiveAdmin:
    • Execute: bin/rails action_text:install
    • Add Javascript library to app/javascript/packs/active_admin.js:
require("trix")
require("@rails/actiontext")
  • Add style library to app/javascript/stylesheets/active_admin.scss:
@agentcooper
agentcooper / 0.README.md
Last active April 9, 2024 19:27
Telegram chat backup/export

How to use

  1. Login to https://web.telegram.org
  2. Copy-paste contents of telegram-scripts.js into JS console
  3. Run showContacts() to get the list of contacts with ids
  4. Run saveChat(userId) where userId is the id from step 3

Process can take a while, check console for progress. Occasionall FLOOD_WAIT errors are expected. Once done, browser will download the JSON file.

Motivation

@pirj
pirj / Gemfile
Created August 17, 2012 10:13
Sinatra streaming + Redis PubSub
source 'https://rubygems.org'
gem 'sinatra'
gem 'sinatra-contrib', require: 'sinatra/streaming'
group :development do
gem 'thin'
gem 'pry-rails'
end
@jemminger
jemminger / async.rb
Created July 2, 2011 14:25
Make any Ruby method asynchronous
# from http://stackoverflow.com/questions/6499654/is-there-an-asynchronous-logging-library-for-ruby/6527134#6527134
require 'thread'
require 'singleton'
require 'delegate'
require 'monitor'
class Async
include Singleton
@justinxreese
justinxreese / download_pages.rb
Created April 12, 2011 15:44
Limit open threads in ruby
# Pretty simple solution to harness the capability of multithreading without running into problems
# caused by doing too many things at once.
# In this example, I was trying to download hundreds of web pages, but opening all those connections
# simultaneously caused a variety of errors
# Contains download_link(link,save_dir,save_name) to download and save webpages locally (irrelevant)
require 'download_page'
# keep the threads in here