Skip to content

Instantly share code, notes, and snippets.

View phpdave's full-sized avatar

UseTheForceDave phpdave

View GitHub Profile
@phpdave
phpdave / Handling CORS with php.php
Created August 26, 2016 20:54
XMLHttpRequest cannot load https://differentSubDomain.example.com/myPHPScript.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www1.example.com' is therefore not allowed access.
<?php
$subject = $_SERVER['HTTP_ORIGIN'];
$subdomain1 = 'www';
$subdomain2 = 'www1';
$pattern = '/http(s)?:\/\/('.$subdomain1.'\.)?('.$subdomain2.'\.)?(example.com)$/';
$regexResult = preg_match($pattern, $subject);
if($regexResult)
{
header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
--DROP TABLE PHP_DAVE1.MYTABLE;
CREATE OR REPLACE TABLE PHP_DAVE1.MYTABLE
(
NAME VARCHAR(150),
PRIMARY KEY( NAME )
);
INSERT INTO PHP_DAVE1.MYTABLE (NAME) VALUES ('JOE SCHMOE');
SELECT * FROM PHP_DAVE1.MYTABLE;
--Attempting to add journaling so that that NetBeans will not mark the table as read only?
@phpdave
phpdave / JDBCtoLitmisSpaceDb2.sh
Created August 12, 2016 21:36
Trying to make a JDBC connection to a litmis space through an ssh tunnel
#In terminal
ssh -L 23470:localhost:3470 [email protected]
#in JDBC setup using JTOpen driver
jdbc:as400://spaces.litmis.com;proxy server=localhost:23470
#jtopen driver: http://jt400.sourceforge.net/
@phpdave
phpdave / JDBCtoLitmisSpaceDb2.sh
Last active August 21, 2016 20:42
Trying to make a JDBC connection to a litmis space through an ssh tunnel
#In terminal (makes the ssh tunnel from local port 23470 to server port 3470)
My-Machine:~ phpdave$ssh -L 23470:localhost:3470 [email protected]
#::NOTE:: We connect to 3470 because the documentation says "If the Toolbox's Proxy Server feature is selected, and is enabled on the IBM i (iSeries or AS/400), only port 3470 is needed."
#in JDBC setup using JTOpen driver
jdbc:as400://spaces.litmis.com;proxy server=localhost:23470
#jtopen driver: http://jt400.sourceforge.net/
@phpdave
phpdave / JDBCtoLitmisSpaceDb2.sh
Created August 12, 2016 21:36
Trying to make a JDBC connection to a litmis space through an ssh tunnel
#In terminal
ssh -L 23470:localhost:3470 [email protected]
#in JDBC setup using JTOpen driver
jdbc:as400://spaces.litmis.com;proxy server=localhost:23470
#jtopen driver: http://jt400.sourceforge.net/
<?php
$myFloat = (float)0.0;
for($i=0;$i<25000;$i++)
{
$myFloat += 10000.10;
}
var_dump($myFloat); // float(250002499.9999)
//Try the BCMath Arbitrary Precision Mathematics extension
<?php
#get latest ibm_db2 php extension tarbal (can't use wget for https, using curl and ignoring ssl [we don't need this data encrypted])
#and installs it to /usr/local/phpdave7/lib/php/extensions/no-debug-non-zts-20160303/ibm_db2.so
#note depending on how PHP is configured on your system their will be either be a debug build or Zend Thread Safety (ZTS) builds of the extension
#$PREFIX/lib/php/extensions/no-debug-non-zts-API_NO for release builds without ZTS
#$PREFIX/lib/php/extensions/debug-non-zts-API_NO for debug builds without ZTS
#$PREFIX/lib/php/extensions/no-debug-zts-API_NO for release builds with ZTS
#$PREFIX/lib/php/extensions/debug-zts-API_NO for debug builds with ZTS
joe /usr/local/phpdave7/lib/php.ini
@phpdave
phpdave / Get Nginx Source and prerequisite binaries, run configure and make to compile.sh
Created June 25, 2016 23:52
Compile Nginx on IBM i PASE AIX. DISCLAIMER Note: this is currently is a draft and is not meant to be used yet. Many things that I'm looking to clean up and simplify. There may be things that don't work so only do this on a development system that you aren't worried about it being fubar'd
#some things we may need:
wget http://www.oss4aix.org/download/RPMS/zlib/zlib-devel-1.2.8-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv zlib-devel-1.2.8-1.aix5.1.ppc.rpm
#nginx: [emerg] using regex "\.php$" requires PCRE library in /usr/local/nginx/conf/nginx.conf:72
wget http://www.oss4aix.org/download/RPMS/pcre/pcre-8.35-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv pcre-8.35-1.aix5.1.ppc.rpm
wget http://www.oss4aix.org/download/RPMS/pcre/pcre-devel-8.35-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv pcre-devel-8.35-1.aix5.1.ppc.rpm
@phpdave
phpdave / Get Nginx Source and prerequisite binaries, run configure and make to compile.sh
Created June 25, 2016 23:52
DISCLAIMER Note: this is currently is a draft and is not meant to be used yet. Many things that I'm looking to clean up and simplify. There may be things that don't work so only do this on a development system that you aren't worried about it being fubar'd
#some things we may need:
wget http://www.oss4aix.org/download/RPMS/zlib/zlib-devel-1.2.8-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv zlib-devel-1.2.8-1.aix5.1.ppc.rpm
#nginx: [emerg] using regex "\.php$" requires PCRE library in /usr/local/nginx/conf/nginx.conf:72
wget http://www.oss4aix.org/download/RPMS/pcre/pcre-8.35-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv pcre-8.35-1.aix5.1.ppc.rpm
wget http://www.oss4aix.org/download/RPMS/pcre/pcre-devel-8.35-1.aix5.1.ppc.rpm
rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv pcre-devel-8.35-1.aix5.1.ppc.rpm
@phpdave
phpdave / Get the PHP Source and prerequisite binaries, run configure and make to compile.sh
Last active April 17, 2019 01:51
DISCLAIMER Note: this is currently is a draft and is not meant to be used yet. Many things that I'm looking to clean up and simplify. There may be things that don't work so only do this on a development system that you aren't worried about it being fubar'd
#DISCLAIMER: this is currently is a draft and is not meant to be used yet. Many things that I'm looking to clean up and simplify. There may be things that don't work so only do this on a development system that you aren't worried about it being fubar'd
#Download PHP source code and change directories to the downloaded src. This is a dev version of PHP. git.php.net is official. http://www.github.com/php/php-src is mirror
git clone http://git.php.net/repository/php-src.git && cd php-src
#Alternative get a certain branch (version), the default is the master branch which is development
#git clone -b PHP-5.6.7 http://git.php.net/repository/php-src.git
#specific to litmis space not having the includes on a fresh container
#local
scp qopensys-usr-include.tar.gz [email protected]:~