Skip to content

Instantly share code, notes, and snippets.

View VadimBrodsky's full-sized avatar

Vadim Brodsky VadimBrodsky

View GitHub Profile
@VadimBrodsky
VadimBrodsky / ES2015.md
Last active September 24, 2016 18:33
ES6 - FrontEnd Masters Notes
@VadimBrodsky
VadimBrodsky / app.js
Last active August 10, 2016 18:05
Sample JS library for greetings, as part of the Udemy JS Understand the weird parts course
var g = G$('John', 'Snow');
// console.log(g);
// g.greet().setLang('es').greet(true).log();
$('#login').click(function () {
var lang = $('#lang').val();
g.setLang(lang).HTMLGreeting('#greeting', true).log();
});
@VadimBrodsky
VadimBrodsky / curry-es5.js
Last active August 4, 2016 19:37
Implementing the Curry function in JavaScript for arbitrary number of arguments
function curry(func) {
var slice = Array.prototype.slice,
args = slice.call(arguments, 1);
return function () {
return func.apply(
null,
args.concat(slice.call(arguments, 0))
);
};
}

Rails Naming Conventions

Ruby

  • Name variables and classes using short phrases.
  • Variable names have all letters lowercase separated by underscores (snakecase): this_is_an_example
  • Classes and modules capitalize each word in the phrase (mixed case): ThisIsAnExample

Rails Assumes

  • Database table names and variable names use snake case.
  • Table names are always plural: orders, thid_parties
@VadimBrodsky
VadimBrodsky / .htaccess
Created April 28, 2016 15:40 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
# update
sudo apt-get update
# install apache
sudo apt-get install -y apache2
# install mysql and php-mysql
sudo apt-get install mysql-server php5-mysql
# install mysql and init
@VadimBrodsky
VadimBrodsky / IRR.js
Created February 3, 2016 20:15 — forked from ghalimi/IRR.js
IRR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@VadimBrodsky
VadimBrodsky / Structure Top Level.md
Last active December 22, 2015 21:07
Craft Snippets

Source -- http://craftcms.stackexchange.com/a/6996

Untested, but you should be able to do this by using the [merge filter in Twig][1] to join the two results together.

Get the top level 'landing page' for this section:

{% set landingPage = entry.getAncestors().level(1) %}
@VadimBrodsky
VadimBrodsky / friendly_urls.markdown
Created December 16, 2015 03:20 — forked from cdmwebs/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.