You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| var gulp = require('gulp'), | |
| concat = require('gulp-concat'), | |
| prefix = require('gulp-autoprefixer'), | |
| sass = require('gulp-sass') | |
| cleancss = require('gulp-clean-css'), | |
| uglify = require('gulp-uglify'), | |
| rename = require('gulp-rename'), | |
| notify = require('gulp-notify'); | |
| var cssDir = 'public/assets/css', |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| def validate_date date | |
| begin | |
| Date.parse(date) | |
| rescue ArgumentError | |
| Date.today | |
| end | |
| end |
| 'Once upon a time in a world far far away'.truncate(20, separator: /\s/) | |
| # "Once upon a time..." |
| <?php | |
| /** | |
| * Kelas untuk memanipulasi data yang berkaitan dengan rupiah. | |
| * | |
| * Catatan: Saya lupa darimana contoh fungsi terbilang awalnya! | |
| * | |
| * @version 0.0.1 | |
| * @author Anggiajuang Patria <[email protected]> | |
| * @copyright (c) 2009-2010 http://www.segellabs.com/ | |
| * @license http://www.gnu.org/licenses/gpl-3.0.txt |
| source 'https://rubygems.org' | |
| # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | |
| gem 'rails', '4.2.6' | |
| # Use sqlite3 as the database for Active Record | |
| gem 'sqlite3' | |
| # Use ActiveModel has_secure_password | |
| # gem 'bcrypt', '~> 3.1.7' |
| config.generators do |g| | |
| g.test_framework :rspec, fixture: true | |
| g.fixture_replacement :factory_girl, dir: 'spec/factories' | |
| g.view_specs false | |
| g.helper_specs false | |
| g.stylesheets = false | |
| g.javascripts = false | |
| g.helper = false | |
| end | |
| config.autoload_paths += %W(\#{config.root}/lib) |
| # This file is copied to spec/ when you run 'rails generate rspec:install' | |
| ENV['RAILS_ENV'] ||= 'test' | |
| require File.expand_path('../../config/environment', __FILE__) | |
| # Prevent database truncation if the environment is production | |
| abort("The Rails environment is running in production mode!") if Rails.env.production? | |
| require 'spec_helper' | |
| require 'rspec/rails' | |
| # Add additional requires below this line. Rails is not loaded until this point! | |
| # Requires supporting ruby files with custom matchers and macros, etc, in |
| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
| package main | |
| import ( | |
| "fmt" | |
| "labix.org/v2/mgo" | |
| "labix.org/v2/mgo/bson" | |
| "time" | |
| ) | |
| type Person struct { |