Skip to content

Instantly share code, notes, and snippets.

View sgolemon's full-sized avatar
👩‍💻
Pushin' code and fixin' bugs

Sara Golemon sgolemon

👩‍💻
Pushin' code and fixin' bugs
View GitHub Profile
@sgolemon
sgolemon / gist:5279803
Last active December 15, 2015 15:09
Current rough outline of AsyncThread's API. (work in progress) If it works as well as I hope it does, expect a repo with an extension implementing it.
<?php
if (empty($_SESSION['threadName'])) {
$t = new AsyncThread("util/handler.php");
// By setting a name, it becomes persistent and may be resumed later
$t->setName($_SESSION['threadName'] = uniqid());
} else {
// Previously started AsyncThread instance with still-running script
$t = AsyncThread::Resume($_SESSION['threadName']);
@sgolemon
sgolemon / gist:8362044
Created January 10, 2014 20:34
Possible fix for freetype linking
diff --git a/CMake/FindFreetype.cmake b/CMake/FindFreetype.cmake
index 4603d01..3a3d4bf 100644
--- a/CMake/FindFreetype.cmake
+++ b/CMake/FindFreetype.cmake
@@ -1,15 +1,10 @@
-if (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIRS)
- set (Freetype_FIND_QUIETLY TRUE)
-endif (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIRS)
+find_package(PkgConfig)
@sgolemon
sgolemon / gist:8462032
Created January 16, 2014 19:46
array<string>
<?hh
function foo(array<string> $bar) {
echo implode(',', $bar);
}
foo(['a','b','c']);
// Outputs 'a,b,c' as expected.
#include <stdio.h>
void hi(int a, float b) {
printf("a = %d\n", a);
printf("b = %f\n", b);
}
int main(void) {
void (*hello)(float,int) = (void(*)(float,int))hi;
hi(1,2);
http://us2.php.net/session_set_save_handler
"[For all callback functions] Return value is TRUE for success, FALSE for failure."
In ext/session/mod_user.c:
PS_FUNC(user) {
/* blah blah */
zval *retval = ps_call_handler(PSF(func), argc, argc);
if (retval) {
require 'formula'
class Jemallocfb < Formula
homepage 'http://www.canonware.com/jemalloc/download.html'
url 'http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2'
sha1 '40c0892b172e5dc14a6cea6fe4edda7dea4f3a68'
keg_only "We're just a patched version."
# __GLIBC__ is not defined, but we still want hooks!
diff --git a/hphp/parser/hphp.y b/hphp/parser/hphp.y
--- a/hphp/parser/hphp.y
+++ b/hphp/parser/hphp.y
@@ -887,17 +887,8 @@
| class_declaration_statement { $$ = $1;}
| trait_declaration_statement { $$ = $1;}
;
-statement:
+statement_no_if:
@sgolemon
sgolemon / ext_date_php_date.c
Created December 30, 2014 18:14
Allow null for default timezone
/* {{{ proto DateTime date_create_immutable_from_format(string format, string time[, DateTimeZone object])
Returns new DateTime object formatted according to the specified format
*/
PHP_FUNCTION(date_create_immutable_from_format)
{
zval *timezone_object = NULL;
char *time_str = NULL, *format_str = NULL;
size_t time_str_len = 0, format_str_len = 0;
zval datetime_object;
@sgolemon
sgolemon / gist:f23dc4f90725bfedc611
Created January 3, 2015 06:24
HHVM vs PHP Extension APIs
<<__Native>> function foo(int $bar, string $baz): bool;
bool HHVM_FUNCTION(foo, int bar, const String& baz) {
// Do stuff with bar and baz
return true;
}
ZEND_BEGIN_ARG_INFO(foo_arginfo, 0, ZEND_RETURN_VALUE, 2)
ZEND_ARG_INFO(0, bar)
@sgolemon
sgolemon / lambda.php
Created January 10, 2015 01:18
Short Lambda Syntax
<?php
$names = ['Alice', 'Bob'];
// PHP Closures
$greetings = array_map(
function($x) {
return "Hello $x";
}, $names);