Skip to content

Instantly share code, notes, and snippets.

@migrs
migrs / fw_isb.rb
Created September 25, 2010 01:27
i.softbank.jp のメールをすべて Gmail に移動する
SB_ACCOUNT = ['USERNAME', 'PASSWORD']
GM_ACCOUNT = ['USERNAME', 'PASSWORD']
BOXCAR_ADDR = "123456.123456@push.boxcar.io"
sb.select 'INBOX'
imap_each(sb, %w(UNDELETED)) do |mail, m|
Net::SMTP.start('127.0.0.1', 25) {|smtp| smtp.send_mail mail.attr['BODY[HEADER]'], m[:from], BOXCAR_ADDR}
gm.append 'INBOX', m[:src], nil, m[:date]
sb.store mail.seqno, '+FLAGS', [:Deleted]
end
@dgutov
dgutov / gist:1274520
Created October 10, 2011 02:35
ruby-indent-line advice for closing paren
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
(goto-char (cadr state))
@mgraupner
mgraupner / gist:1859298
Last active September 30, 2015 20:47
MacOS X 10.7.3 and XCode 4.3: Installing Ruby, Gem and Rails
Made an update covering Macos 10.8 and ruby 2.0: https://gist.github.com/michaelsd/5224456
- Install "Command Line Tools for XCode" (Get it from Apple Developer Program) or Install XCode via Appstore
where option one is the faster one, 170MB vs 1.xGB
- Install https://github.com/sstephenson/rbenv
git clone into your home folder;
set environment variables, see install docs of rbenv;
- Get libyaml
@ymorimo
ymorimo / amida.rb
Created June 2, 2012 05:29
#minatork01
#!/usr/bin/env ruby
cols = (ARGV[0] || 5).to_i - 1
rows = (ARGV[1] || 9).to_i
begin
table = (0...rows).map do |i|
(0...cols).map { rand(2) }.join
end
end until table.join =~ /1/
@digitaljhelms
digitaljhelms / gist:4287848
Last active July 19, 2024 03:32
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@brenes
brenes / model_extension.rb
Last active February 14, 2024 11:39
Removing validation of a model declared on a gem
# We have to remove validations on email, as it's no longer needed.
# Based on a solution found at http://stackoverflow.com/questions/7545938/how-to-remove-validation-using-instance-eval-clause-in-rails
Model.class_eval do
_validators.reject!{ |key, _| key == :field }
_validate_callbacks.each do |callback|
callback.raw_filter.attributes.delete :field
end
@ganta
ganta / japanese-patch-for-emacs-24.3.patch
Created March 12, 2013 00:13
Emacs 24.3への日本語環境用のパッチです
diff --git configure.ac configure.ac
index 62f53a3..850eaa4 100644
--- configure.ac
+++ configure.ac
@@ -1571,7 +1571,7 @@ if test "${HAVE_NS}" = yes; then
leimdir="\${ns_appresdir}/leim"
INSTALL_ARCH_INDEP_EXTRA=
fi
- NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
+ NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o"
@hubb
hubb / gem install mysql2 - fail
Last active December 17, 2015 00:19
Tweak mysql_config to properly install mysql2 gem with 10.8 and MySQL installed from dmg (only found solutions for Homebrew)
$ sudo gem install --no-rdoc --no-ri mysql2 --version 0.2.11 -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/hubb/.rbenv/versions/1.9.3-p0/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql-5.6.11-osx10.7-x86_64 --with-mysql-config=/usr/local/mysql-5.6.11-osx10.7-x86_64/bin/mysql_config --with-opt-include=/usr/local/mysql-5.6.11-osx10.7-x86_64/include
checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
@nojimage
nojimage / AppCakeEmail.php
Last active December 17, 2015 20:39
腐ったEmailアドレスに対応するためのCakeEmail Hack.
<?php
App::uses('CakeEmail', 'Network/Email');
class AppCakeEmail extends CakeEmail {
protected $_emailPattern = null;
/**
*
@willurd
willurd / web-servers.md
Last active July 19, 2024 02:15
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000