Skip to content

Instantly share code, notes, and snippets.

View the-teacher's full-sized avatar
💻
Working remotely

Ilya N. Zykin the-teacher

💻
Working remotely
View GitHub Profile
@zealot128
zealot128 / rails-models-to-typescript-schema.rb
Last active July 1, 2024 16:05
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
/***
Copyright (c) 2016, Alexander Choporov aka CoolCmd
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDE
@JoshCheek
JoshCheek / option_parser_example.rb
Created February 8, 2015 09:27
Why I will not use Ruby's OptionParser
# Have to hijack the global environment, b/c that's how invasive it is!
def self.wtf
to_return = {exception: nil, stdout: nil, stderr: nil}
require 'stringio'
$stdout = StringIO.new
$stderr = StringIO.new
to_return[:returned] = yield
rescue Exception
to_return[:exception] = $!
ensure
@alexeisavca
alexeisavca / ReactIgnore
Last active March 12, 2023 12:24
A simple component to make ReactJs ignore subtrees
var React = require('react/addons');
var ReactIgnore = {
displayName: 'ReactIgnore',
shouldComponentUpdate (){
return false;
},
render (){
return React.Children.only(this.props.children);
}
module.exports = (grunt) ->
# Project configuration.
grunt.initConfig
coffee:
options:
sourceMap: false
app:
expand: true
cwd: 'public/js/coffee/'
@renius
renius / select2dropdown.js.coffee
Last active December 12, 2015 07:28
# Convert .bootstrap-select elements to Bootstrap Dropdown Group # Assumes jQuery and Bootstrap scripts already linked
#
# Convert .bootstrap-select elements to Bootstrap Dropdown Group
# Assumes jQuery and Bootstrap scripts already linked
# !!! require jQuery 1.7.2 - 1.8.3
#
# Expected markup:
# <select class="span1" id="car_engine_type" name="car[engine_type]" style="margin-left: 30px">
# <option value="">fuel</option>
# <option value="diesel">diesel</option>
# <option value="gasoline">gasoline</option>