Skip to content

Instantly share code, notes, and snippets.

View AgtLucas's full-sized avatar
🌎
💀⏳🌷

Lucas AgtLucas

🌎
💀⏳🌷
View GitHub Profile
@AgtLucas
AgtLucas / login.js
Created March 15, 2018 13:39 — forked from kentcdodds/login.js
Example of a test that doesn't use enzyme or TestUtils
import React from 'react'
function Login({onSubmit}) {
return (
<div>
<form
data-test="login-form"
onSubmit={e => {
e.preventDefault()
const {username, password} = e.target.elements
@AgtLucas
AgtLucas / pwnd.js
Created March 2, 2018 18:52 — forked from jgrahamc/pwnd.js
Cloudflare Workers that adds an "Cf-Password-Pwnd" header to a POST request indicating whether the 'password' field appears in Troy Hunt's database of pwned passwords.
addEventListener('fetch', event => {
event.respondWith(fetchAndCheckPassword(event.request))
})
async function fetchAndCheckPassword(req) {
if (req.method == "POST") {
try {
const post = await req.formData();
const pwd = post.get('password')
const enc = new TextEncoder("utf-8").encode(pwd)
@AgtLucas
AgtLucas / patternMatch.hs
Created February 17, 2018 10:13 — forked from animatedlew/patternMatch.hs
Here are some examples of pattern matching in Haskell.
-- Haskell will match starting at the top, until it hits a catchall
factorial :: Int -> Int
factorial 0 = 1
factorial n = n * factorial(n - 1)
-- Haskell is able to match empty lists and x:xs patterns
head' :: [a] -> a
head' [] = error "No head available on empty lists!"
head' (x:_) = x
@AgtLucas
AgtLucas / thinkingInReact.re
Created February 10, 2018 11:15 — forked from broerjuang/thinkingInReact.re
This is the implementation of thinking in react using reason
type product = {
category: string,
price: string,
stocked: bool,
name: string
};
type products = list(product);
let products = [
@AgtLucas
AgtLucas / bsconfig.json
Created January 23, 2018 08:44 — forked from FiberJW/bsconfig.json
Example ReasonReact BuckleScript Configuration
{
"name": "<Your App Name Here />",
"reason": {
"react-jsx": 2
},
"bsc-flags": ["-bs-super-errors"],
"bs-dependencies": ["reason-react"],
"sources": [
{
"dir": "./src",

Basic Algorithm

  1. A secret byte you want to read is stored at inaccessible memory location priv_mem.
  2. The sender triggers an access exception by attempting to access priv_mem.
  3. Due to out-of-order execution, the load of secret and its access in step 4 may happen before the exception fires.
  4. Calculate an offset into a known array probe by multiplying secret by the width of a cache line.
  5. This forces the cache to load probe[offset], caching exactly one chunk of our array.
  6. The exception fires, clearing the modified registers, but cached data is not excised.
  7. Iterate over all 256 offsets into probe to find out which one loads fast. You've determined the value of secret.
@AgtLucas
AgtLucas / array-reduce.js
Created November 15, 2017 21:18 — forked from edysegura/array-reduce.js
[JS] Using reduce to calculate average
var scores = [1, 4, 6, 8];
var result = scores.reduce((total, score) => total + score) / scores.length;
console.log(result); // 4.75
@AgtLucas
AgtLucas / flow-redux.guideline.md
Created November 11, 2017 16:07 — forked from sibelius/flow-redux.guideline.md
How to easily type Redux Props with Flow

How to easily type Redux Props with Flow

Add ExtractReturn helper

// https://hackernoon.com/redux-flow-type-getting-the-maximum-benefit-from-the-fewest-key-strokes-5c006c54ec87
// https://github.com/facebook/flow/issues/4002
// eslint-disable-next-line no-unused-vars
type _ExtractReturn<B, F: (...args: any[]) => B> = B;
export type ExtractReturn = _ExtractReturn&lt;*, F&gt;;
@AgtLucas
AgtLucas / .bashrc
Created October 16, 2017 18:34 — forked from staltz/.bashrc
Put this in your ~/.bashrc (or equivalent) file. Then run `reactnativedev "192.168.1.101:8081"`
# Tweak tap coordinates as you wish
function reactnativedev() {
adb shell input keyevent 82;
sleep 0.1;
adb shell input tap 150 1401;
sleep 0.1;
adb shell input tap 150 1401;
sleep 0.1;
adb shell input text "$1";
sleep 0.1;