Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
jakebellacera / ICS.php
Last active June 2, 2024 02:20
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@soldair
soldair / bench.php
Created June 28, 2011 21:26
fastest way to get a hash based on the githash in php
<?php
/*
~>php bench.php
md5_file 634.3932 ms
hash_file/md5 714.4802 ms
parse contents 911.6130 ms
parse contents substr 852.8361 ms
contents first chunk 590.0660 ms
all ran with 30000 itterations
@mrdaemon
mrdaemon / .tmux-bootstrap.sh
Created July 12, 2011 23:01
tmux config and random bullshit
#!/bin/bash
# Shitty tmux bootstrap script for auto-login and session planning
SESSIONNAME="hack"
hash tmux || { echo "Could not find tmux? Ensure it's in \$PATH" ; exit 1 ;}
check_session() {
tmux list-sessions | cut -d ':' -f '1'| \
egrep "^""$SESSIONNAME""\$" 2>&1 > /dev/null
@pnomolos
pnomolos / Example conditions.php
Created July 21, 2011 21:18
LS DB ActiveRecord HABTM extension for conditional joins
<?php
public $has_and_belongs_to_many = array(
'add_on_order_status'=>array(
'class_name'=>'Shop_StatusTransition',
'primary_key'=>'psinventory_param_id',
'foreign_key' => 'shop_status_transition_id',
'join_table' => 'psinventory_params_shop_status_transitions',
'join_fields' => array(
'transition_flag' => 'active'
)
@mhawksey
mhawksey / gist:1276293
Last active October 23, 2023 09:00
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
<?php
// File containing cronjobs
$cronFile = dirname(__FILE__) . '/crontab';
// Lockfile to prevent multiple instances
$pidFile = dirname(__FILE__) . '/cron.lock';
// Exit file to signal a running instance to exit
$exitFile = dirname(__FILE__) . '/cron.exit';
@EHLOVader
EHLOVader / gist:1473452
Created December 13, 2011 19:18
Fix for VirtualDocumentRoot issues in Apache.
<?php apache_setenv("DOCUMENT_ROOT",$_SERVER['DOCUMENT_ROOT'] = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME'])) ?>
@khalsah
khalsah / deploy.sh
Created January 3, 2012 22:59
Experimental git sync & deploy hooks
#!/bin/sh
LOCAL_BRANCH="master"
LIVE_BRANCH="live"
REMOTE_NAME="deploy"
if [ "$(git symbolic-ref -q HEAD)" != "refs/heads/${LOCAL_BRANCH}" ]; then
echo "Not on ${LOCAL_BRANCH}, not deploying"
exit 1
else
@pnomolos
pnomolos / file.php
Created January 5, 2012 17:26
Lemonstand - Minimize memory when using products
<?php
$grouped_product = new Shop_Product(null, array('no_validation' => true, 'no_column_init' => true, 'no_timestamps' => true));
$data = $_POST['Shop_Product'];
$data['grouped'] = 1;
$data['name'] = $product->name . ' ('.$attributes->name.')';
$data['url_name'] .= '_'.uniqid('', true);
$data['sku'] .= '-' . strtolower($attributes->sku.uniqid('', true));
$data['grouped_option_desc'] = $attributes->name;
$data['x_aga_ids'] = join(':', $ids);
@EHLOVader
EHLOVader / Base File.sublime-settings.js
Last active September 29, 2015 18:18
My user settings for SublimeText2 (and ST3) which includes all fonts from http://www.codinghorror.com/blog/2007/10/revisiting-programming-fonts.html and links to download them when needed. Also added an extended monokai scheme and great theme for enhancing SublimeText
{
/**
* Monokai Extended Color Scheme
* Author: Jon Schlinkert
* Link: https://github.com/jonschlinkert/sublime-monokai-extended
*/
"color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme",
/**