Skip to content

Instantly share code, notes, and snippets.

View drakmail's full-sized avatar
🇦🇷
Working

Alex Maslov drakmail

🇦🇷
Working
View GitHub Profile
@drakmail
drakmail / jira.md
Last active November 22, 2023 18:34
Красивое оформление задач в JIRA

Панель для модели

panel-model

{panel:title=НазваниеМодели|titleBGColor=#4A90E2|bgColor=#FAFAFA|titleColor=#FFFFFF}
Тут информация
{panel}
@drakmail
drakmail / .bashrc
Created September 18, 2012 10:10
Nice PS1 for bash
# Check for an interactive session
[ -z "$PS1" ] && return
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
bash_prompt() {
local NONE="\[\033[0m\]" # unsets color to term's fg color
@drakmail
drakmail / example.jsx
Last active April 10, 2019 11:24
Modal Manager
import React, { Component } from 'react'
import { Alert } from '@blueprintjs/core'
import ModalManager from './modalManager'
class Example extends Component {
handle = (modal) => async () => {
const result = await modal.result()
alert(result)
}
@drakmail
drakmail / example.rb
Created December 11, 2015 07:37
Bulk update example in ActiveRecord Rails
new_values = { 10 => "test1", 20 => "test2" }
value = new_values.map { |product_id, value| "(#{product_id}, #{value})" }.join(",")
ActiveRecord::Base.connection.execute(%(
UPDATE products AS p SET value = v.value
FROM (values #{values}) AS v(id, value)
WHERE p.id = v.id
))
@drakmail
drakmail / Rails cheatsheet.textile
Created March 29, 2018 14:09 — forked from ingmarsk/Rails cheatsheet
Rails cheatsheet

rails s (start server)
rails console
rake about (app desc)
rake db:schema:dump (connecto db & export schema)
rake db:migrate:status
rake db:migrate (apply migrations to db)
rake db:migrate VERSION=0 (rollback)
rake db:migrate:(up/down/redo) VERSION=
rake db:seed (populate db with test data from seeds.rb)
rake db:rollback (rollback the migration)

@drakmail
drakmail / drink_habit.rb
Created February 20, 2016 18:34
STI example
class DrinkHabit < Habit
# DB structure
# id:integer
# title:text
# food_amount:integer
# drink_time:datetime
# type: string
end
@drakmail
drakmail / remove_background.sh
Created October 29, 2012 15:52
remove white background with imagemagick
convert "$1" -bordercolor white -border 1x1 \
-alpha set -channel RGBA -fuzz 20% \
-fill none -floodfill +0+0 white \
-shave 1x1 $2
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'parallel_assets_compiler'
s.version = '0.3'
s.platform = Gem::Platform::RUBY
s.author = 'Jørgen Orehøj Erichsen, Alexander Maslov'
s.email = 'joe@erichsen.net, drakmail@gmail.com'
s.summary = 'Compile assets in parallel'
s.description = 'Compile assets in parallel to speed up deployment'
class Handlers
constructor: ->
@handlers = {}
register: (handler, registered_class) ->
@handlers[handler] = registered_class
instantiate: (handlers, element) ->
handlers = handlers.replace(/\s/g, '').split(',')
element.handlers = []
# Sends reminders to issue assignees
# Available options:
# * :days => how many days in the future to remind about (defaults to 7)
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
# * :project => id or identifier of project to process (defaults to all projects)
# * :users => array of user ids who should be reminded
def self.reminders(options={})
days = options[:days] || 7
project = options[:project] ? Project.find(options[:project]) : nil
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil