Skip to content

Instantly share code, notes, and snippets.

View sftsk's full-sized avatar

Lukas Jakob Hafner sftsk

View GitHub Profile
@gpbmike
gpbmike / Streamer.php
Created July 6, 2011 21:08
php backend for streaming file upload with XMLHttpRequest
<?php
class File_Streamer
{
private $_fileName;
private $_contentLength;
private $_destination;
public function __construct()
{
if (!isset($_SERVER['HTTP_X_FILE_NAME'])
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@neomantra
neomantra / thing-o-matic-command-line-update.md
Created January 14, 2014 04:30
Thing-o-matic Firmware Upgrade from command-line. Using the ReplicatorG and MakerWare I was getting errors like "upload failed".... and endlessly pressing reset and upload. This worked without any tricky timing. I did this on OSX, but I don't know why it wouldn't work similarly on another OS...

After spending two hours fucking with pushing my reset-button and clicking upload in both ReplicatorG and Makerware, I figured out how to do it from the command line. The command line was determined from running ReplicatorG on the console and trying to upgrade the firmware.

Install ReplicatorG

Download and install it from http://www.makerbot.com/sailfish/install/

Get the 4.4 firmware from Makerbot

wget http://firmware.makerbot.com/firmware/MB-mb24-2560-Sailfish-v4.4-r1029.hex
@ericlbarnes
ericlbarnes / bower.json
Last active January 8, 2024 01:52
Gulp, Bower, Bootstrap Sass, FontAwesome
{
"name": "project",
"version": "0.0.0",
"authors": [
"Eric Barnes <me@example.org>"
],
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
@qstudio
qstudio / pll_copy_post_metas.php
Last active September 15, 2021 16:36
WP / PolyLang / Un-Sync Specified Custom Fields
<?php
// filter to exclude specified post_meta from Polylang Sync ##
add_filter( 'pll_copy_post_metas', 'q_pll_copy_post_metas' );
/**
* Remove defined custom fields from Polylang Sync
*
* @since 0.1
* @param Array $metas
@james2doyle
james2doyle / simple-json-reponse.php
Last active March 7, 2024 06:02
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($code = 200, $message = null)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
<?php
// put array in here
$array = array (
'key' => 'group_54624ad06f391',
'title' => 'Company List',
'fields' => array (
array (
'key' => 'field_54624aff43237',
'label' => 'Companies',
@stuartduff
stuartduff / woocommerce-add-sku-to-emails.php
Last active September 7, 2017 15:04
This filter will add SKU numbers to your WooCommerce emails in v2.6 and above
// Edit order items table template defaults
function sd_add_wc_order_email_sku( $table, $order ) {
ob_start();
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
'order' => $order,
'items' => $order->get_items(),
'show_download_links' => $show_download_links,
@only-cliches
only-cliches / pixibackground.js
Last active March 14, 2024 12:07
PixiJS Background Cover & Background Container
/*
* PixiJS Background Cover/Contain Script
* Returns object
* . {
* container: PixiJS Container
* . doResize: Resize callback
* }
* ARGS:
* bgSize: Object with x and y representing the width and height of background. Example: {x:1280,y:720}
* inputSprite: Pixi Sprite containing a loaded image or other asset. Make sure you preload assets into this sprite.
@yratof
yratof / functions.php
Created December 7, 2016 16:01
Woocommerce remove unused attributes on product variations
<?php
add_action( 'init', function() {
ini_set( 'memory_limit', '2048M' );
set_time_limit( 0 );
$posts = get_posts( [
'post_type' => 'product',
'posts_per_page' => -1
] );
$count = 0;