Skip to content

Instantly share code, notes, and snippets.

View dapi's full-sized avatar
🌴
Open for offers

Danil Pismenny dapi

🌴
Open for offers
View GitHub Profile
@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>
@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/*
##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
# 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 - [email protected]
#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"})
require "spec/spec_helper"
class WrongUser
def deliver_message
raise
end
end
class WrongNotifierJob
def perform
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
// 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.
//
module CML2
# Includes to ProductCategory model
module ProductCategory
def import node_set
::ProductCategory.delete_all
::ProductCategory.import_categories \
node_set.xpath('/КоммерческаяИнформация/Классификатор/Группы')
end
@itechGroup
itechGroup / bitrix_git.sh
Created April 14, 2011 06:21
Скрипт по установке сайта на bitrix под управление системы контроля версий, включает в себя предыдущие скрипты
if test -z $1
then
echo "$0 : You must set a project name"
exit 1
else
if test -d /srv/sites/$1/www/
then
if test -d /srv/sites/$1/www/bitrix/modules/main/
then
echo 'packing site...'
@slayer
slayer / gist:935641
Created April 21, 2011 22:46
SQL JOIN via AREL in Rails 3
# Simple JOIN
User.joins(:account) # User -> Account
# Will produce
# SELECT `users`.* FROM `users` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id`
# Complicated JOIN
Trait.joins(:user => :account) # Trait -> User -> Account
# Will produce
# SELECT `traits`.* FROM `traits` INNER JOIN `users` ON `users`.`id` = `traits`.`user_id` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id`