# Creating a lambda
l = lambda { |name| "Hi #{name}!" }
# Executing the lambda
l.call("foo") # => Hi foo!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isTouchDevice = () => !!('ontouchstart' in window) || !!('msmaxtouchpoints' in window.navigator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
exports.onCreateWebpackConfig = ({ stage, actions }) => { | |
actions.setWebpackConfig({ | |
resolve: { | |
modules: [path.resolve(__dirname, 'src'), 'node_modules'], | |
}, | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assign costants at the top of the file. | |
# Use capital letters for the name, and the #freeze method on the object | |
PHYLA = %w[Ecdysozoa Lophotrochozoa Radiata Deuterostomia].freeze | |
class Animal | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Useful Mixins | |
@mixin shadow($x, $y, $blur, $color) { | |
box-shadow: $x $y $blur $color; | |
} | |
@mixin animate($property: all, $duration: 1s, $easing: ease) { | |
transition: $property $duration $easing; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. null vs. undefined | |
// null is a value, representing "nothing" | |
// undefined means that the variable was never assigned | |
const nullValue = null | |
const undefinedValue = undefined | |
let name // I declare this variable, but I don't assign it | |
console.log(name) // => undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Script to copy Algolia's settings, synonyms and rules from one index to all others in the same application. | |
*/ | |
import algoliasearch from 'algoliasearch' | |
const client = algoliasearch('APP_ID', 'ADMIN_API_KEY') | |
const sourceIndex = client.initIndex('SOURCE_INDEX_NAME') | |
const copySettings = async (source, target) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import algoliasearch from 'algoliasearch' | |
import searchInsights from 'search-insights' | |
import { chunks } from './utils.js' | |
const APP_ID = 'YOUR_APP_ID' | |
const API_KEY = 'YOUR_SEARCH_API_KEY' | |
const INDEX_NAME = 'YOUR_INDEX_NAME' | |
const FACET_NAME = 'categories' // change this value according to your configuration | |
const client = algoliasearch(APP_ID, API_KEY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import algoliasearch from 'algoliasearch' | |
const INDEX_NAME = 'SOURCE_INDEX_NAME' // e.g. 01uat_hmkw_en | |
const QUERY_SUGGESTIONS_INDEX_NAME = 'QUERY_SUGGESTIONS_INDEX_NAME' // e.g. 01uat_hmkw_en_query | |
const NEW_QUERY_SUGGESTIONS_INDEX_NAME = 'NEW_QUERY_SUGGESTIONS_INDEX_NAME' // e.g. 01uat_hmkw_en_query_suggestions | |
const FACET_NAME = 'CATEGORY_FACET_NAME' // e.g. field_category_name.lvl0 | |
const client = algoliasearch('APP_ID', 'API_KEY') | |
const querySuggestionsIndex = client.initIndex(QUERY_SUGGESTIONS_INDEX_NAME) | |
const newQuerySuggestionsIndex = client.initIndex(NEW_QUERY_SUGGESTIONS_INDEX_NAME) |
OlderNewer