Skip to content

Instantly share code, notes, and snippets.

View camerow's full-sized avatar

Will Cameron camerow

View GitHub Profile
@camerow
camerow / main.dart
Created February 23, 2022 23:16
Precision
void main() {
var p1 = double.tryParse('575000000000000000000');
var p2 = double.tryParse('1.169909130904319607');
var result = p2! / p1!;
print(p1);
print(p2);
print(result);
print(result == 0);
}
@camerow
camerow / add-react-jest-airbnb-linting.sh
Created September 27, 2017 18:31 — forked from rakannimer/add-react-jest-airbnb-linting.sh
Adding react-airbnb styleguide linting to create-react-app
( export PKG=eslint-config-airbnb; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs yarn add -D "$PKG@latest"; )
yarn add babel-eslint
echo "{
\"parser\": \"babel-eslint\",
\"env\": {
\"browser\": true,
\"node\": true,
\"jest\": true,
},
\"extends\": \"airbnb\",
@camerow
camerow / js-observables-binding.md
Created August 10, 2017 20:22 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@camerow
camerow / package.json
Last active February 28, 2017 18:46
Live reloading Polymer apps
// Magic happens on line 12.
{
"name": "first-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
@camerow
camerow / web.config
Last active January 7, 2024 23:25
IIS Redirect to index.html for React-Router compat
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
<rewrite>
<rules>
<rule name="Rewrite to index.html">
@camerow
camerow / MimeToExtension.php
Created October 7, 2016 21:51
PHP Mime Types to Extensions
function getExtension ($mime_type){
$extensions = return array(
'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
@camerow
camerow / profile.ps1
Created October 3, 2016 18:52
Authenticate Powershell to Azure on startup
# Will authenticate you in to Azure
$azureAccountName ="YourAzureUsername"
$azurePassword = ConvertTo-SecureString "YourPassword" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)
Login-AzureRmAccount -Credential $psCred
#Selects the Subscription associated with our team.
Select-AzureRmSubscription -SubscriptionName "Development"
@camerow
camerow / compose.html
Last active August 23, 2016 18:34 — forked from anonymous/index.html
JS BinExample of higher order functions using compose// source http://jsbin.com/hiweso
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Example of higher order functions using compose">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@camerow
camerow / PShellCustom.PNG
Last active August 22, 2016 21:36
Customize PowerShell Color Scheme
PShellCustom.PNG
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">