Skip to content

Instantly share code, notes, and snippets.

View patriques82's full-sized avatar

Patrik Nygren patriques82

  • Gothenburg
View GitHub Profile
@patriques82
patriques82 / ruby language
Last active July 24, 2019 15:53
A summary of the book "The Ruby Programming Language" by David Flanagana and Yukihiro "Matz" Matsumoto
CONTENT
Expressions, Statements and Controlstructures
Equlaity
Assigments
The ||= idiom
Other assignments
Flip-flops
Iterators
Blocks
Control-flow keywords
@patriques82
patriques82 / Ruby tricks
Last active July 12, 2017 09:59
A list of Ruby tricks from the book "the ruby programming language"
Equality
The equal? method is defined by Object to test whether two values refer to exactly the same
object. For any two distinct objects, this method always returns false:
a = "Ruby" # One reference to one String object
b = c = "Ruby" # Two references to another String object
a.equal?(b) # false: a and b are different objects
b.equal?(c) # true: b and c refer to the same object
By convention, subclasses never override the equal? method. The == operator is the most common
@patriques82
patriques82 / LInux (Debian) Server tasks
Last active December 20, 2015 08:09
LInux (Debian) Server tasks
Linux (Debian) System Tasks:
SSH
$ ssh optimusprime.se
or
$ ssh 31.192.227.207
Add user (with root privileges):
$ sudo useradd -s /bin/bash -m -d /home/<username> -c <username> (add user with bash and homedir)
$ sudo passwd <username> (give password)
@patriques82
patriques82 / Git internals and workflows
Last active December 18, 2015 12:39
Git workflow and a summary of how git works
GIT internals and workflows
Contents
THEORY AND SETUP
Installing and Configuration
Intializing
Object types and References
Remotes
How it works
.gitignore file
@patriques82
patriques82 / Rails project setup
Last active February 13, 2021 15:03
Rails project setup
Content
Installation
RubyGems
Gemsets
Updates
Configuration
Environment
Using .rvmrc file (Best if many projects)
Using different gemsets
Databases
@patriques82
patriques82 / Vim cheat sheet
Last active June 4, 2023 08:04
Vim cheat sheet
Vim commands helpsheet
Contents
My .vimrc commands
Basics
Movement
Search and replacement
Buffers and Windows
Buffers
Windows
@patriques82
patriques82 / Saas solutions-to-homework
Last active December 16, 2015 09:29
Chapter 3 (Ruby)
#Project 4 (this one is credited to https://gist.github.com/tomtung/1973534)
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s
attr_reader attr_name
attr_reader attr_name+"_history"
class_eval %Q{
def #{attr_name}=(value)
if(!defined?(@#{attr_name}_history))
@#{attr_name}_history = [@#{attr_name}]