Skip to content

Instantly share code, notes, and snippets.

View hikari-no-yume's full-sized avatar
🌟
trying to save beautiful things

hikari_no_yume hikari-no-yume

🌟
trying to save beautiful things
View GitHub Profile
//respawn timer here
if (global.respawntimer == 1)
{
if (time <= global.Server_Respawntime)
time += 1
else
instance_destroy();
if (instance_exists(global.myself))
{
if (global.myself.object != -1)
#include <cstdlib>
#include <ctime>
#define DLLEXPORT extern "C" __declspec (dllexport)
DLLEXPORT double get_time()
{
time_t currentTime, zeroTime = {0};
time(&currentTime);
return difftime(currentTime, zeroTime);
}
@hikari-no-yume
hikari-no-yume / curry.js
Last active August 29, 2015 14:01
Tiny function and operator curriers
function curry(func, arity) {
arity = (arity === undefined) ? func.length : arity;
if (arity > 1) {
return function (arg) {
var args = Array.prototype.slice.call(arguments, 0);
return function partial (arg) {
args = args.concat(Array.prototype.slice.call(arguments, 0));
if (args.length < arity) {
return partial;
} else {
@hikari-no-yume
hikari-no-yume / evil.js
Created May 9, 2014 21:30
How to mess with JavaScript programmers
var TotallyNotArray = Object.create(Array.prototype);
TotallyNotArray.constructor = Array;
var EvilArray = function () {
return Object.create(TotallyNotArray);
};
// Now do x = EvilArray(); in Chrome's dev console
// It'll show up like an array, and all operations will work...
// But there's no magic .length property! >:D
@hikari-no-yume
hikari-no-yume / bigint.patch
Last active August 29, 2015 14:02
Work-in-progress Zend bigint patch (zend_language_scanner.c's massive diff removed for the sake of readability)
From bdec0820b6933a64c388b0451c8ae0914e817aa4 Mon Sep 17 00:00:00 2001
From: Andrea Faulds <ajf@ajf.me>
Date: Fri, 6 Jun 2014 02:12:59 +0100
Subject: [PATCH] Working bigints with no tests and some unfixed corner cases
---
Zend/Makefile.am | 2 +-
Zend/Zend.dsp | 4 +
Zend/Zend.m4 | 24 +
Zend/ZendTS.dsp | 4 +
@hikari-no-yume
hikari-no-yume / tests.txt
Created June 9, 2014 23:54
Tests broken by bigints
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Bug #24054 (Assignment operator *= broken) [tests/lang/bug24054.phpt]
Directly modifying an unreferenced array when foreach'ing over it while using &$value syntax. [tests/lang/foreachLoop.013.phpt]
Directly modifying a REFERENCED array when foreach'ing over it. [tests/lang/foreachLoop.014.phpt]
Directly modifying a REFERENCED array when foreach'ing over it while using &$value syntax. [tests/lang/foreachLoop.015.phpt]
Test + operator : 64bit long tests [tests/lang/operators/add_basiclong_64bit.phpt]
Test & operator : 64bit long tests [tests/lang/operators/bitwiseAnd_basiclong_64bit.phpt]
Test ~N operator : 64bit long tests [tests/lang/operators/bitwiseNot_basiclong_64bit.phpt]
@hikari-no-yume
hikari-no-yume / gist:9baa7726cfefc8b21b3e
Last active June 19, 2016 19:22
Unbound, scoped closures, and why they would be useful
<?php
// A closure can be bound ($this will be a specific object), unbound ($this not set) or static ($this cannot be set)
// A closure may be scoped (it can see the private properties of a specific class), or unscoped (no class)
// At present, a closure must be bound or static if it is scoped, and unscoped if it is unbound
// I propose changing this to also allow scoped, unbound closures
// I want to add Closure::call, which lets you call and bind a closure (to avoid creating a new closure for each object you want to bind to)
$foo = function () {
return $this->x;
@hikari-no-yume
hikari-no-yume / gist:9a5ca0eb55a1d7918796
Last active August 29, 2015 14:04
->call versus ->bindTo performance
andreas-air:php-src ajf$ time sapi/cli/php -r '$a = function () { return $this->x; }; class FooBar { private $x = 3; } $foobar = new FooBar; for ($i = 0; $i < 100000; $i++) { $x = $a->bindTo($foobar, "FooBar"); $x(); }'
real 0m0.259s
user 0m0.208s
sys 0m0.012s
andreas-air:php-src ajf$ time sapi/cli/php -r '$a = function () { return $this->x; }; $a = $a->bindTo(NULL, "FooBar", true); class FooBar { private $x = 3; } $foobar = new FooBar; for ($i = 0; $i < 100000; $i++) { $a->call($foobar); }'
real 0m0.100s
user 0m0.094s
@hikari-no-yume
hikari-no-yume / problems_with_C.md
Created August 11, 2014 22:09
Problems with C
  1. Prototypes and headers. Get rid of them.
  2. Integer types. To be fair, it's not really a language problem, rather a compiler/platform issue:
    • char - almost universally 8-bit
    • short - almost universally 16-bit
    • int - supposed to be 16-bit, in practise 32-bit
    • long - supposed to be 32-bit, in practise 64-bit on UNIX-likes on AMD64
    • long long - always 64-bit

I'd make char 8-bit, short 16-bit, int 32-bit and long 64-bit consistently. long int would be removed. char would always be signed. 3. Other stuff I forgot welp

#define ggon_decode
// real/string ggon_decode(string text)
// Decodes a GGON (Gang Garrison Object Notation) text
// Returns either a string or a ds_map handle
var text;
text = argument0;
var tokens;
tokens = ggon_tokenise(text);