Skip to content

Instantly share code, notes, and snippets.

View rmrfself's full-sized avatar
🎯
Focusing

mikezhang rmrfself

🎯
Focusing
View GitHub Profile
@rmrfself
rmrfself / Sublime Text License Key
Last active December 13, 2015 23:08
Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version.
Tags: Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version
Go to menu Help > Enter License.
----- BEGIN LICENSE -----
J2TeaM
2 User License
EA7E-940282
45CB0D8F 09100037 7D1056EB A1DDC1A2
@rmrfself
rmrfself / gist:e14c90f95e8fd85d9d5e
Created May 26, 2015 09:24
Keypoint of ruby metaprogramming.
An object is composed of a bunch of instance variables and a link to a
class.
• The methods of an object live in the object’s class. (From the point of view
of the class, they’re called instance methods.)
• The class itself is just an object of class Class. The name of the class is
just a constant.
• Class is a subclass of Module. A module is basically a package of methods.
In addition to that, a class can also be instantiated (with new) or arranged
in a hierarchy (through its superclass).
• Constants are arranged in a tree similar to a file system, where the names
@rmrfself
rmrfself / gist:3978736
Created October 30, 2012 07:09 — forked from chengdh/gist:3271840
ubuntu + rails3.2 生产环境配置

预置服务器环境

sudo apt-get update
sudo apt-get upgrade

#### note: ran rvm requirements to get package list:
sudo apt-get install curl build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion -y

在服务器上创建用户

@rmrfself
rmrfself / add p3p header
Created September 6, 2012 07:49 — forked from radzikowski/add p3p header
add p3p Header to nginx
add to nginx.conf
add_header P3P 'policyref="/w3c/p3p.xml", CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT", CP="CAO PSA OUR"'
@rmrfself
rmrfself / Document.php
Created August 4, 2012 14:30 — forked from beberlei/Document.php
My Symfony2 File Upload workflow
<?php
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @Entity
*/
class Document
{
@rmrfself
rmrfself / Unique.php
Created June 7, 2012 06:53
@unique annotation support for Symfony 2 Validator with Nette, for more info see: http://docs.symfony-reloaded.org/guides/validator.html
<?php
namespace Symfony\Component\Validator\Constraints;
class Unique extends \Symfony\Component\Validator\Constraint
{
public $message = 'Entity with this property %value% already exists'; # 'Symfony.Validator.Unique.message';
}
@rmrfself
rmrfself / transaction.php
Created May 19, 2012 07:27
How to make transactions in Doctrine 2 using Symfony 2
<?php
// Snippet for Symfony 2 application that uses Doctrine 2 to handle transactions
// It uses the names of the objects/doctrine repositories from the Beta 4 Manual of Symfony 2.
// Get the entity manager
$em = $this->getDoctrine()->getEntityManager();
// suspend auto-commit
$em->getConnection()->beginTransaction();
@rmrfself
rmrfself / gist:1867326
Created February 20, 2012 02:25
Rails mysql reconnect code
ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
def execute_with_retry_once(sql, name = nil)
retried = false
begin
execute_without_retry_once(sql, name)
rescue ActiveRecord::StatementInvalid => exception
ActiveRecord::Base.logger.info "#{exception}, retried? #{retried}"
# Our database connection has gone away, reconnect and retry this method
reconnect!
@rmrfself
rmrfself / ruby-1.9-tips.rb
Created September 15, 2011 10:13 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"