Skip to content

Instantly share code, notes, and snippets.

View Monichre's full-sized avatar
🏠
Working from office

Liam Ellis Monichre

🏠
Working from office
View GitHub Profile
@Monichre
Monichre / Multicall.sol
Created March 22, 2022 06:36 — forked from 0xAlcibiades/Multicall.sol
A Pre EIP-1559 MEV/Multicall in pure Yul integrated with ApeBank and with Native GasTokens
// SPDX-License-Identifier: MIT
object "Multicall" {
code {
// Deploy the contract
// Store gas token burn cost in zero slot
sstore(0, 0)
sstore(1, 0)
sstore(2, 0)
datacopy(0x0, dataoffset("MulticallRuntime"), datasize("MulticallRuntime"))
@Monichre
Monichre / contracts...1_Storage.sol
Created January 6, 2022 22:42
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.11+commit.d7f03943.js&optimize=false&runs=200&gist=
// 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 {
@Monichre
Monichre / data.csv
Created May 8, 2020 04:18 — forked from grncdr/data.csv
Demo of importing a CSV file into a Contentful space
first name last name age
Stephen Sugden 31
Tom Reznik 29
Justin Thomas 30
@Monichre
Monichre / oneliners.js
Created April 1, 2019 20:39 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// 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.
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' },
@Monichre
Monichre / mediaqueries.css
Created January 29, 2019 23:03 — forked from needim/mediaqueries.css
Device Specific CSS Media Queries Collection
/*
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)
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 {
// 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'] %}
@Monichre
Monichre / multi-touch.js
Created October 31, 2018 21:36
Multi Touch Event Handling
let node;
let rotation = 0;
let gestureStartRotation = 0;
let gestureStartScale = 0;
let scale = 1;
let posX = 0;
let posY = 0;
let startX;
let startY;
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);