Skip to content

Instantly share code, notes, and snippets.

@hopsoft
hopsoft / db.rake
Last active April 3, 2024 13:13
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@kitak
kitak / doc.md
Last active October 18, 2023 09:57
コマンドによる「負荷」の原因切り分け

コマンドによる「負荷」の原因切り分け

この文章では、Linuxコマンド、sar, top, psを使って、一般的に負荷といわれるものの原因を切り分けることを目的とする。

そもそも負荷とは

「複数のタスクによるサーバリソースの奪い合いの結果に生じる待ち時間」を一言で表した言葉。OSのチューニングとは負荷の原因を知り、それを取り除くことにほかならない。

ボトルネックの見極め作業の大まかな流れ

  • ロードアベレージ(処理を実行したくても、実行できなくて待たされているプロセス(CPUの実行権限が与えられるのを待っている、またはディスクI/Oが完了するのを待っている)の数)を見る

2013 年の新卒研修メニュー

Rails Tutorial

目的

  • 2013 年で Web アプリケーションを作る時にモダンな方法で一通り Web アプリケーションを自分一人で作れるようになってもらう
  • 作る過程で Web 開発で必要とされるスキルセットを身につけてもらう

教材と教える項目

@Shinpeim
Shinpeim / 000.md
Last active January 22, 2022 07:31
プロセスとかスレッドとかプロセス間通信とかについて書く場所

重要

サイズがあまりに大きくなってしまったので、gist ではなくて github 上で管理するようにしました。

https://github.com/Shinpeim/process-book

URL 変わっちゃうの申し訳ないんだけど、一覧性が高くなるのと pull req が受け取れるメリットのほうを取ります。せっかく読みにきてくれたのにひと手間かかっちゃってすみません。

この文書の目的

@tiagoa
tiagoa / Backbone.websocket.js
Created October 13, 2012 23:34
Overwrite Backbone.sync method to persist model via WebSocket
// Inspired by https://github.com/logicalparadox/backbone.iobind/blob/master/lib/sync.js
// Overwrite Backbone.sync method
Backbone.sync = function(method, model, options){
// create a connection to the server
var ws = new WebSocket('ws://127.0.0.1:1234');
// send the command in url only if the connection is opened
// command attribute is used in server-side.
ws.onopen = function(){
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@peter
peter / creating-edgerails-app.sh
Created June 30, 2012 21:03
Creating and Deploying an EdgeRails (Rails 4) Application to Heroku
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone https://github.com/rails/rails.git
@tatsuosakurai
tatsuosakurai / gist:1269914
Created October 7, 2011 09:42
9桁の数字を求める
# 1
(rand(900000000)+10 ** 9).to_s
# 2
([(0..9).to_a]*9).map{|i|i.sample}.join
# 3
sprintf("%09d", rand(10 ** 9))
# 4
Array.new(9){ Array(0..9).sample }.join
# 5
9.times.map{rand 10}.join
@kylelemons
kylelemons / gotour-69.go
Created October 7, 2011 01:55
My solution to Go Tour #69 - Web Crawler
package main
import (
"os"
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...