Skip to content

Instantly share code, notes, and snippets.

🏃
Running away from my issues.

Billcountry Mwaniki Billcountry

View GitHub Profile
@Billcountry
Billcountry / images.js
Last active Feb 4, 2018
Load images after the whole page has loaded by just adding the class .async-img
View images.js
// Default image data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mO8dPv2fwAImAOJMh4kwgAAAABJRU5ErkJggg==
function load_images(){
var images = document.querySelectorAll(".async-img");
for(var id=0; id<images.length; id++){
var image = images[id];
var img_url = image.getAttribute('url');
image.src = img_url;
}
@Billcountry
Billcountry / deploy.php
Last active Feb 3, 2018
This file will deploy your git repository to a php server or the directory it's. It's convenient for cpanel hosting and you can add it's URL as a web-hook so that it's updated every time you push your updates to git.
View deploy.php
<?php
ini_set('display_errors', 1);
header('Content-Type: text/plain');
$account = '_YOUR_ACCOUNT_NAME_'; // Example Billcountry
$repo = '_REPO_TO_DEPLOY_'; // iF i NEED TO EXPLAIN THIS YOU SHOULD PROBABLY LEAVE
$branch = '_BRANCH_TO_DEPLOY_';
$url = "https://github.com/$account/$repo/archive/$branch.zip";
echo("Cloning into $url\n");
$path = dirname(__FILE__)."/$branch.zip";
@Billcountry
Billcountry / utilities.py
Created Nov 8, 2017
A collection of functions that I use to speed up my productivity. Feel free to use them as you wish. Connect's to a database, provides method to insert table, run sql queries, hash using sha256, generate dates with addation or removal of time, log your errors among others
View utilities.py
import smtplib
import os
import random
import hashlib
from datetime import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from validate_email import validate_email
import sqlalchemy
from sqlalchemy import engine
@Billcountry
Billcountry / fetch_wrapper.js
Last active Oct 30, 2017
A wrapper for fetch that falls back to Jquery ajax if the fetch api is not available on the browser.
View fetch_wrapper.js
let ajax = function (options) {
function setDefaultVal(value, defaultValue){
return (value === undefined) ? defaultValue : value;
}
let settings = {
url: setDefaultVal(options.url, ""),
type: setDefaultVal(options.type, "GET"),
headers: setDefaultVal(options.headers, {}),
data: setDefaultVal(options.data, {}),
dataType: setDefaultVal(options.dataType, "text"),
@Billcountry
Billcountry / proxy.py
Last active Sep 29, 2017
An easy way to create personal proxy servers and bouncing your connection off several servers before the connection finally reaches you. Use with caution, am not responsible of your actions.
View proxy.py
#!/usr/bin/python
import sys, thread, socket
'''
Under MIT License
To run Simply
(If you make proxy.py executable)
./proxy.py 8090
(Else)
python proxy.py 8090
You can’t perform that action at this time.