Skip to content

Instantly share code, notes, and snippets.

View Lewiscowles1986's full-sized avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
echo time()."\r\n";
var_dump( microtime_str() );
var_dump( microtime_str() );
var_dump( microtime_str() );
var_dump( microtime_str() );
var_dump( microtime_str() );
var_dump( microtime_str() );
var_dump( microtime_str() );
var_dump( microtime_str() );
var_dump( microtime_str() );
@Lewiscowles1986
Lewiscowles1986 / getWP.sh
Created October 3, 2014 18:35
install / update wordpress
#!/bin/sh
sudo apt-get update && apt-get install unzip
wget http://wordpress.org/latest.zip
unzip -o -u latest.zip
@Lewiscowles1986
Lewiscowles1986 / test.dt.human.php
Created December 9, 2014 03:43
Testing Human date / time
<?php
//
// setup
//
date_default_timezone_set('Europe/London');
//
// code to test
//
$post_time = get_the_time( 'U' );

Problem #1

God algorithms, God solutions etc, God methods etc often add unnesecarry complexity with very little benefit. There is no God, get over that...

Shipow: Even if I don't support religions, I'm pretty ok with the idea of an omnipotent mind as it stay in the context of narration. And I guess that even someone very trustfull will never imagine God as web/app designer ;)

Problem #2

Lack of evidence for decisions... I could understand iteratively improving a design because nobody gets "sign up", "sign in"... if it EVER happened! Jeff even admits there is little evidence against "sign up" / "sign in", and the link seems to be to some stackoverflow o similar upvoting thread (thus promoting over-simplification, lack of engagement and pack mentality common on such services)... The truth is "sign up", "sign in" is not confusing, unless you do not speak english, then you have bigger problems than "sign up", "sign in"... You know like using any of the interface...

@Lewiscowles1986
Lewiscowles1986 / Random.php
Last active August 29, 2015 14:13
fantastic secure random bytes from native PHP
<?php
namespace lewiscowles\security {
Class Random {
const SECRANDSRC = '/dev/urandom';
const DEFAULT_RANDOM_BYTES = 16;
public static function getTrueRandomBytes( $cnt=16 ) {
$out = '';
@Lewiscowles1986
Lewiscowles1986 / TextColorHelper.php
Created January 18, 2015 07:09
PHP Bash colour re-factor...
<?php
namespace {
use \lewiscowles\nix\terminal\bash\TextColorHelper;
$bashTxt = new TextColorHelper();
$bashTxt->setString( 'Normal Text' )
->output()
->setString( 'Less Normal Text', 'light_purple' )
->output()
->setString( 'Success', 'light_green' )
@Lewiscowles1986
Lewiscowles1986 / tag_cloud.html
Created June 23, 2015 02:06
Tag Cloud Include for Jekyll
{% assign all_tags = site.tags|size %}
<div class="tagcloud">{% for tag in site.tags %}
{% assign tag_name = tag|first %}
{% assign tag_count = tag|last|size %}
{% assign tag_avg = tag_count | div: all_tags %}
<span class="tag" style="font-size: {{ tag_avg | times: 100 }}%;">{{ tag_name }}</span>{% if false %} ({{ tag_count }}){% endif %}
{% endfor %}</div>
@Lewiscowles1986
Lewiscowles1986 / _config.yml
Created June 23, 2015 02:38
Jekyll Content Sections - Port of CD2 content-sections WordPress Plugin
# Find your Start of collections
collections:
content-sections:
output: true
title: Content Sections
# Continue with other collections
@Lewiscowles1986
Lewiscowles1986 / get_otto.sh
Created October 4, 2015 16:17
Ubuntu Otto
#!/bin/sh
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" > /etc/apt/sources.list.d/virtualbox.list'
sudo apt-get update -y
sudo apt-get install -y dkms unzip virtualbox-5.0 vagrant
wget https://dl.bintray.com/mitchellh/otto/otto_0.1.1_linux_amd64.zip -O otto.zip
unzip otto.zip
rm otto.zip
mv otto /usr/local/bin/otto
@Lewiscowles1986
Lewiscowles1986 / rand.js
Last active October 29, 2015 22:12
JavaScript Random Numbers
function rand( min, max ) {
var seed = Math.random();
if( typeof min != 'number' && typeof max != 'number' ) {
return seed; // default is just random
} else if( typeof min == 'number' && typeof max != 'number' ) {
return Math.round( seed * min );
} return Math.floor( seed * max ) + min;
}
//