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
// Original Snake Tutorial: Creating a Snake Clone in Rust, with Bevy [0.7.0] | |
// https://mbuffett.com/posts/bevy-snake-tutorial/ | |
use bevy::{prelude::*, time::common_conditions::on_timer, window::PrimaryWindow}; | |
use rand::random; | |
use std::time::Duration; | |
const SNAKE_HEAD_COLOR: Color = Color::srgb(0.7, 0.7, 0.7); | |
const SNAKE_SEGMENT_COLOR: Color = Color::srgb(0.3, 0.3, 0.3); | |
const FOOD_COLOR: Color = Color::srgb(1.0, 0.0, 1.0); |
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
/// Building Zig structs at Compile Time by mht.wtf | |
/// https://mht.wtf/post/comptime-struct/#user-content-fnref-typeinfo | |
/// | |
/// Reading through the blog post originally written on 11 June 2022 with | |
/// Zig version 0.9.1, I got the examples working for 0.14.0 | |
/// | |
const std = @import("std"); | |
const print = std.debug.print; | |
fn Range(comptime T: type) type { |
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
(ns eviscerate-sequence-test | |
(:require [clojure.test :refer [deftest is run-tests]])) | |
(defn eviscerate-sequence | |
([xs n] (eviscerate-sequence xs n n)) | |
([xs n m] | |
(let [v (vec xs)] | |
(concat (subvec v 0 n) (subvec v (inc m)))))) | |
(deftest eviscerate-sequence-test |
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
car name | miles/gallon | cylinders | displacement | horsepower | weight | acceleration | model year | origin | |
---|---|---|---|---|---|---|---|---|---|
chevrolet chevelle malibu | 18 | 8 | 307 | 130 | 3504 | 12 | 70 | 1 | |
buick skylark 320 | 15 | 8 | 350 | 165 | 3693 | 11.5 | 70 | 1 | |
plymouth satellite | 18 | 8 | 318 | 150 | 3436 | 11 | 70 | 1 |
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 http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<title>VueJS</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
</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
import com.google.gson.GsonBuilder | |
import java.security.MessageDigest | |
import java.util.Date | |
// This example is a port of the Java version described by: | |
// https://medium.com/programmers-blockchain/create-simple-blockchain-java-tutorial-from-scratch-6eeed3cb03fa | |
typealias BlockChain = ArrayList<Block> | |
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
class Ship { | |
var name: String = "" | |
var crewSize: Int = 0 | |
var numMasts: Int = 0 | |
override fun toString(): String { | |
return "Ship { Name: $name, Num masts: $numMasts Crew Size: $crewSize}" | |
} | |
} |
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
import java.util.PriorityQueue | |
// node class is the basic structure | |
// of each node present in the huffman - tree. | |
class HuffmanNode : Comparable<HuffmanNode> { | |
var freq = 0 | |
var chr = ' ' | |
var left: HuffmanNode? = null | |
var right: HuffmanNode? = null |
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
/// | |
/// Each car element accepts a visitor. | |
/// | |
trait CarElement { | |
fn accept(&self, visitor: &CarElementVisitor); | |
} | |
/// | |
/// Each visitor must deal with each element of a car. | |
/// | |
trait CarElementVisitor { |
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
// A basic Enum constructor function | |
const Enum = (...values) => { | |
let newEnum = {} | |
for (const value of values) { | |
Object.assign(newEnum, { | |
[value]: value | |
}) | |
} | |
return newEnum | |
} |
NewerOlder