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 _ from "lodash" | |
class TheBrowser { | |
constructor () { | |
this.window = {} | |
this.status = false | |
this.isPhone = false | |
this.isTablet = false | |
this.isMediumTablet = false | |
this.isLargeTablet = false |
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
var tx = 0; | |
var ty = 0; | |
var scale = 1; | |
document.addEventListener('wheel', function (e) { | |
e.preventDefault(); | |
if (e.ctrlKey) { | |
var s = Math.exp(-e.deltaY / 100); | |
scale *= s; | |
console.log("delta = " + e.deltaY); |
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
let node; | |
let rotation = 0; | |
let gestureStartRotation = 0; | |
let gestureStartScale = 0; | |
let scale = 1; | |
let posX = 0; | |
let posY = 0; | |
let startX; | |
let startY; |
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
// SNIPPET | |
{% comment %} | |
Collection template, used on current_collection.liquid and current_collection.image.liquid | |
{% endcomment %} | |
<div class="compare-basket"> | |
<button class="action action--button action--compare"><i class="fa fa-check"></i><span class="action__text">Compare</span></button> | |
</div> | |
{% assign current_collection = collections['model-1'] %} |
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 React, { Component } from "react"; | |
import { BrowserRouter } from "react-router-dom"; | |
import AppStore from "./flux/stores"; | |
import AppDispatcher from "./flux/dispatchers"; | |
import Loader from "./components/loader"; | |
import { componentRoutes, leftNavRoutes, rightNavRoutes } from "./routes"; | |
import { BROWSER } from "./utils/browser"; | |
import "./App.scss"; | |
class App extends Component { |
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
/* | |
Based on: | |
1. http://stephen.io/mediaqueries | |
2. https://css-tricks.com/snippets/css/media-queries-for-standard-devices/ | |
*/ | |
/* iPhone X in portrait & landscape */ | |
@media only screen | |
and (min-device-width : 375px) | |
and (max-device-width : 812px) |
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. Remove duplicates from an array of numbers/strings | |
Well, this is the only one not about map/reduce/filter but it’s so concise that it was hard not to put it in the list. Plus we’ll use it in a couple of examples too. | |
let values = [3, 1, 3, 5, 2, 4, 4, 4]; | |
let uniqueValues = [...new Set(values)]; | |
// uniqueValues is [3, 1, 5, 2, 4] | |
2. A simple search (case-sensitive) | |
The .filter() method creates a new array with all elements that pass the test implemented by the provided function. | |
let users = [ | |
{ id: 11, name: 'Adam', age: 23, group: 'editor' }, | |
{ id: 47, name: 'John', age: 28, group: 'admin' }, |
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
// By @coderitual | |
// https://twitter.com/coderitual/status/1112297299307384833 | |
// Remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)] | |
// Sleep in async functions. Use: await sleep(2000). | |
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
// Type this in your code to break chrome debugger in that line. |
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
first name | last name | age | |
---|---|---|---|
Stephen | Sugden | 31 | |
Tom | Reznik | 29 | |
Justin | Thomas | 30 |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
/** | |
* @title Storage | |
* @dev Store & retrieve value in a variable | |
*/ | |
contract Storage { |
OlderNewer