Skip to content

Instantly share code, notes, and snippets.

@s-mage
s-mage / hash_diff.rb
Last active April 1, 2023 16:19
Update rails translations using openAI. Usage: `OpenAITranslation.call`
class HashDiff
class << self
def t(target)
en = YAML.load_file("config/locales/en.yml")["en"]
target = YAML.load_file("config/locales/#{target}.yml")[target.to_s]
for_translation(en, target)
end
def push(target_language, update)
@s-mage
s-mage / boring-tomorrow.lua
Last active November 5, 2022 12:36
A colorscheme that only highlights things that require attention. https://smagin.fyi/posts/colorscheme/
vim.o.background = "light"
vim.o.termguicolors = true
if vim.g.colors_name then vim.cmd("hi clear") end
vim.cmd("syntax reset")
vim.g.colors_name = "Boring Tomorrow"
-- Default GUI Colours
chromedriver
firefox
iterm2
karabiner-elements
skype
steam
thunderbird
virtualbox
anki
djview
FF = "Firefox"
CHROME = "Google Chrome"
SLACK = "com.tinyspeck.slackmacgap"
GLEAM_GH = /github.com\/Crowd9/
module.exports = {
defaultBrowser: FF,
handlers: [
@s-mage
s-mage / convert.sh
Last active February 14, 2018 15:00
Imagemagick tricks
# change white to transparent
convert old.png -fuzz 20% -transparent white new.png
@s-mage
s-mage / test_vcr_re_record_log
Last active August 30, 2017 11:29
[Log] VCR ignores cached responses after first re-record
# re_record_time: 10.minutes
# Time: 11:57
# VCR records requests first time
$ bundle exec rspec ./spec/features/market/job_offer_spec.rb
Job Offer
to a hourly job
company
VCR GET: https://api.stripe.com/v1/customers/cus_BJ3toXQ39RNwHm
AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
- 'vagrant/**/*'
TargetRubyVersion: 2.3
Lint/EndAlignment:
EnforcedStyleAlignWith: variable
@s-mage
s-mage / prevent_parent_scroll.js
Last active March 16, 2018 20:57
Prevent scrolling of parent element.
jQuery($ =>
$(document).on('wheel', '.scrollable', function(ev) {
let $el = $(this);
let height = $el.outerHeight(true);
let delta = ev.originalEvent.deltaY;
let up = delta < 0;
let prevent = function() {
ev.stopPropagation();
ev.preventDefault();
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '5.1'

Keybase proof

I hereby claim:

  • I am s-mage on github.
  • I am smagin (https://keybase.io/smagin) on keybase.
  • I have a public key whose fingerprint is 349B 7B52 9D18 E43B 1014 45E7 E2C5 C5D9 1549 AC85

To claim this, I am signing this object: