Skip to content

Instantly share code, notes, and snippets.

😐
Focusing

Peter Arato itarato

😐
Focusing
Block or report user

Report or block itarato

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@itarato
itarato / dmg_beep.rs
Created Apr 30, 2019
DMG Boot logo beep sound prototype.
View dmg_beep.rs
extern crate sdl2;
use sdl2::audio::{AudioCallback, AudioSpecDesired};
use std::sync::{Arc, Mutex};
use std::time::Duration;
struct SoundPacket {
pitch: f32,
len: Option<usize>,
volume: f32,
@itarato
itarato / serde_json_dig.rs
Created Dec 8, 2018
Serde JSON nest digger
View serde_json_dig.rs
use serde_json::Value;
#[derive(Debug)]
enum Shovel {
Key(&'static str),
Index(usize),
}
fn dig(val: Value, with: &[Shovel]) -> Option<Value> {
if with.len() == 0 {
@itarato
itarato / translation.rb
Last active Nov 28, 2018
Translation finder
View translation.rb
# USAGE: ruby PATH_TO_SCRIPT/translation.rb "TOKEN_TO_TRANSLATE"
require 'yaml'
LANG = 'en'
subject = ARGV[0].split('.')
`find . -name '#{LANG}.yml'`
.lines
.map { |line| YAML.load(IO.read(line.strip))[LANG] }
@itarato
itarato / nqueen.rb
Last active Nov 9, 2018
N-Queen with recursive and non-recursive algorithm
View nqueen.rb
require 'pp'
def run_test
make_board = -> { 8.times.map { [0] * 8 } }
board = make_board.call
return false unless ok?(board)
board = make_board.call
board[0][0] = 1
@itarato
itarato / stacklang.cpp
Created Oct 27, 2018
Stack base interpreter
View stacklang.cpp
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <regex>
#include <unordered_map>
#include <cmath>
using namespace std;
using value_t = double;
View brainfuck_interpreter.hs
import Data.Char
data VM = VM {
mem :: [Int],
ptr :: Int
}
tPlus = '+'
tMinus = '-'
tDot = '.'
@itarato
itarato / discount_code_creation.go
Last active May 11, 2018
Stress test of discount code creation
View discount_code_creation.go
package main
import "gopkg.in/resty.v1"
import "fmt"
import "log"
import "strconv"
import "sync"
func main() {
var wg sync.WaitGroup
@itarato
itarato / look_ahead_lookup_table.rb
Last active May 3, 2018
Look-ahead table generator from non-empty deterministic grammar.
View look_ahead_lookup_table.rb
require 'pp'
class RuleOption
attr_accessor :parts
def initialize(*parts)
@parts = parts
end
end
@itarato
itarato / parse_json.hs
Last active Jan 4, 2018
Functional JSON encoder / decoder.
View parse_json.hs
-- Custom data types
data Value = ValueString String | ValueInt Int | ValueJson Json deriving (Show)
data KeyValuePair = KeyValuePair String Value deriving (Show)
data Json = JsonObject [KeyValuePair] | JsonArray [Value] deriving (Show)
-- Decoder
decode :: String -> Value
decode raw = v
@itarato
itarato / match_search.rb
Last active Dec 22, 2017
Match making model - solution goes into `generate_new_meeting`.
View match_search.rb
## CONSTS #####################################################################
PERSON_NUM = 32
# Number of meeting iterations.
ITERATION = 64
## METHODS ####################################################################
# Generates start-state meetings with the number of iterations
def generate_old_meetings
You can’t perform that action at this time.