$ ruby treetoar.rb
SELECT "topics".* FROM "topics" WHERE "topics"."id" = 1
Topic.where(id: 1)
SELECT "topics".* FROM "topics" WHERE "topics"."id" IN (1, 2, 3)
Topic.where(id: [1, 2, 3])
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script will migrate schema and data from a SQLite3 database to PostgreSQL. | |
# Schema translation based on http://stackoverflow.com/a/4581921/1303625. | |
# Some column types are not handled (e.g blobs). | |
SQLITE_DB_PATH=$1 | |
PG_DB_NAME=$2 | |
PG_USER_NAME=$3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I got tired of uploading to /tmp then moving to the correct location, so these two convenience methods will save you a lot of time in the long run. | |
# Helper method to upload to /tmp then use sudo to move to correct location. | |
def put_sudo(data, to) | |
filename = File.basename(to) | |
to_directory = File.dirname(to) | |
put data, "/tmp/#{filename}" | |
run "#{sudo} mv /tmp/#{filename} #{to_directory}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XVFB=/usr/bin/Xvfb | |
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset" | |
PIDFILE=/var/run/xvfb.pid | |
case "$1" in | |
start) | |
echo -n "Starting virtual X frame buffer: Xvfb" | |
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS | |
echo "." | |
;; | |
stop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# bash generate random alphanumeric string | |
# | |
# bash generate random 32 character alphanumeric string (upper and lowercase) and | |
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
# bash generate random 32 character alphanumeric string (lowercase only) | |
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1 |
- cucumber-rails
- simple_form - has a 3.0.0.rc but it depends on rails 4.0.0.rc1
- delayed_job_active_record - has a v4.0.0.beta3 so likely ready to release soon
- spork-rails - has no indication of even a beta for rails 4
- authlogic: binarylogic/authlogic#368
- activeadmin/activeadmin#1963
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import datetime | |
from sqlalchemy import create_engine | |
from sqlalchemy import Column, Integer, String, DateTime | |
from sqlalchemy.schema import CheckConstraint | |
from sqlalchemy.orm import validates | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.exc import IntegrityError |
Как вы называете переменную, когда нужно сохранить this
в замыкании?
Вопрос не праздный, ведь это дело даже не личного вкуса, а, скорее, договоренности.
В коде проекта, над которым я сейчас активно работаю, можно было с равной степенью вероятности
встретить that
и self
.
Через два года разработки, впрочем, баланс заметно сместился в сторону that
.
Но знаете, что? И self
, и that
, и даже _this
с me
— это очень хреновые названия.
OlderNewer