Skip to content

Instantly share code, notes, and snippets.

View somethvictory's full-sized avatar

Someth Victory somethvictory

View GitHub Profile
@somethvictory
somethvictory / index.scss
Last active February 2, 2017 07:28
Sample load module sass. Every page should have a distinguish body id, and css should be place under a specific body id, so that we don't have a style confiction
body[id=companies_index] {
.main-loading {
border-radius: 2px;
color: $main-blue;
height: 260px;
margin-top: 40px;
padding-top: 200px;
}
.main-search {
@somethvictory
somethvictory / initializer.coffee
Created February 2, 2017 07:34
Load all common js related code then load js page by page
IDByMe.Initializer =
exec: (pageName) ->
if pageName && IDByMe[pageName]
IDByMe[pageName]['init']()
currentPage: ->
return '' unless $('body').attr('id')
bodyId = $('body').attr('id').split('-')
action = IDByMe.Util.capitalize(bodyId[1])
@somethvictory
somethvictory / charge.rb
Created February 3, 2017 03:04
Organise your spec by grouping under its own functionality.
require 'rails_helper'
describe Charge, 'validations', type: :model do
it { is_expected.to validate_presence_of(:amount) }
it { is_expected.to validate_presence_of(:customer) }
end
describe Charge, 'delegations', type: :model do
it { is_expected.to delegate_method(:name).to(:customer).with_prefix(true) }
end
@somethvictory
somethvictory / color_scheme_spec.rb
Created February 3, 2017 08:13
Sample feature spec with RSpec Capybara.
feature 'Color Scheme' do
given(:development) { create(:development) }
given(:user) { create(:user, :admin) }
given!(:color_scheme) { create(:color_scheme, development: development, name: FFaker::Name.name, price: 13660)}
given(:other_development){ create(:development) }
given!(:image) { create(:image, development: development) }
before do
login_as(user)
end
@somethvictory
somethvictory / markers.json
Created February 3, 2017 08:19
Sample API design.
{
data: [
{
name: 'Rotati Consulting',
lat: 10.222111,
lng: 144.122322,
stories: [
{
name: 'Story of Rotati',
url: 'markers/2/stories/1'
@UserList = React.createClass
getInitialState: ->
users: @props.users
newPath: @props.new_path
getDefaultProps: ->
users: []
newPath: ''
class UrlList extends React.Component {
constructor(props) {
super(props);
this.state = {
urls: []
}
this.handleUrlCreated = this.handleUrlCreated.bind(this);
}
@somethvictory
somethvictory / url_spec.rb
Created July 28, 2017 04:38
Organise your spec by grouping them under different describe context, associations, validations, callbacks, etc...
require 'rails_helper'
RSpec.describe Url, 'Associations', type: :model do
it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:logs) }
end
RSpec.describe Url, 'Validations', type: :model do
it { is_expected.to validate_presence_of(:original_name) }
it { is_expected.to validate_uniqueness_of(:original_name) }
@somethvictory
somethvictory / server_connection.rb
Created June 12, 2018 14:22
Sample singleton in Ruby
class ServerConnection
include Singleton
def connection
@connection ||= Server.new(
key: ENV['ACCESS_KEY'],
host: ENV['HOST'],
username: ENV['USERNAME']
)
end
@somethvictory
somethvictory / response.json
Last active June 13, 2018 13:57
A sample response from domain searching api
{
"response": {
"status": {
"code": 200,
"message": "OK"
},
"body": {
"type": "domain",
"name": "some-domain.com",
"price": "11.00",