Skip to content

Instantly share code, notes, and snippets.

View mgmilcher's full-sized avatar

Marius Milcher mgmilcher

View GitHub Profile
function initLazyImages() {
const lazyImages = document.querySelectorAll(".lazy-image");
function onIntersection(imageEntities) {
imageEntities.forEach(image => {
if (image.isIntersecting) {
observer.unobserve(image.target);
image.target.src = image.target.dataset.src;
}
});
@mgmilcher
mgmilcher / range-finder.js
Created October 5, 2015 08:56
Range Finder
var x1 = 1;
var x2 = 100;
var y1 = 99;
var y2 = 1250100;
function rangeFinder(x1,x2,y1,y2) {
return Math.max(x1,y1) <= Math.min(x2,y2);
}
@mgmilcher
mgmilcher / gist:029e9ebe78cc2e6c8efa
Created April 30, 2015 10:01
WP Export Posts as JSON
<?php
include "wp-load.php";
$posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish');
$posts = $posts->posts;
/*
global $wpdb;
$posts = $wpdb->get_results("
SELECT ID,post_type,post_title
@mgmilcher
mgmilcher / gist:5eaed7714d031a12ed97
Last active March 28, 2023 14:53
Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X

This is my take on how to get up and running with NGINX, PHP-FPM, MySQL and phpMyAdmin on OSX Yosemite.

This article is adapted from the original by Jonas Friedmann. Who I just discovered is from Würzburg in Germany. A stonesthrow from where I was born ;)

Xcode

Make sure you have the latest version of XCode installed. Available from the Mac App Store.

Install the Xcode Command Line Tools:

xcode-select --install

@mgmilcher
mgmilcher / osx-server-aliases
Last active March 18, 2018 16:02
osx-server-aliases
### SERVER SERVICES ALIAS
# Nginx
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
# PHP-FPM
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
@mgmilcher
mgmilcher / gist:9892489
Last active August 29, 2015 13:57 — forked from g3d/gist:2709563
OSX Chill Defaults
@mgmilcher
mgmilcher / gist:9184511
Created February 24, 2014 09:29
Computer Science - Crib Sheet

#ACID

Atomicity

Atomicity requires that each transaction is "all or nothing": if one part of the transaction fails, the entire transaction fails, and the database state is left unchanged. An atomic system must guarantee atomicity in each and every situation, including power failures, errors, and crashes. To the outside world, a committed transaction appears (by its effects on the database) to be indivisible ("atomic"), and an aborted transaction does not happen.

##Consistency

The consistency property ensures that any transaction will bring the database from one valid state to another. Any data written to the database must be valid according to all defined rules, including but not limited to constraints, cascades, triggers, and any combination thereof. This does not guarantee correctness of the transaction in all ways the application programmer might have wanted (that is the responsibility of application-level code) but merely that any programming errors do not violate any defined rules.

@mgmilcher
mgmilcher / gist:6563332
Created September 14, 2013 16:23
In App Purchasing with Cordova

####Install PhoneGap IAP Plugin

plugman install --platform ios --project [directory] --plugin git://github.com/j3k0/PhoneGap-InAppPurchase-iOS.git

####Add StoreKit framework to XCode project

  1. Go to the Build Phases tab in your project target
  2. Expand the "Link Binary With Libraries" list.
  3. Click the plus button at the button
  4. Search for StoreKit and add the StoreKit.framework item.
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm --install rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum install --enablerepo=rpmforge memcached
memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody
wget http://pecl.php.net/get/memcache-2.2.5.tgz
tar -xvf memcache-2.2.5.tgz
cd memcache-2.2.5
phpize && ./configure --enable-memcache && make
cp /root/memcache-2.2.5/modules/memcache.so /usr/lib/php/modules/
echo extension=memcache.so >> /etc/php.ini