Skip to content

Instantly share code, notes, and snippets.

View ken-muturi's full-sized avatar

muturiken ken-muturi

View GitHub Profile
@ken-muturi
ken-muturi / jekyll-and-liquid.md
Created February 10, 2018 17:43 — forked from magicznyleszek/jekyll-and-liquid.md
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@ken-muturi
ken-muturi / xml.php
Last active August 3, 2016 08:35
mark-xml
public function xml()
{
$url = '';
$this->load->helper('curl');
$response = curl::get("{$url}:8080/services/user/devices.xml");
$devices = new SimpleXMLElement($response);
util::printr( $devices );
foreach ($devices->id as $device)
{
@ken-muturi
ken-muturi / util_helper.php
Created July 8, 2016 10:16
mark-util.php
<?php
/**
* This class contains a collection of useful functions used all over the place
* */
class Util
{
/**
* Generate a random string
* @param integer $xters string length
<?php
class Curl
{
var $headers;
var $user_agent;
var $compression;
var $cookie_file;
var $proxy;
@ken-muturi
ken-muturi / config.php
Last active July 8, 2016 08:05
ODK config
<?php
preg_match_all("/\/([^\/]+)\//i", $_SERVER['REQUEST_URI'], $match);
define('REQUEST_URI', $_SERVER['REQUEST_URI']);
define('BASE_DIR', $match[1][0] . '/');
define ('FS_PATH', str_replace('//', '/', $_SERVER['DOCUMENT_ROOT'] . '/' . BASE_DIR));
define ('BASE_URL', 'http://' . str_replace('//', '/', $_SERVER['SERVER_NAME'] . '/' . BASE_DIR));
@ken-muturi
ken-muturi / formList.php
Last active July 8, 2016 08:20
ODK formList.php
<?php
require("../config.php");
require("../util.php");
if( ! isset( $_SERVER['PHP_AUTH_DIGEST'] ) || empty($_SERVER['PHP_AUTH_DIGEST']) )
{
http_response_code(401);
header("HTTP/1.1 401 Unauthorized");
header('WWW-Authenticate: Digest realm="'. $realm .'",qop="auth",nonce="'.uniqid().'",opaque="'. md5($realm) .'"');
@ken-muturi
ken-muturi / util.php
Last active July 8, 2016 08:19
PHP ODK Util File
<?php
class Util
{
public static $realm = 'PHP ODK Aggregate';
public static $users = [
'admin' => 'mypass',
'guest' => 'guest'
];
// function to parse the http auth header
@ken-muturi
ken-muturi / Submission.php
Last active September 12, 2019 13:37
ODK Submission Controller
<?php
require("../config.php");
require("../util.php");
if ( ! empty($_FILES) )
{
header('Server: Apache-Coyote/1.1');
header('Content-Type: application/xml;charset=UTF-8');
header( "Date: ".date('r'));
header('Content-Length: 1000000');
@ken-muturi
ken-muturi / gist:30c6652deff08b60c6e1
Last active July 17, 2017 02:17 — forked from evildmp/gist:3094281
Set up Django, nginx and uwsgi