Skip to content

Instantly share code, notes, and snippets.

@MaxLevs
MaxLevs / 01a.md
Created May 9, 2024 03:41 — forked from s5bug/01a.md
Advent of Code solved in Hex Casting

Accepts input as a list of UTF-32 codepoints and returns a Number.

High-Level

let isNewline: Number -> Boolean =
  (x: Number) -> x == 10

let isDigit: Number -> Boolean =
  (x: Number) -> (x >= 48) && (x < 58)
@MaxLevs
MaxLevs / 0_initial_brainstorming.md
Created May 9, 2024 03:41 — forked from s5bug/0_initial_brainstorming.md
Hex Casting compiler ideas

Basic Control Flow

Given an arbitrary program:

@main def lcm(a: Int, b: Int): Int =
  if(a < b) (a * (b / gcd(b, a))
  else (b * (a / gcd(a, b))

def gcd(a: Int, b: Int): Int =
  if(b == 0) a
@MaxLevs
MaxLevs / MSBuildCheatSheet.xml
Created March 3, 2024 14:52 — forked from dotMorten/MSBuildCheatSheet.xml
MSBuild Cheat Sheet
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
How to define a variable.
Just stick a new node in a property group.
-->
<PropertyGroup>
<!-- This node in a property group will define a variable -->
<TestVariable>Test Variable Value</TestVariable>
@MaxLevs
MaxLevs / NLog.conf
Created April 7, 2022 22:20
Шаблон конфигурации NLog
<?xml version="1.0" encoding="utf-8" ?>
<nlog
xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true">
<!-- [${callsite}]-->
<variable name="defaultMessageTemplate" value="[${longdate}] [${callsite}] [${uppercase:${level}}] ${message} ${exception:innerFormat=Message,StackTrace}"/>
<targets>
@MaxLevs
MaxLevs / README.md
Created February 27, 2021 14:18 — forked from GusAntoniassi/README.md
Play audio files on your microphone with ffmpeg

play-audio-mic.sh

This script was adapted to allow you to play audio files through your microphone input. It does so by creating a virtual microphone and piping an audio file to it.

The work was mostly done in this StackOverflow answer, I just adapted it to use ffmpeg and add a trap to cleanup on exit.

Requirements:

  • ffmpeg
  • Bash
  • PulseAudio/pactl
@MaxLevs
MaxLevs / client-socket-reconnect.js
Created February 15, 2021 13:36 — forked from sio2boss/client-socket-reconnect.js
Node.js Re-connecting Socket
//
// Simple example of using net.Socket but here we capture the
// right events and attempt to re-establish the connection when
// is is closed either because of an error establishing a
// connection or when the server closes the connection.
//
// Requires
var net = require('net');

Seed Cracking

Part 1: A little explanation about Java Random

  • java.util.Random, An instance of this class is used to generate a stream of pseudorandom numbers. The class uses a 48-bit seed, which is modified using a linear congruential formula. (See Donald Knuth, The Art of Computer Programming, Volume 2, Section 3.2.1.)

  • This class has 6 nifty functions:

    • nextBoolean()
    • nextDouble()
  • nextFloat()

$ wget http://downloads.sourceforge.net/project/glfw/glfw/3.0.1/glfw-3.0.1.zip
$ unzip glfw-3.0.1.zip
$ cd glfw-3.0.1/
$ mkdir build
$ cd build
$ export MACOSX_DEPLOYMENT_TARGET=10.8
$ cmake -D GLFW_NATIVE_API=1 -D CMAKE_OSX_ARCHITECTURES="i386;x86_64" -D BUILD_SHARED_LIBS=ON -D CMAKE_C_COMPILER=clang ../
$ make
$ ls -l src/libglfw*
@MaxLevs
MaxLevs / verify_mc_login.py
Last active January 17, 2019 08:55
Check available for Minecraft account.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
import json
import argparse
from sys import exit
import uuid
client_token = str(uuid.uuid4())
@MaxLevs
MaxLevs / LICENCE SUBLIME TEXT
Created November 23, 2018 07:13
Sublime Text 3 Serial key build is 3176
## Sublime Text 3 Serial key build is 3176
> * Added these lines into /etc/hosts
127.0.0.1 www.sublimetext.com
127.0.0.1 license.sublimehq.com
> * Used the license key
----- BEGIN LICENSE -----