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
#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) {
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:0e1ea13a16d21098e73f
Last active August 29, 2015 14:23
Questionable use of GitHub APIs

Over-reacted to second hand info and misinterpreted docs.

I do think OAuth providers (like Github, Twitter, Facebook, etc...) should do more to discourage apps from requesting write access. It PARTICULARLY disturbs me that admin:public_key is even an option in Github's Scopes. So the potential for disasterous outcomes certainly exists when granting access to apps via Github's OAuth system, but provided that you carefully read what you're granting access to, it's not necessarily as bad a my original post (left intact below) made it out.


During a twitter conversation[1] this morning, I discovered that in order for an application to get something as simple as your name during a single-sign on, it has to ask for full user profile information. That's a bit scary by itself, but when asking for full profile information, it also has to ask for read and WRITE permissions.[2]

Yes, in order to use single-signon to a 3rd party site, I have to give that site the rights to modify my email addr

@sgolemon
sgolemon / graft-if.phpt
Created October 16, 2015 11:56
My AstKit experimental branch. This is runkit levels of bad...
--TEST--
Graft new value onto a statement list
--FILE--
<?php
include('astkit-test.inc');
$if = AstKit::parseString(<<<EOD
if (true) {
echo "This is a triumph.\n";
} else {
@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.
@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)