Skip to content

Instantly share code, notes, and snippets.

@agbishara
agbishara / geohopper.php
Created September 18, 2015 14:17
Geohopper ifttt.com php tie in - Maker Channel
<?php
$key="enter your key";
function run($command,$key) {
$ch = curl_init();
$timeout = 5;
$url='http://maker.ifttt.com/trigger/'.$command.'/with/key/'.$key;
//echo $url;
curl_setopt($ch, CURLOPT_URL,$url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
@agbishara
agbishara / Excel Range Concatenate
Created February 15, 2015 14:37
Excel - Concatenate over a range
Option Explicit
Public Function JoinText(cells As Variant,Optional delim_str As String) As String
If cells.Columns.count < cells.Rows.count Then
JoinText = Join(WorksheetFunction.Transpose(cells), delim_str)
Else
JoinText = Join(WorksheetFunction.Transpose(WorksheetFunction.Transpose(cells)), delim_str)
End If
End Function
@agbishara
agbishara / disable magic quotes
Created February 15, 2015 14:28
disable magic quotes PHP 5.4 +
create a .user.ini file at your Joomla! root.
Add this content to the file and save
magic_quotes_gpc = Off
src = https://docs.joomla.org/How_to_turn_off_magic_quotes_gpc_for_Joomla_3
http://jsperf.com/asdffafaal/2
// Define a class like this
function Person(name, gender){
// Add object properties like this
this.name = name;
this.gender = gender;
}
@agbishara
agbishara / Generate XLS from mysql query and download.php
Last active August 29, 2015 14:01
query mysql and grab excel then download
<?php
/*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
@agbishara
agbishara / Generate CSV from mysql and email out.php
Last active May 7, 2024 12:05
Generate CSV from mysql and email out
<?php
//src: http://stackoverflow.com/questions/10334753/how-to-send-an-email-with-a-csv-attachment-from-a-string
//mysql user variables
$mysqli = new mysqli("localhost", "user", "password", "database");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
@agbishara
agbishara / gist:11215922
Created April 23, 2014 13:51
Allow Joomla 3 to install with magic quotes setup on the server, add the following to htaccess
#joomla 3 magic quotes fix
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
@agbishara
agbishara / VBA - Create workbook at Path
Created April 15, 2014 16:06
Create a workbook at a path
Function CreateWorkbook(Path As String) As Workbook
Dim Tempbook As Workbook
Set Tempbook = Workbooks.Add(ThisWorkbook.Path & "\template.xlsx")
Application.DisplayAlerts = False
Tempbook.SaveAs Filename:=Path
Application.DisplayAlerts = True
Set CreateWorkbook = Tempbook
End Function
@agbishara
agbishara / VBA - Save workbook without prompt
Created April 15, 2014 16:04
If your producing a set of workbooks, this hides the save prompt
Application.DisplayAlerts = False
Tempbook.Save
Application.DisplayAlerts = True
Tempbook.Close
@agbishara
agbishara / VBA - Copy and Paste Visible Cells in Range
Created April 15, 2014 16:03
This is good if you need to filter on a worksheet and do a special copy
Mainbook.Sheets(4).Range("E2:k5000").SpecialCells(xlCellTypeVisible).Copy
Sheet.Range(TMPCellAddress).PasteSpecial xlPasteValues