This file contains 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
// credit for this goes to makerofthings7 on stack exchange | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
using System.Net; |
This file contains 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
#define CLOCK_PIN 2 | |
#define LATCH_PIN 3 | |
#define DATA_PIN 4 | |
#define OPEN_LATCH digitalWrite(LATCH_PIN, 0) | |
#define CLOSE_LATCH digitalWrite(LATCH_PIN, 1) | |
byte digits[16]; | |
void setup() { | |
pinMode(LATCH_PIN, OUTPUT); |
This file contains 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
#define CLOCK_PIN 2 | |
#define LATCH_PIN 3 | |
#define DATA_PIN 4 | |
#define READ_PIN 0 | |
#define OPEN_LATCH digitalWrite(LATCH_PIN, 0) | |
#define CLOSE_LATCH digitalWrite(LATCH_PIN, 1) | |
byte digits[16]; | |
void setup() { |
This file contains 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
package com.wausoft.main | |
import scala.collection.mutable.Stack | |
trait ImplicitClasses { | |
implicit class RichStack[A](stack: Stack[A]) { | |
def operate(op: (A, A) => A): Unit = { | |
val (b, a) = (stack.pop, stack.pop) | |
stack push op(a,b) | |
} |
This file contains 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
// it's Seq[_] because we don't really care abou the type, all we're doing is comparing sizes anyway | |
implicit class RichSequence(a: Seq[_]) { | |
def ==(b: Seq[_]): Boolean = a.size == b.size | |
def !=(b: Seq[_]): Boolean = !(a == b) | |
def < (b: Seq[_]): Boolean = a.size < b.size | |
def <=(b: Seq[_]): Boolean = a < b || a == b | |
def > (b: Seq[_]): Boolean = !(a <= b) | |
def >=(b: Seq[_]): Boolean = !(a < b) | |
} |
This file contains 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
// what it tries to solve: | |
var cond = true | |
if(cond) { | |
while(cond) { | |
// do something | |
} | |
} | |
else { | |
// do something else | |
} |
This file contains 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
~ com.wausoft.test = | |
+ _ Program = | |
+ main(args: Array[String]): Unit = // unit is equivalent to void | |
printfn("this is a test") | |
- res = add(2, 4) // type inferred to int | |
printfn("result: $res") // example of string interpolation | |
+ add(a: Int, b: Int): Int = a + b |
This file contains 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
; Scala inspired Lisp | |
; I call it "Stutter" :3 | |
; variable (mutable) definition: | |
(var a 5) | |
; value (immutable) definition: | |
(val b 4) | |
; function definition: |
This file contains 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
#!/bin/bash | |
function setup-sbt() { | |
# make the basic directories | |
mkdir -p "src/main/scala" # change scala to java if that's what you use | |
mkdir -p "src/main/resources" | |
mkdir -p "src/test/scala" | |
# make build file | |
touch build.sbt |
This file contains 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
import java.io.File | |
/** | |
* A completely OS-Agnostic way of dealing with java.io.File paths | |
*/ | |
object RichPath { | |
sealed class RichBase[+A](left: A) { | |
/** | |
* Simple enrichment method designed to let you create a java.io.File | |
* by simply writing "folderA" / "folderB" / "folderC" |
OlderNewer