Skip to content

Instantly share code, notes, and snippets.

@Freika
Freika / givup.md
Last active August 23, 2023 21:57
Ты слишком быстро сдаешься

Деятельность ментора по программированию часто напоминает работу неким life coach'ем. Мотивировать. Давать общие советы по жизни. Как организовывать время. Как решать задачи. Как быть продуктивным. Это всё значительно важней, чем уметь фреймворк X или язык программирования Y. Научись программировать на одном ЯП — и ты найдёшь себе работу "Язык X junior developer". Научись мгновенно изучать любую технологию и разбираться в любом коде и задаче — и ты никогда не останешься без работы и денег.

На днях я искал нового помощника для разработки mkdev.me, выложив в Интернет вот такое описание вакансии: https://gist.github.com/Fodoj/4acb2c9d1f6335de003f028585c3126d

Ключевым пунктом в требованиях там было, пожалуй, следующее: «Трудолюбие, желание учиться, вот это вот всё».

Каждому, кто откликнулся на эту, простите, вакансию я выдал небольшое тестовое задание — починить тесты в open source геме.

Результат меня разочаровал, хоть и был весьма предсказуемым: из десятка людей с «горящими глазами и жадных до знаний» ли

@alexpchin
alexpchin / Ruby_Rails_Naming_Conventions.md
Created May 8, 2014 10:56
Ruby & Rails Naming Conventions

Alex's Rails Cheat Sheet

I think the most confusing thing that I have found about Ruby on Rails so far has been the transition from (trying to) write code myself to the use of the fabled "Rails Magic". So, to help my own understanding of a few core Ruby on Rails concepts, I have decided to write something on what I think is a CRITICAL topic... the idea of Convention over Configuration and why (in my mind) it is the most important thing that helps Rails become magic!

(This may be a topic that we cover in more detail in class but as I said, I'm writing this for my own understanding... I hope it helps someone else understand things too... Perhaps you can give me a hand when I'm crying next week!)

##Convention over configuration ###What does this "actually" mean...

@d3noob
d3noob / index.html
Last active January 24, 2020 07:46
OSMGeocoder plugin for Leaflet.
<!DOCTYPE html>
<html>
<head>
<title>osmGeocoder Search Plugin for Leaflet Map</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
/>
<link
@mattriley
mattriley / post_xml.rb
Created January 25, 2012 22:39
Ruby HTTP POST request containing XML content
require 'net/http'
def post_xml url_string, xml_string
uri = URI.parse url_string
request = Net::HTTP::Post.new uri.path
request.body = xml_string
request.content_type = 'text/xml'
response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
response.body
end
@parkerl
parkerl / legacy_firefox_for_selenium.md
Created January 20, 2012 22:19
Configuring selenium to use a legacy Firefox version in Rails applications.

Motivation

We recently were working on a project where the version of Firefox on the development machines was causing acceptance tests running on Capybara and Selenium to fail and/or hang erroneously. The solution was to point Selenium at a custom version of Firefox. We also added the Firefox binaries to the application git repo so that all devs could run against a known good version of Firefox.

Solution

  1. Download the desired version of Firefox from ftp://ftp.mozilla.org/pub/firefox/releases/

  2. Put Firefox.app in your rails app somewhere like ./bin/spec/macosx/

Transactions

As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.

Basics

All the complexity is handled by ActiveRecord::Transactions. Any model class or instance has a method named .transaction. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.

Example

@neiled
neiled / hamlhtml5boilerplate.html.haml
Created November 25, 2010 23:20
My haml version of the html 5 boiler plate code
!!! 5
/[if lt IE 7] <html lang="en" class="no-js ie6">
/[if IE 7 ] <html lang="en" class="no-js ie7">
/[if IE 8 ] <html lang="en" class="no-js ie8">
/[if IE 9 ] <html lang="en" class="no-js ie9">
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
%head
%meta{:charset => "utf-8"}/
/
Always force latest IE rendering engine (even in intranet) &amp; Chrome Frame