Skip to content

Instantly share code, notes, and snippets.

View edwinlab's full-sized avatar
🐢
run

Edwin edwinlab

🐢
run
View GitHub Profile
@edwinlab
edwinlab / gulpfile.js
Created March 14, 2016 09:15
Simple glupfile.js
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',
@edwinlab
edwinlab / set-value.md
Created April 20, 2016 03:39 — forked from JeffreyWay/set-value.md
PHP: Set value if not exist

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');
@edwinlab
edwinlab / validate.rb
Created July 29, 2016 03:28
Checking string is valid date
def validate_date date
begin
Date.parse(date)
rescue ArgumentError
Date.today
end
end
@edwinlab
edwinlab / truncate.rb
Created August 4, 2016 02:48
Truncate with regex to detection word
'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
@edwinlab
edwinlab / rails http status codes
Created November 6, 2016 14:29 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
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
@edwinlab
edwinlab / mgoExample.go
Created November 28, 2016 14:43 — forked from border/mgoExample.go
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {