Skip to content

Instantly share code, notes, and snippets.

View dapi's full-sized avatar
🤝
Open to consulting on agentic developer workflows

Danil Pismenny dapi

🤝
Open to consulting on agentic developer workflows
View GitHub Profile
module CML2
# Includes to ProductCategory model
module ProductCategory
def import node_set
::ProductCategory.delete_all
::ProductCategory.import_categories \
node_set.xpath('/КоммерческаяИнформация/Классификатор/Группы')
end
// Create a simple top to bottom linear gradient with a background-color backup
// The first argument, $color will be output as background-color: $color
//
// This yields a gradient that is 5% brighter on the top and 5% darker on the bottom
//
// +gradient-bg(#777)
//
// This yeilds a gradient where the bright and dark colors are shifted 10% from the original color.
// If you don't specify a third argument it will assign this value for the darkness too, keeping the gradient even.
//
Delayed::Worker.backend = :active_record
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 60
Delayed::Worker.max_attempts = 25
Delayed::Worker.max_run_time = 5.minutes
class Delayed::Worker
alias_method :original_handle_failed_job, :handle_failed_job
protected
require "spec/spec_helper"
class WrongUser
def deliver_message
raise
end
end
class WrongNotifierJob
def perform
# Basic text search with relevancy for MongoDB.
# See http://blog.tty.nl/2010/02/08/simple-ranked-text-search-for-mongodb/
# Copythingie 2010 - Ward Bekker - ward@tty.nl
#create (or empty) a docs collection
doc_col = MongoMapper.connection.db('example_db').collection('docs')
doc_col.remove({})
#add some sample data
doc_col.insert({ "txt" => "it is what it is"})
##formtastic_datepicker_interface
module Formtastic
module DatePicker
protected
def datepicker_input(method, options = {})
format = options[:format] || ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS[:default] || '%d %b %Y'
string_input(method, datepicker_options(format, object.send(method)).merge(options))
end
@parasew
parasew / .gitignore
Created January 25, 2010 12:46
.gitignore file about what to ignore in a new rails app
Capfile
config/deploy.rb
config/database.yml
log/*.log
**/*.spec.log
db/*.sqlite3
db/schema.rb
tmp/cache/*
tmp/pids/*
tmp/sessions/*
@enormego
enormego / EGOCache.h
Created July 6, 2009 13:31
Caching for Objective-C/iPhone -- All new updates will be here: http://github.com/enormego/EGOCache
//
// EGOCache.h
// enormego
//
// Created by Shaun Harrison on 7/4/09.
// Copyright 2009 enormego. All rights reserved.
//
#import <Foundation/Foundation.h>