Skip to content

Instantly share code, notes, and snippets.

View AregevDev's full-sized avatar
😀

Alon Regev AregevDev

😀
  • Rehovot, Israel
View GitHub Profile
@AregevDev
AregevDev / lambdas.kt
Last active July 17, 2018 14:50
A cheatsheet about the stdlib lambdas in Kotlin
fun main(args: Array<String>) {
val str = "I am a string"
str.run {
// no lambda params, receiver is value type (String), returns R, the result of the lambda.
}
str.let {
// lambda params are value type (String), no receiver, returns R, the result of the lambda.
}
@AregevDev
AregevDev / order66.rs
Last active February 22, 2019 19:12
A Rust simulation of Star Wars III's order 66 scene
use std::fmt::{Display, Formatter, Result};
use std::sync::{Arc, Mutex};
enum Killer {
AnakinSkywalker,
Clones,
}
impl Display for Killer {
fn fmt(&self, f: &mut Formatter) -> Result {
@AregevDev
AregevDev / Main.cr
Created April 9, 2019 11:19
raylib-cr
@[Link(ldflags: "-L#{__DIR__} -lraylib -lglfw3 -lX11 -lm")]
lib LibRaylib
struct Color
r : UInt8
g : UInt8
b : UInt8
a : UInt8
end
fun InitWindow(width : Int32, height : Int32, title : LibC::Char*) : Void
@AregevDev
AregevDev / serenity.rs
Created April 25, 2019 10:26
Discord bot in Rust WIP
use serenity::model::prelude::{Channel, UserId};
use serenity::utils::Colour;
use serenity::{
framework::{
standard::macros::{check, command, group, help},
standard::{
help_commands, Args, CheckResult, CommandGroup, CommandOptions, CommandResult,
HelpOptions,
},
StandardFramework,
use glium::glutin::{
dpi::LogicalSize, Api, ContextBuilder, Event, EventsLoop, GlRequest, WindowBuilder, WindowEvent,
};
use glium::index::{NoIndices, PrimitiveType};
use glium::texture::RawImage2d;
use glium::{implement_vertex, uniform, Display, DrawParameters, Program, Surface, VertexBuffer};
use image::GenericImageView;
use std::io::Cursor;
use glium::uniforms::{Sampler, MagnifySamplerFilter};
use oauth2::reqwest::http_client;
use oauth2::{basic::BasicClient, AuthUrl, AuthorizationCode, ClientId, ClientSecret, CsrfToken, Scope, TokenUrl, TokenResponse};
use std::io::{BufRead, BufReader, Write};
use std::net::TcpListener;
use url::Url;
use serenity::http::Http;
fn main() {
let client = BasicClient::new(
ClientId::new("544523578855391241".to_string()),
@AregevDev
AregevDev / readfile.c
Created July 17, 2019 18:59
Function for reading files
char *readFile(const char *filepath) {
char *source = NULL;
FILE *fp = fopen(filepath, "r");
if (fp) {
if (fseek(fp, 0L, SEEK_END) == 0) {
long bufsize = ftell(fp);
source = malloc(sizeof(char) * (bufsize + 1));
fseek(fp, 0L, SEEK_SET);
size_t len = fread(source, sizeof(char), bufsize, fp);
#include <math.h>
#include <raylib/raymath.h>
#include <raylib/raylib.h>
int main() {
InitWindow(500, 500, "Hello World");
SetTargetFPS(60);
Vector2 player = {30.0f, 70.0f};
@AregevDev
AregevDev / glbug.cpp
Last active August 20, 2019 19:46
No normal matrix, just output the normals
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <glad/glad.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h>
#define NK_INCLUDE_FIXED_TYPES
@AregevDev
AregevDev / Shader.hpp
Last active November 7, 2019 15:24
Pls review
//
// Created by AregevDev on 11/5/2019.
//
#pragma once
#include <glad/glad.h>
#include <sstream>
#include <fstream>