Skip to content

Instantly share code, notes, and snippets.

View sftsk's full-sized avatar

Lukas Jakob Hafner sftsk

View GitHub Profile
@sftsk
sftsk / countTo.js
Created March 13, 2015 09:52
small jQuery plugin to animate a counting to number
(function($) {
$.fn.countTo = function(options) {
// merge the default plugin settings with the custom options
options = $.extend({}, $.fn.countTo.defaults, options || {});
// how many times to update the value, and how much to increment the value on each update
var loops = Math.ceil(options.speed / options.refreshInterval),
increment = (options.to - options.from) / loops;
return $(this).each(function() {
@sftsk
sftsk / stopwatch.php
Created March 17, 2015 13:59
Measure how long something takes in php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
// do something in here
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
@sftsk
sftsk / .htaccess
Created March 24, 2015 08:41
www to non-www redirect .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
@sftsk
sftsk / gem installs osx
Last active August 29, 2015 14:17
install nokogiri osx yosemite
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
@sftsk
sftsk / wpml-resave.js
Last active August 29, 2015 14:20
hacky trigger for wpml translation re-save
var saveTranslations = function (el) {
var popupId = '#' + el.attr('id').replace('-', '-popup-');
el.trigger('click');
jQuery(jQuery(popupId).find('.term-save')).trigger('click');
var waitForClose = window.setInterval(function () {
if (jQuery(popupId).text() === '') {
window.clearInterval(waitForClose);
var nextRow = jQuery('#' + el.attr('id')).closest('tr').next('tr');
if (nextRow.length > 0) {
console.log('next row');
@sftsk
sftsk / osx-reverse-proxy
Created May 2, 2015 13:19
set up reverse proxy on osx server
I have changed the way I am doing reverse proxy on Mountain Lion Server. On my old Snow Leopard Server system, I looked at how it set-up Reverse Proxy. Configuring Reverse Proxy from the GUI, in Snow Leopard Server, added the following to the site configuration file (after the <IfModule mod_ssl.c> ~ </IfModule> section):
<IfModule mod_proxy_balancer.c>
ProxyPass / balancer://balancer-group/
ProxyPassReverse / balancer://balancer-group
<Proxy "balancer://balancer-group">
BalancerMember http://my.example.com:8080
</Proxy>
</IfModule>

In general for Wordpress the server needs the following:

https://wordpress.org/about/requirements/

In order for us to deploy to the server easily we will need the following as well:

  • folder with write permission on the server
  • domain pointing to the server and vhost set up to folder/current/web
  • ssh access to the server (with key authentication)
  • the server has to be able to run git & composer
@sftsk
sftsk / wp-plugin-list.js
Created April 21, 2016 14:43
JS Scriplet that creates a list of the active plugins of a WordPress installation. Useful when needed for a site documentation or similar
// v0.1
// @saftsaak
// got tt the plugins page, open the developer tools on your browser, paste this, hit enter and then copy-paste the output from the console log
var pList = "";
jQuery('#the-list tr.active:not(.plugin-update-tr)').each(function () {
var $this = jQuery(this);
var pTitle = jQuery('.plugin-title strong', $this).text();
var pVersion = jQuery('.plugin-version-author-uri', $this).text();
var pDesc = jQuery('.plugin-description', $this).text();
@sftsk
sftsk / how-to-set-up-stress-free-ssl-on-os-x.md
Created July 10, 2016 15:51 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
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