Skip to content

Instantly share code, notes, and snippets.

@djackson1
djackson1 / README.md
Last active January 18, 2016 15:19
Javascript to disable overscroll on body (iPad) but keep on content

Known bugs

On iPad, if you scroll on the right hand side (Where the scrollbar would be) it doesn't prevent overscroll.

Hex2RGB

A little function that I thought would be useful to create a tuple of rgb percentages from a hex string. The original function was contained within a file of many special functions (which is why you must specify hex2rgb as the first param, this will be changed in a future release)

Usage

Call the function with a parameter of hex2rgb and a second of a hex string 0xf93819.
It will display variable outputs that may be useful:

  • Invdidual decimal numbers e.g. a hex of e2 will output 226
  • Percentages of the hex e.g. a hex of e2 will output .88
  • A tuple of the percentages {.88, .32, .12}

OCaml nub a list

This is a function that is called to remove all preceding elements in an array in OCaml

To run call nub2 [1;4;2;3;1;2;1;1;4;2];; and you should receieve int list = [1; 4; 2; 3] - all repeated elements are removed

Both players pick a number, if it's the same no one wins, if it's an even number P1 wins and if it's odd P2 wins.
Given a set of numbers {1,2,3} P2 is always more likely to win the more games they play
All of the events are just as likely to happen (if they choose randomly)
{1,1} = Same number = No one wins
{1,2} = 3 = Odd = P2
{1,3} = 4 = Even = P1
{2,1} = 3 = = P2
@djackson1
djackson1 / corrupted-patterns-fixed.txt
Created March 21, 2017 15:48
Fixed corrupted patterns
[1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1]
[1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1]
[1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -
const day03_a = input => {
// NOTE: Doesn't work for actual square numbers, too lazy to fix, deal with it
// n = the square root of the nearest square number below it
// m = the square root of the nearest square number above it
const n = roundDownToNearestOddNumber(Math.sqrt(input))
const n2 = n * n
// amount of steps to reach the nth corner [not the mth]
const steps_for_n = (n + 1) / 2
@djackson1
djackson1 / app.js
Last active January 6, 2018 00:28
First react stuff ehhh
class Item extends React.Component {
constructor(props){
super(props);
this.state = {
name: props.name,
count: props.count
}
}