Skip to content

Instantly share code, notes, and snippets.

View mattdelacdev's full-sized avatar

Matt Delac mattdelacdev

View GitHub Profile
@mattdelacdev
mattdelacdev / Travis: Cheatsheet
Created June 14, 2012 12:11
Travis: Cheatsheet
language: ruby
bundler_args: --without development
before_script: ./bin/ci/before_build.sh
script: "bundle exec rake spec:ci"
env:
- CI=true
rvm:
- 1.8.7
- rbx-19mode
- jruby-19mode
@mattdelacdev
mattdelacdev / Backbone: Cheatsheet
Created July 3, 2012 01:03
Backbone: Cheatsheet
# Backbone
- Models - Store data and trigger cahnge events
`window.Album = Backbone.Model.extend({});`
album = new Album({title: 'Abbey Road', artist: 'The Beatles'})
-- Get an attribute
album.get('title')
-- Set an attribute
album.set({key: value})
-- Model persistent
album.isNew()
pairs = GENGO_CLIENT.getServiceLanguagePairs["response"].select do |pair|
pair["lc_src"] == "en"
end
languages = pairs.map do |pair|
pair["lc_tgt"]
end.uniq
puts languages.inspect
=> ["ar", "de", "es", "es-la", "fr", "fr-ca", "id", "it", "ja", "ko", "nl", "pl", "pt", "pt-br", "ru", "sv", "th", "tr", "vi", "zh", "zh-tw", "tl", "ms"]
## Git
alias gb='git branch'
alias gd='git diff'
alias gdm='git diff master'
alias gl='git log'
alias ga='git add'
alias gco='git checkout'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gba='git branch -a'
class Document < ActiveRecord::Base
after_commit :setup, on: :create
def setup
update foo: :bar if needs_to_update?
end
def needs_to_update
true
end
@mattdelacdev
mattdelacdev / this_global.js
Last active November 15, 2018 15:55 — forked from PavanKu/this_global.js
Global Execution context and value of this.
function go() {
console.log("Simple function call");
console.log(this === window);
}
go(); //prints true on console
console.log(this === window) //Prints true on console.
@mattdelacdev
mattdelacdev / parent.js
Created November 15, 2018 15:58 — forked from PavanKu/parent.js
this inside object method
var person = {
firstName: "John",
lastName : "Doe",
id : 5566,
fullName : function() {
return this.firstName + " " + this.lastName;
}
};
function go(event) {
console.log(event.currentTarget === this);
};
document.querySelector('.block').addEventListener('click', go);
<html>
<head> </head>
<body>
<h1>Math</h1>
<script>
let temperature = 19.7;
temperature = Math.round(temperature);
console.log(temperature);
let morningTemperature = 11;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>SheCodes</title>
<style>
body {
font-family: Cerebri Sans, Helvetica, Arial, sans-serif;