This file contains hidden or 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
" Install Plug for plugin support | |
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
" Don't try to be vi compatible | |
set nocompatible | |
" Helps force plugins to load correctly when it is turned back on below | |
filetype off | |
" Auto reload file when changed by linter |
This file contains hidden or 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
const {min, max} = require('underscore') | |
const first = (arr) => arr[0] | |
const last = (arr) => arr[arr.length - 1] | |
const almostZero = (a) => (a > -0.000001 && a < 0.000001) | |
const almostEqual = (a, b) => almostZero(Math.abs(a) - Math.abs(b)) | |
const population = [ | |
{ objectives: [0.1, 0.2, 0.3] }, | |
{ objectives: [0.2, 0.4, 0.6] }, | |
{ objectives: [0.1, 0.05, 0.3] } | |
] |
This file contains hidden or 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
def calculate_crowding_distance(pop) | |
pop.each {|p| p[:dist] = 0.0} | |
num_obs = pop.first[:objectives].size | |
num_obs.times do |i| | |
min = pop.min{|x,y| x[:objectives][i]<=>y[:objectives][i]} | |
max = pop.max{|x,y| x[:objectives][i]<=>y[:objectives][i]} | |
rge = max[:objectives][i] - min[:objectives][i] | |
pop.first[:dist], pop.last[:dist] = 1.0/0.0, 1.0/0.0 | |
next if rge == 0.0 | |
(1...(pop.size-1)).each do |j| |
This file contains hidden or 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
exports.handler = (event, context, callback) => { | |
var data = { | |
headers: event.headers, | |
path: event.resourcePath, | |
queryParams: event.queryStringParameters, | |
pathParams: event.pathParameters, | |
bodyParams: event.body, | |
method: event.httpMethod | |
} | |
var response = { |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://fb.me/react-with-addons-15.1.0.js"></script> | |
<script src="https://fb.me/react-dom-15.1.0.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-redux/4.4.5/react-redux.min.js"></script> |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script> | |
</head> | |
<body> |
This file contains hidden or 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
'use strict'; | |
console.log('Loading function'); | |
let doc = require('dynamodb-doc'); | |
let dynamo = new doc.DynamoDB(); | |
/** | |
* Provide an event that contains the following keys: | |
* | |
* - operation: one of the operations in the switch statement below |
This file contains hidden or 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
# Add it to /etc/environment | |
LC_ALL="en_US.UTF-8" | |
# or execute it to the console | |
export LC_ALL="en_US.UTF-8" |
This file contains hidden or 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
if (jslogger) { | |
if(!window.console) window.console = {}; | |
var methods = ["log", "debug", "warn", "info"]; | |
for(var i=0;i<methods.length;i++){ | |
console[methods[i]] = function(){jslogger.log.apply(jslogger, arguments);}; | |
} | |
} |
This file contains hidden or 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
// Format JSON function | |
// http://ketanjetty.com/coldfusion/javascript/format-json/ | |
var formatJson = function (val) { | |
var retval = ''; | |
var str = val; | |
var pos = 0; | |
var strLen = str.length; | |
var indentStr = ' '; | |
var newLine = '<br />'; |
NewerOlder