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
# Sets CORS headers for request from example1.com and example2.com pages | |
# for both SSL and non-SSL | |
SetEnvIf Origin "^https?://[^/]*(example1|example2)\.com$" ORIGIN=$0 | |
Header set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN | |
Header set Access-Control-Allow-Credentials "true" env=ORIGIN | |
# Always set Vary: Origin when it's possible you may send CORS headers | |
Header merge Vary Origin |
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
<?php | |
/** | |
* I was having trouble with socket connections timing out reliably. Sometimes, | |
* my timeout would be reached. Other times, the connect would fail after three | |
* to six seconds. I finally figured out it had to do with trying to connect to | |
* a routable, non-localhost address. It seems the socket_connect call would | |
* not fail immediately for those connections. This function is what I finally | |
* ended up with that reliably connects to a working server, fails quickly for | |
* a server that has an address/port that is not reachable and will reach the |
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
docker run \ | |
--name={{.Name}} \ | |
{{range $e := .Config.Env}}--env={{printf "%q" $e}} \ | |
{{end}}{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \ | |
{{end}}{{end}}{{range $n, $conf := .NetworkSettings.Networks}}{{with $conf}}--network {{printf "%q" $n}} \ | |
{{range $conf.Aliases}}--network-alias {{printf "%q" .}} {{end}} \ | |
{{end}}{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from={{printf "%q" .}} \ | |
{{end}}{{range $v := .HostConfig.Binds}}--volume={{printf "%q" .}} \ | |
{{end}}{{range $l, $v := .Config.Labels}}--label {{printf "%q" $l}}={{printf "%q" $v}} \ | |
{{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{printf "%q" .}} \ |
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
<?php | |
class Foo { | |
private $bar = "private variable 1"; | |
private $bar2 = "private variable 2"; | |
} | |
$foo = new Foo; | |
echo current($foo)."\n"; |
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
function getWindowMediaWidth() { | |
if(!window.matchMedia){ | |
// it should be this, so return it when we can't | |
// figure it out. Of course, it does not do a lot | |
// of good if the browser does not support media | |
// queries. | |
return document.body.clientWidth; | |
} |
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
#!/usr/bin/lua | |
-- Requires lua 5.1+ and lua socket | |
-- | |
-- Copyright (c) 2015, Brian Moon | |
-- All rights reserved. | |
-- | |
-- Redistribution and use in source and binary forms, with or without | |
-- modification, are permitted provided that the following conditions are met: | |
-- | |
-- * Redistributions of source code must retain the above copyright notice, |
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
$ ./pecl-manager.php -c config-single.ini -w ./pecl-worker-classes -vvv | |
PID Type Message | |
25968 INFO Loading workers in ./pecl-worker-classes | |
25969 PROC Helper forked | |
25969 INFO Loading workers in ./pecl-worker-classes | |
25968 PROC Started with pid 25968 | |
25970 WORKER Adding server 127.0.0.1 | |
25970 WORKER Adding job Avg | |
25970 WORKER Adding job Sum | |
25968 PROC Started child 25970 (Avg,Sum) |
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
<?php | |
/** | |
* Given two timestamps returns the Y-m-d ranges for each week within the range. | |
* | |
* @param int $start_ts Starting timestamp | |
* @param int $end_ts Ending timestamp | |
* @param bool $full_weeks If true, full weeks will be returned meaning | |
* the start and end will be adjusted to create full weeks | |
* @return array |
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
<?php | |
/** | |
* Given two timestamps and a integer, returns the Y-m-d range, separated by days | |
* of that integer | |
* | |
* @param int $start_ts Starting timestamp | |
* @param int $end_ts Ending timestamp | |
* @return array | |
* | |
* @test |
NewerOlder