Skip to content

Instantly share code, notes, and snippets.

@cyrilchampier
cyrilchampier / gist:f2f5d0de52c6b73f7ed4
Created January 14, 2015 14:52
previous_changes not cleared on autosave
> m.display_configuration.are_shadows_enabled = true
> m.save
> m.display_configuration.previous_changes
=> {"are_shadows_enabled"=>[false, true] ...
> m.save
> m.display_configuration.previous_changes
=> {"are_shadows_enabled"=>[false, true] ...
> m.display_configuration.save
> m.display_configuration.previous_changes
=> {}
> m.previous_changes
=> {}
> m.display_configuration.previous_changes
=> {}
> m.name = "second name"
> m.display_configuration.are_shadows_enabled = false
> m.save
=> true
> m.previous_changes
=> {"name"=>["truc", "second name"], ...
> m2 = model3d_file.clone
=> #<ModModel3dFile id: 1, uuid: "28b2f60f-c569-4d8b-9783-26661f303433", created_at: "2015-01-14 16:42:48", updated_at: "2015-01-14 16:42:48", file: "98b2e7f0-76ff-4721-90bf-482457343d5b.ZIP", original_filename: "character_blend.ZIP", model3d_id: nil, owner_id: 1, processing_state: "pending", processed_file: "8003773c-4c14-46f4-aeac-30cc5adafd11.ZIP_preproces...">
> m2.model3d
=> nil
> create(:model3d, model3d_file: model3d_file)
=> #<Model3d id: 1, name: "Model3d 1", description: nil, created_at: "2015-01-14 16:43:36", updated_at: "2015-01-14 16:43:36", author: nil, is_temp: false, tags: nil, owner_id: 2, uuid: "fdf3d382-cd9e-41eb-8fc0-758fde80f929", model_url: nil, website_url: nil, is_public: true, category: "characters", review_state: nil>
> m2.model3d
=> #<Model3d id: 1, name: "Model3d 1", description: nil, created_at: "2015-01-14 16:43:36", updated_at: "2015-01-14 16:43:36", author: nil, is_temp: false, tags: nil, owner_id: 2, uuid: "fdf3d382-cd9e-41eb-8fc0-758fde80f929", model
UPDATE users u
SET u.default_model3d_configuration = REPLACE(u.default_model3d_configuration, 'is_fit_to_view_computed: false', 'is_fit_to_view_computed: true')
WHERE EXISTS (
SELECT *
FROM (
SELECT m.owner_id, MAX(m.updated_at) updated_at
FROM model3ds m
GROUP BY m.owner_id
) AS owner_last_model
INNER JOIN model3ds m ON m.owner_id = owner_last_model.owner_id AND m.updated_at = owner_last_model.updated_at
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: [ lambda.amazonaws.com ]
Action: [ 'sts:AssumeRole' ]
#[test]
fn auto_subdirectory_watch() {
let tempdir = TempDir::new("kragle").unwrap();
let path = tempdir.path();
let (tx, rx) = channel();
let mut watcher = watcher(tx.clone(), Duration::from_millis(100)).unwrap();
sleep(Duration::from_millis(100));
watcher.watch(path, RecursiveMode::Recursive).unwrap();
create_dir_all(path.join("sub1").join("sub2")).unwrap();
# frozen_string_literal: true
# disable CSS3 and jQuery animations in test mode for speed, consistency and avoiding timing issues.
# Usage for Rails:
# in config/environments/test.rb
# config.middleware.use Rack::NoAnimations
class Build::Middleware::NoAnimations
def initialize(app)
@app = app
end
# Disable CSS3 and jQuery animations in test mode for speed, consistency and avoiding timing issues.
# Usage for Rails:
# in config/environments/test.rb
# config.middleware.use Rack::NoAnimations
class Build::Middleware::NoAnimations
DISABLE_ANIMATIONS_HTML = <<~HTML
<script type="text/javascript">
if (typeof window.jQuery !== 'undefined') {
window.jQuery(() => {
window.jQuery.support.transition = false;
@cyrilchampier
cyrilchampier / module_nesting_behavior.rb
Created December 18, 2018 13:14
broken code to demonstrate module nesting behavior
module A1
REACHABLE = true
module B1
NESTING = Module.nesting
def self.reachable?
REACHABLE
end
end
end
> MY_CONST = 'truc'
=> "truc"
> MY_CONST.capitalize!
=> "Truc"
> MY_CONST = { a: 1 }
(irb):8: warning: already initialized constant MY_CONST
(irb):6: warning: previous definition of MY_CONST was here
=> {:a=>1}