Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / rails-models-to-typescript-schema.rb
Last active February 18, 2024 12:11
Simple ruby script to generate Active Record Typescript information with enums + associations
# USAGE:
# rails runner rails-models-to-typescript-schema.rb > app/javascript/types/schema.d.ts
Rails.application.eager_load!
models = ActiveRecord::Base.descendants.reject { |i| i.abstract_class? }
belongs_to = true
has_many = true
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers

Various search databases and backends as alternatives to Elasticsearch.

Rust

@castwide
castwide / rails.rb
Last active April 7, 2024 22:10
Enhance Rails Intellisense in Solargraph
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!parse
# class ActionController::Base
@bazzel
bazzel / README.md
Last active March 20, 2022 22:00
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@mmalek-sa
mmalek-sa / string_enums.rb
Created August 16, 2018 20:45
String enums are useful when you want to keep the actual string instead of integer in database, This gist add the validation to make sure users are passing correct values to model.
require 'active_support/concern'
module StringEnums
extend ActiveSupport::Concern
class_methods do
def string_enum(enums_hash)
enum_name = enums_hash.keys.first.to_s
define_singleton_method(enum_name.pluralize) do
@florentbr
florentbr / #wd-drop-file.py
Last active April 7, 2024 02:56
Selenium - Drop a file from the desktop on a drop area
from selenium import webdriver
from selenium.webdriver.remote.webelement import WebElement
import os.path
# JavaScript: HTML5 File drop
# source : https://gist.github.com/florentbr/0eff8b785e85e93ecc3ce500169bd676
# param1 WebElement : Drop area element
# param2 Double : Optional - Drop offset x relative to the top/left corner of the drop area. Center if 0.
# param3 Double : Optional - Drop offset y relative to the top/left corner of the drop area. Center if 0.
# return WebElement : File input
@danharper
danharper / normalize-filenames.js
Last active August 17, 2018 19:32 — forked from dcramer/normalize-filenames.js
use Sentry (Raven) on PhoneGap
Raven.config(dsn, {
dataCallback(data) {
const normalize = filename => filename.split('/www/', 2)[1]
data.exception.values[0].stacktrace.frames.forEach(frame => {
frame.filename = normalize(frame.filename)
})
data.culprit = data.exception.values[0].stacktrace.frames[0].filename
@jasonswearingen
jasonswearingen / redux-simple-router-example.tsx
Last active October 31, 2017 19:37
A simplified example of redux + redux-simple-router using Typescript
/**
WHAT: A very simple example of redux + redux-simple-router using Typescript.
WHY: The official example found here: https://github.com/rackt/redux-simple-router/tree/1.0.2/examples/basic has problems:
1) it is spread over many files making it very hard to "skim"
2) it is organized by function, not by feature. (Example: learning "how to manipulate redux state" is spread over 5 files in 4 folders)
3) there are no comments explaining what's going on/why.
WHO: by JasonS@Novaleaf.com