Skip to content

Instantly share code, notes, and snippets.

View francmut's full-sized avatar
🎯
Focusing

Francis Muturi francmut

🎯
Focusing
  • Splenics Limited
  • Nairobi, Kenya
View GitHub Profile
@francmut
francmut / get_combinations.php
Created March 22, 2020 16:41 — forked from cecilemuller/get_combinations.php
PHP: Get all combinations of multiple arrays (preserves keys)
<?php
function get_combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_value) {
$tmp[] = array_merge($result_item, array($property => $property_value));
}
@francmut
francmut / RegisterController.php
Created December 18, 2018 14:26
Register with file upload
public function register(Request $request) {
$validator = \Validator::make($request->all(), [
'username' => 'required|string',
'avatar' => 'required|file'
]);
if ($validator->fails()) {
return response()
->json([
@francmut
francmut / self-update-script.py
Created October 23, 2018 08:43 — forked from gesquive/self-update-script.py
Stick this in a python script to self update the script from an online source
def update(dl_url, force_update=False):
"""
Attempts to download the update url in order to find if an update is needed.
If an update is needed, the current script is backed up and the update is
saved in its place.
"""
import urllib
import re
from subprocess import call
def compare_versions(vA, vB):
@francmut
francmut / setup-zeromq.sh
Created March 25, 2018 13:54 — forked from katopz/setup-zeromq.sh
Setup zeromq in Ubuntu 16.04
#!/usr/bin/bash
# Download zeromq
# Ref http://zeromq.org/intro:get-the-software
wget https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz
# Unpack tarball package
tar xvzf zeromq-4.2.2.tar.gz
# Install dependency
@francmut
francmut / phpzmqinstall.sh
Created March 25, 2018 12:24 — forked from Kamisama666/phpzmqinstall.sh
Installation of ZeroMQ and php-zmq extension on Ubuntu 14.04. Must be run as root
#!/bin/bash
cd /tmp
apt-get update
apt install -y libtool pkg-config build-essential autoconf automake uuid-dev git wget
git clone git://github.com/jedisct1/libsodium.git
cd libsodium/
./autogen.sh
./configure && make check
make install
ldconfig
@francmut
francmut / wkhtmltopdf.md
Created March 22, 2018 00:40 — forked from kai101/wkhtmltopdf.md
How to Install Wkhtmltopdf 12.4 with patched Qt?

How to Install Wkhtmltopdf 12.4 with patched Qt?

Current version of apt-get wkhtmltopdf does not come with Qt patch. There are some issue going with both Qt patched and non-patched. Most common use case is compatible with the patched Qt.

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
sudo mv wkhtmltox/bin/wkhtmlto* /usr/local/bin 
sudo apt-get install -y openssl libssl-dev libxrender-dev libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig
{
"transactions": [
{
"trs": "1",
"rid": "943",
"pid": "5",
"uid": "56",
"oid": "339",
"qty": "55",
"barcode": "45657585",
/* From http://www.designyourway.net/blog/resources/31-css-code-snippets-to-make-you-a-better-coder/ */
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Sales Agent Route</name>
<description>SFA sales agent route</description>
<Style id="blueLine">
<LineStyle>
<color>ff0800f4</color>
<width>2</width>
</LineStyle>
@francmut
francmut / loops
Last active January 24, 2017 12:21
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Sales Agent Route</name>
<description>SFA sales agent route</description>
<Style id="blueLine">
<LineStyle>
<color>ff0800f4</color>
<width>2</width>
</LineStyle>