Skip to content

Instantly share code, notes, and snippets.

View kalashnikovisme's full-sized avatar
💜
Look at my readme

Pavel Kalashnikov kalashnikovisme

💜
Look at my readme
View GitHub Profile
Factory.define :item do |f|
include ActionDispatch::TestProcess
f.name "Macbook Pro 15"
f.price_in_dollars 1500
f.photo { fixture_file_upload('/files/avatar.jpg', 'image/jpg') }
end
@kalashnikovisme
kalashnikovisme / script.sh
Last active October 27, 2019 11:52
script for my environment on ubuntu 12.04 LTS and 14.04 (testing) LTS #rails #vim #git #postgresql
sudo apt-get update
# ruby and rails
sudo apt-get install htop graphviz git curl build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libreadline-dev libsqlite3-dev libxslt1-dev libgdbm-dev libncurses5-dev automake libtool bison libffi-dev libsqlite3-0 libmysql-ruby libmysqlclient-dev libs$ --yes
curl -L https://get.rvm.io | bash -s stable --rails
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
notify-send "Ruby on Rails" Installed
git clone https://gist.github.com/6722293.git ~/config_files
mv ~/config_files/.pryrc ~/.pryrc
@kalashnikovisme
kalashnikovisme / .bashrc
Last active October 27, 2019 11:52
config files
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@kalashnikovisme
kalashnikovisme / gist:7852903
Created December 8, 2013 03:06
Export DataGridView to Excel. You must have "export.xlt" file in project directory.
public void ExportToExcel(DataGridView grid) {
ApplicationClass Excel = new ApplicationClass();
XlReferenceStyle RefStyle = Excel.ReferenceStyle;
Excel.Visible = true;
Workbook wb = null;
String TemplatePath = System.Windows.Forms.Application.StartupPath + @"\export.xlt";
try {
wb = Excel.Workbooks.Add(TemplatePath); // !!!
} catch (System.Exception ex) {
throw new Exception("Template is unavailable " + TemplatePath + "\n" + ex.Message);
@kalashnikovisme
kalashnikovisme / youtube_embed_auto_size.coffee
Created May 16, 2016 18:34
Youtube embed auto size (Coffeescript, jQuery)
parent_div_width = $('.youtube_embed').parents('div').first().width()
$youtube_embed = $('.youtube_embed iframe')
$youtube_embed.prop('width', "#{parent_div_width}px")
$youtube_embed.prop('height', "#{parent_div_width / 16 * 9}px")
@kalashnikovisme
kalashnikovisme / resolution.sh
Last active May 25, 2016 17:19
ubuntu set screen resolution
cvt 1440 900 60
xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
xrandr --addmode VGA1 1440x900_60.00
---
- hosts: all
vars:
name: "Your name"
email: "your_email"
tasks:
- command: git config --global user.email "{{ email }}"
- command: git config --global user.name "{{ name }}"
- apt: name={{ item }}
sudo: True
@kalashnikovisme
kalashnikovisme / Ruby List.md
Last active November 1, 2017 14:01 — forked from evtuhovich/gist:1134998
Список вопросов для собеседования

Общие вопросы

  • динамическая и статическая типизация
  • строгая и нестрогая типизация
  • компилируемые и интерпретируемые языки

Ruby

  • принципиальное различие скриптовых и “обычных” языков
  • типизация в Ruby
  • 3 принципа ООП
  • реализация множественного наследования в ruby
  • duck typing
@kalashnikovisme
kalashnikovisme / aasm.readme example.rb
Created February 4, 2021 00:57
Medium. Get list of state machines names provided by gem `aasm` article
class SimpleMultipleExample
include AASM
aasm(:move, column: 'move_state') do
state :standing, initial: true
state :walking
state :running
event :walk do
transitions from: :standing, to: :walking
end
@kalashnikovisme
kalashnikovisme / script.rb
Last active February 12, 2021 02:29
Fix "json" exported from errbit
file = File.open("errors.json").read
lines = []
file.each_line do |line|
line.gsub!(/ObjectId\({1}(.)/, '\1').sub!(/()*\)/, '\1') if line.include? 'ObjectId'
line.gsub!(/ISODate\({1}(.)/, '\1').sub!(/()*\)/, '\1') if line.include? 'ISODate'
lines.push line
end
puts lines