Skip to content

Instantly share code, notes, and snippets.

View jgmuchiri's full-sized avatar
🏠
Working from home

John Muchiri jgmuchiri

🏠
Working from home
View GitHub Profile
@jgmuchiri
jgmuchiri / 404.html
Created February 16, 2019 20:44
Responsive 404 page not found
<!doctype html>
<html lang="en">
<head>
<title>404 - Page Not Found!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet" type="text/css">
<style>
.penguin {
/* change code below */
--penguin-skin: gray;
--penguin-belly: white;
--penguin-beak: orange;
/* change code above */
position: relative;
@jgmuchiri
jgmuchiri / composer.json
Created February 2, 2019 16:55
PHP Stripe gateway
{
"require": {
"stripe/stripe-php": "^6.8",
"phpmailer/phpmailer": "^6.0",
"symfony/polyfill-mbstring": "^1.8"
}
}
@jgmuchiri
jgmuchiri / tag-extractor.php
Created February 2, 2019 05:57
Extracts attribute values inside an element from html content
<?php
/**
* You can modify preg_match_all to match your needs
*
* Extracts attribute values inside an element from html content
* You post html content and inside the content, you have shortcodes with attributes like [pageBreak id="home" title="Home page"]
* You want to extract id and title attribute values so you can save them in db as a matching pair.
*/
$content = 'hello there [pageBreak ="home" title="Home page"] new page [/pageBreak] another page';
extract($content);
@jgmuchiri
jgmuchiri / bbcode-html.php
Created February 2, 2019 05:00
Convert BBcode to HTML and Vice-Versa
<?php
//This function let convert BBcode to HTML
function bbcode_to_html($text)
{
$text = nl2br(htmlentities($text, ENT_QUOTES, 'UTF-8'));
$in = array(
'#\[b\](.*)\[/b\]#Usi',
'#\[i\](.*)\[/i\]#Usi',
'#\[u\](.*)\[/u\]#Usi',
'#\[s\](.*)\[/s\]#Usi',
@jgmuchiri
jgmuchiri / alertboxes-alerts
Last active February 2, 2019 03:13
Information blocks - alerts
<div style="width:500px; margin:0 auto">
<div class="alertbox alertbox-info">
This is an information message
</div>
<div class="alertbox alertbox-success">
We have successfully processed your request!
</div>
<div class="alertbox alertbox-warning">
@jgmuchiri
jgmuchiri / wsl-dev-env-preliquisites.sh
Last active January 29, 2019 00:39
A quick way to create a Dev env with WSL as the server for Apache and MySQL
#!/bin/bash
sudo apt-get update
sudo apt-get install apache2 mysql-server php72-cli git
sudo service apache2 start
sudo service mysql start
sudo service php7.2-fpm start
#Mailhog -optional
git clone https://github.com/mailhog/MailHog.git mailhog
@jgmuchiri
jgmuchiri / iFrameResizer.html
Last active January 3, 2019 21:42
Resizes iframe if window height resizes
<iframe
src="your-url-here"
id="my_iframe"
style="width: 100%;"
border="0"
margin="0" padding="0"
frameborder="0" scrolling="no" ></iframe>
@jgmuchiri
jgmuchiri / My_config.php
Last active October 19, 2018 02:06
CodeIgniter load language files dynamically. User can select from dropdown menu their preferred language. Autoload this model.
<?php if(!defined('BASEPATH')) {
exit('No direct script access allowed');
}
//autoload this model
class My_config extends CI_Model
{
public function __construct()
{
$this->setLanguage();
@jgmuchiri
jgmuchiri / X-SiteImagesScrapper.vue
Last active August 28, 2018 18:04
Download images in a page - VueJS
<template>
<div>
<div class="row">
<div class="col-sm-9">
<button class="btn btn-success" v-on:click="dlImages()">
<i class="fa fa-download"></i>
Download photos
</button>
<hr/>