Skip to content

Instantly share code, notes, and snippets.

View MilanGrubnic70's full-sized avatar

Milan Grubnic MilanGrubnic70

View GitHub Profile
@MilanGrubnic70
MilanGrubnic70 / sql_commands.md
Last active June 7, 2023 19:49
SQL Commands

##SELECT

Strings should be in 'single quotes'

Show the population of Germany

SELECT population
FROM world
WHERE name = 'Germany'
@MilanGrubnic70
MilanGrubnic70 / javascript_for_loop.md
Last active January 24, 2023 16:17
JavaScript For Loop

#For Loops

##for A for loop, as mentioned above, is useful for looping with a given number of iterations. Use it when you want to do something x times, such as changing the values in an array or counting the number of vowels in a string.

The common and fundamental syntax for a for loop in JavaScript is as follows:

for (var i = 0; i < n; i++) {
  // block of code
}
@MilanGrubnic70
MilanGrubnic70 / puts_print_p.md
Last active June 13, 2022 19:22
puts vs. print vs. p

#puts vs. print vs. p ###The 'puts' (short for "put string") and 'print' commands are both used to display the results of evaluating Ruby code. ###Both 'puts' and 'print' call the 'to_s' method on the object AND return nil.

###The primary difference between them is that 'puts' adds a newline after executing, and 'print' does not. ###They don't RETURN anything so the RETURN value is nil. ###Using 'p' calls the 'inspect' method on the object.

print "Milan"
Milan => nil

@MilanGrubnic70
MilanGrubnic70 / faker.md
Last active March 21, 2018 21:06
Faker

#Faker

Usage is simple; first grab the gem using your gem program:

$sudo gem install faker

Now you can use it in your favorite ruby program or script. For now let's fire up irb and see what we can fake.

require 'rubygems'  
@MilanGrubnic70
MilanGrubnic70 / sublime_shortcuts.md
Last active July 12, 2017 03:02
Sublime Text shortcuts

#Sublime Text Shortcuts

CTRL-SHIFT-UP/DOWN => multiple cursors
CMD-D => select next occurences
CMD-CTRL-G => select all occurences of a word you can edit
OPT/ALT-ENTER = > find all
CTRL/TAB or CTRL/SHIFT/TAB => toggle tabs

FUNC-DELETE => delete forward

@MilanGrubnic70
MilanGrubnic70 / Snap.txt
Created April 23, 2017 20:34
Snap to Grid
Ctrl + Windows + arrow will snap window into grid positons.
@MilanGrubnic70
MilanGrubnic70 / embedded_Ruby.erb
Last active January 10, 2017 23:52
Embedded Ruby Shortcut Keybinding
// alt + r will get you <% _ %>
// shirt + alt + r will get you <%= _ %>
[
{ "keys": ["alt+r"],
"command": "insert_snippet",
"args": {
"contents": "<% ${1:}$SELECTION %> ${0}"
}
@MilanGrubnic70
MilanGrubnic70 / spec.rb
Created December 24, 2016 00:22
RSpec Refactored
require 'spec_helper'
describe "Static pages" do
let(:base_title) {"Ruby on Rails Tutorial Sample App"}
subject { page }
describe "Home page" do
Terminal shortcuts go in .bashrc in the home directory.
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
@MilanGrubnic70
MilanGrubnic70 / forms_of_functions.js
Last active April 26, 2016 23:14
Functions: Declarative vs. Expression
Two Forms of Functions
// function declaration
function square(x) {
return x * x;
}
// function expression
var square = function(x) {
return x * x;
};