Skip to content

Instantly share code, notes, and snippets.

View tagrudev's full-sized avatar

Todor Grudev tagrudev

View GitHub Profile
1.9.3-p194 :001 > a = [1, 2, 3, 4]
=> [1, 2, 3, 4]
1.9.3-p194 :002 > a.last
=> 4
1.9.3-p194 :003 >
/**
* Mulit-byte Unserialize
*
* UTF-8 will screw up a serialized string
*
* @access private
* @param string
* @return string
*/
function mb_unserialize($string) {
product = Product.new
product.name = "Hello"
product.save!
1.9.3p194 :001 > [1,2,3,4,5,6].in_groups(4,false)
=> [[1, 2], [3, 4], [5], [6]]
@tagrudev
tagrudev / yolo
Last active May 13, 2017 13:51
YOLO practices #RubyOnRails
# Do not refactor, it is a bad practice. YOLO
# Not understanding why or how something works is always good. YOLO
# Do not ever test your code yourself, just ask. YOLO
# No one is going to read your code, at any point don't comment. YOLO
# Why do it the easy way when you can reinvent the wheel? Future-proofing is for pussies. YOLO
Spork.each_run do
require 'factory_girl_rails'
# reload all the models
Dir["#{Rails.root}/app/models/**/*.rb"].each do |model|
load model
end
end
Spork.each_run do
...
# Hack to ensure models get reloaded by Spork - remove as soon as this is fixed in Spork.
# Silence warnings to avoid all the 'warning: already initialized constant' messages that
# appear for constants defined in the models.
silence_warnings do
Dir["#{Rails.root}/app/models/**/*.rb"].each {|f| load f}
end
end
C runs the command self-insert-command, which is an interactive built-in function in `C source code'.
It is bound to many ordinary text characters.
(self-insert-command N)
Insert the character you type.
Whichever character you type to run this command is inserted.
Before insertion, `expand-abbrev' is executed if the inserted character does
not have word syntax and the previous character in the buffer does.
C runs the command self-insert-command, which is an interactive built-in function in `C source code'.
It is bound to many ordinary text characters.
(self-insert-command N)
Insert the character you type.
Whichever character you type to run this command is inserted.
Before insertion, `expand-abbrev' is executed if the inserted character does
not have word syntax and the previous character in the buffer does.
C runs the command self-insert-command, which is an interactive built-in function in `C source code'.
It is bound to many ordinary text characters.
(self-insert-command N)