This file contains 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
// 32 bit FNV-1a hash | |
// Ref.: http://isthe.com/chongo/tech/comp/fnv/ | |
function fnv32a( str ) | |
{ | |
var FNV1_32A_INIT = 0x811c9dc5; | |
var hval = FNV1_32A_INIT; | |
for ( var i = 0; i < str.length; ++i ) | |
{ | |
hval ^= str.charCodeAt(i); | |
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24); |
This file contains 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
require_relative '../lib/blend2d.rb' | |
require_relative 'util' | |
include Blend2D | |
if __FILE__ == $PROGRAM_NAME | |
load_blend2d_lib() | |
img = BLImageCore.new | |
r = blImageInitAs(img.pointer, 480, 480, BL_FORMAT_PRGB32) |
This file contains 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
require 'raylib' | |
include Raylib | |
#################################################################################################### | |
class Game | |
attr_reader :high_score, :config, :current_score, :state_timer | |
STATES = [:Ready, :Playing, :GameOver] |
This file contains 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
/* | |
[Usage] | |
$ clang -I`brew --prefix mruby`/include -Iraylib/include raylib_mrb.c `brew --prefix mruby`/lib/libmruby.a raylib/lib/libraylib.a -lm -framework IOKit -framework Cocoa -framework OpenGL -o raylib_mrb | |
$ ./raylib_mrb | |
*/ | |
#include <mruby.h> | |
#include <mruby/class.h> | |
#include <mruby/compile.h> | |
#include <mruby/data.h> | |
#include <mruby/string.h> |
This file contains 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
(defun fnv32a (s) | |
"Calculates FNV-1a 32-bit hash of given string s." | |
(let (hval) | |
(setq hval 2166136261) ; hval = FNV1_32A_INIT | |
(loop for c across s do | |
(setq hval (logxor hval c)) ; hval ^= c | |
(setq hval (* 16777619 hval)) ; hval *= FNV_32_PRIME | |
(setq hval (mod hval 4294967296))) ; hval %= UINT32_MAX | |
hval)) |
This file contains 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
require 'uri' | |
google_link = ARGV[0] | |
encoded_url = /.+url=(.+)&.+/.match(google_link)[1] | |
decoded_url = URI.decode_www_form(encoded_url) | |
puts decoded_url |
This file contains 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
require 'ffi' | |
module UI | |
extend FFI::Library | |
class InitOptions < FFI::Struct | |
layout( | |
:Size, :size_t | |
) | |
end |
This file contains 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
$ curl -L https://github.com/glfw/glfw/releases/download/3.3.2/glfw-3.3.2.zip > glfw-3.3.2.zip | |
$ unzip glfw-3.3.2.zip | |
$ cd glfw-3.3.2/ | |
$ mkdir build | |
$ cd build | |
$ export MACOSX_DEPLOYMENT_TARGET=10.14 | |
$ cmake -D CMAKE_BUILD_TYPE=Release -D GLFW_NATIVE_API=1 -D CMAKE_OSX_ARCHITECTURES="x86_64;arm64" -D BUILD_SHARED_LIBS=ON -D CMAKE_C_COMPILER=clang ../ | |
$ make | |
$ ls -l src/libglfw* |
This file contains 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 sys | |
import re | |
def fnv32a( str ): | |
hval = 0x811c9dc5 | |
fnv_32_prime = 0x01000193 | |
uint32_max = 2 ** 32 | |
for s in str: | |
hval = hval ^ ord(s) | |
hval = (hval * fnv_32_prime) % uint32_max |
This file contains 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
/* -*- encoding: utf-8; -*- */ | |
/* nuklear - v1.17 - public domain */ | |
/* Unicode character test based on: | |
* https://github.com/vurtun/nuklear/blob/master/demo/glfw_opengl3/main.c */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <stdarg.h> |
NewerOlder