This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LruCacheClassMethod(): | |
def __init__(self, klass, method_name): | |
self.klass = klass | |
self.method_name = method_name | |
self.original_method = getattr(self.klass, self.method_name) | |
def __enter__(self): | |
new_method = functools.lru_cache()(self.original_method) | |
setattr(self.klass, self.method_name, new_method) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"blop_f": 4.2, | |
"blop_i": 42, | |
"blop_fs": "4.2", | |
"blop_is": "42", | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"id":1, "value":"One"}, | |
{"id":2, "value":"Two"}, | |
{"id":3, "value":"Three"}, | |
{"id":4, "value":"Four"}, | |
{"id":5, "value":"Five"}, | |
{"id":6, "value":"Six"}, | |
{"id":7, "value":"Seven"}, | |
{"id":8, "value":"Height"}, | |
{"id":9, "value":"Nine"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"id": 1, | |
"title": "The Shawshank Redemption ", | |
"year": "1998", | |
"votes": 194865, | |
"rating": "7.5", | |
"rank": 1 | |
}, { | |
"id": 2, | |
"title": "The Godfather", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BenchMerge | |
# class CreateAnimals < ActiveRecord::Migration | |
# def change | |
# enable_extension 'hstore' | |
# | |
# | |
# create_table :animals do |t| | |
# t.hstore :data | |
# t.timestamps null: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage : f.input :my_date_field, as: :datepicker, datepicker_options: {dateFormat: 'mm-dd-yy'} | |
# Default dateFormat french : dd/mm/yy | |
class DatepickerInput < ActiveAdmin::Inputs::DatepickerInput | |
def to_html | |
input_wrapping do | |
# New field options inherit from given input_html_options | |
new_input_html_options = input_html_options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"id":1, "value":"A"}, | |
{"id":2, "value":"B"}, | |
{"id":3, "value":"C"} | |
] |