Skip to content

Instantly share code, notes, and snippets.

View divanvisagie's full-sized avatar
🦀
Rewriting it in Rust

Divan Visagie divanvisagie

🦀
Rewriting it in Rust
View GitHub Profile
def sentimentCounter(list: List[String]): List[Int] = {
list.foldLeft(List[Int](0, 0, 0))((acc, item) => {
item match {
case "Positive" => List(acc.head + 1, acc(1), acc(2))
case "Very positive" => List(acc.head + 2, acc(1), acc(2))
case "Negative" => List(acc.head, acc(1) + 1, acc(2))
case _ => List(acc.head, acc(1), acc(2) + 1)
}
})
}
<link rel="import" href="bower_components/polymer/polymer-element.html">
<link rel="import" href="bower_components/paper-input/paper-textarea.html">
<link rel="import" href="bower_components/iron-ajax/iron-ajax.html">
<dom-module id="sentiment-aware-input">
<template>
<style>
:host {
display: block;
}
@divanvisagie
divanvisagie / README.md
Last active June 11, 2017 08:06
Enable Material Design Youtube
  1. Go to https://www.youtube.com
  2. Open the developer tools
  3. Go to the Application tab and delete the VISITOR_INFO1_LIVE cookie for the YouTube domain
  4. Go to the console and define the VISITOR_INFO1_LIVE cookie using the following command:
document.cookie="VISITOR_INFO1_LIVE=Qa1hUZu3gtk;path=/;domain=.youtube.com";
class Future<A> {
constructor(public promise: Promise<A>) { }
static value<A>(arg: A) {
return new Future(
new Promise<A>(resolve => resolve(arg))
)
}
function findDiff(original, newText) {
function getZip(originalList, newTextList){
return originalList.map(function(char,i) {
return {
first: char,
second: newTextList[i]
}
})
}
sudo: required
dist: trusty
language: node_js
node_js:
- '4.2'
addons:
apt:
sources:
- google-chrome
language: scala
sudo: required
services:
- docker
scala:
- 2.11.7
jdk:
gpg --keyserver pgp.mit.edu --recv-keys 702353E0F7E48EDB
Array.prototype.foldLeft = function(init) {
function f(sum, list, callback) {
if (list.length > 0) {
var head = list.shift();
return f(callback(sum, head), list, callback);
}
return sum;
}
var list = this;
return function(cb) {
@divanvisagie
divanvisagie / implicits.scala
Created April 13, 2016 19:02
Scala implicits explained in 6 lines
def greet(name: String)(implicit greeting: String) : Unit = {
println(s"$greeting $name")
}
greet("Bob")("Hi") //Hi Bob
implicit val greeting = "Hello"
greet("World") //Hello World