Skip to content

Instantly share code, notes, and snippets.

View inem's full-sized avatar
🌰
In progress

Ivan Nemytchenko inem

🌰
In progress
View GitHub Profile
require 'uri'
require 'rexml/document'
require 'net/http'
require_relative 'cloth'
require_relative 'smart_wardrobe'
class MeteoService
CITIES = {'Москва' => '37', 'Рига' => '312', 'ГонКонг' => '256', 'Женева' => '374', 'Вашингтон' => '384', 'Каир' => '334'}
def initialize(url = "https://xml.meteoservice.ru/export/gismeteo/point")
@inem
inem / friendly_urls.markdown
Created June 30, 2018 17:23 — forked from cdmwebs/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

# before (legacy model)
# app/models/user.rb
class User < ActiveRecord::Base
validates :name, length: { maximum: 100 }
validates :lastname, length: { maximum: 100 }
validates :patronymic, length: { maximum: 100 }
before_save :capitalize_name!, :if => :name_process_needed?
private
hightlighter = function(formula){
formula.split(";").forEach(function(part){
elements = part.trim().split(")");
pre_number = elements[0].trim() - 1;
line_numbers = elements[1].trim().split(",");
$.each(line_numbers, function(i, v) {
index = v - 1;
// тулза которая подсвечивает код, оборачивает все в тройной pre, отсюда такая длинная колбаса
$("pre.highlight:eq("+ pre_number +") pre:eq(1) span.line:eq("+ index +")").addClass('emphasis');

Как готовить скринкасты

  1. Выставить минимальное разрешение монитора
  2. Проверить чтобы в сайдбаре файндера не было лишнего
  3. Папки создавать только на английском, сайты в браузере - только на английском
  4. Записывать с помощью QuickTime
  5. Первым делом кликнуть на Desktop, чтобы из менюбара ушел Quicktime
  6. Монтировать в iCloud
    • Разкропнуть
  • Убрать звук
# Pure bash solution to lit, add and remove tags for files in OS X
# Based on https://apple.stackexchange.com/a/119370
# Depends on xattr (https://github.com/xattr/xattr - included in OS X?)
# Alternative: https://github.com/jdberry/tag
# Add the followingꜜ to your .bashrc
#tags <file>
#Lists all tags of a file

The goal of my talk is to make you a more competitive programmer.

How the average programmer thinks? “Ok, I am the programmer, I like to program, and I will program.”

However, programming is just a small part of the software development process.

It all starts with discussing an idea, then the idea turns into a task/issue, then you dig into the details, prioritize and plan, and lastly you'll start drafting your code. When the code is written, it should be tested and reviewed. New version should be tested on Staging,

(1..5).include?(2..3) # => false
require 'active_support/all'
(1..5).include?(2..3) # => true
@inem
inem / get_title_and_url.applescript
Created December 31, 2015 14:57 — forked from vitorgalvao/Get Title and URL.applescript
Applescript to get frontmost tab’s url and title of various browsers.
# Keep in mind that when asking for a `return` after another, only the first one will be output.
# This example is meant as a simple starting point, to show how to get the information in the simplest available way.
# Google Chrome
tell application "Google Chrome" to return URL of active tab of front window
tell application "Google Chrome" to return title of active tab of front window
# Google Chrome Canary
tell application "Google Chrome Canary" to return URL of active tab of front window
tell application "Google Chrome Canary" to return title of active tab of front window
# Chromium