Skip to content

Instantly share code, notes, and snippets.

@Spriithy
Spriithy / pom.xml
Created April 4, 2019 21:10
Startup pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.spriithy</groupId>
<artifactId>project-name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
@Spriithy
Spriithy / main.c
Created December 12, 2017 21:40
A minimalistic VM in C
#include "tvm.c"
int main(void)
{
int code[] = {
Const,
-5564,
Const,
184841,
Add,
@Spriithy
Spriithy / Lex.hs
Last active August 2, 2017 21:32
Primitive tokenizer in Haskell to learn the language
module Lex (
Token(..),
tokKind,
tokText,
tokPos,
Kind(..),
doLex,
) where
import Data.Char
export default class Client {
constructor() {
this.local = window.location.href.indexOf("file://") > -1 || window.location.href.indexOf("localhost") > -1;
this.twitchKey = this.local ? "miocs45t65k5y2ym8vtfq56lpofbocv" : "74q6uco0vgklzwgehthw3fbyfif54er";
this.racers = [];
this.websocket = null;
this.wsUri = "ws://perso.mog-creations.com:43042/";
{
"workbench.sideBar.location": "right",
"files.associations": {
"*.h": "c",
"*.c": "c"
},
"editor.formatOnSave": true,
"editor.rulers": [
80
],
@Spriithy
Spriithy / perfectsquare.go
Created October 25, 2016 20:56
Find easily if integer N is a perfect square (ie. sqrt(N) is an integer)
func IsPerfectSquare(n int64) bool {
h := n & 0xF; // last hexadecimal "digit"
if h > 9 {
return false
}
// Take advantage of Boolean short-circuit evaluation
if ( h != 2 && h != 3 && h != 5 && h != 6 && h != 7 && h != 8 ) {
t := (int64) (math.Floor(math.Sqrt((float64)(n)) + 0.5 ))
return t * t == n
}
package main
import "fmt"
func main () {
fmt.Println("-= Stack Demo =-")
s := Stack()
s.Push(Int, 0)
s.Push(Int, 1)
s.Push(Int, 2)
@Spriithy
Spriithy / 3n+1.py
Last active August 10, 2016 09:13
Simple calculation program for the 3x+1 problem
import time
it = 0
L = []
i = 1
mi = 0
mv = 1
dt = time.time()
@Spriithy
Spriithy / GUIDFactory.java
Last active December 20, 2017 10:45
A simple GUID generating function
public class GUIDFactory {
private static final String chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final int charsCount = chars.length();
/**
* Generates a random GUID. Example :
*
* <pre>
* 13219ec0-3a81-44c5-a300-de14b7d0235f
* </pre>