Skip to content

Instantly share code, notes, and snippets.

View r3wt's full-sized avatar
😅
Move Fast. Break Things.

Garrett R. Morris r3wt

😅
Move Fast. Break Things.
  • Walmart
  • Hartman, Arkansas, United States
View GitHub Profile
@r3wt
r3wt / subarrays.php
Last active August 29, 2015 14:24
create a contiguous subarray lambda
<?php
function create_csl($length = 3,$comparison_operator = '>')
{
$fn = '';
$i = 0;
while(true)
{
if($i == 0)
{
@r3wt
r3wt / instructions.md
Created September 8, 2015 17:58
a simple way to run cronjobs on nginx/hhvm with JIT capabilities.

cron.sh:

#!/bin/bash

curl http://localhost/related.php &

curl http://localhost/artist_rank.php &

curl http://localhost/sitemap.php &
<?php
namespace UserFrosting\Util;
trait ArraySingleton
{
protected $data = [];
protected $defaults = [];
private static $instance = null;
@r3wt
r3wt / yearselect.twig
Created January 27, 2016 07:34
twig year select
<select name="year">
<option value="">Not Selected</option>
{% for i in range(19,20) %}
{%for j in range(0,9) %}
{% for k in range (0,9) %}
{% set y %}{{i}}{{j}}{{k}}{%endset%}
{% if y <= "now"|date('Y') %}
<option value="{{y}}">{{y}}</option>
{% endif %}
{% endfor %}
@r3wt
r3wt / README.md
Last active January 5, 2017 01:22
ez tiny grid framework. no jquery!

No media queries are used Since tablets and mobiles are now displaying huge resolutions, if we think its mobile, the body gets a class of .m, if we think its a tablet, it gets a class of .t. if its neither mobile nor tablet,it gets .d unless the screen is wider than 1920px, then it gets .hd

  • Columns must use class .col
  • Mobile use class .m-{desired size} eg .m-12
  • Tablet use class .t-{desired size} eg .t-6
  • Desktop use class .d-{desired size} eg .d-4
  • Huge Desktop use class .hd-{desired size} eg .hd-2
  • 12 columns (.col). extras .row, .container, .container.fluid
  • use .{size}-hide to hide eg .m-hide would hide for mobile.
@r3wt
r3wt / db.factory.js
Last active February 7, 2017 18:16
a helper for angularfire making things easier.
angular
.module('myApp')
.factory('$db',['$firebaseObject','$firebaseArray','$q',function($firebaseObject,$firebaseArray,$q){
function $db( type, id ){
var ref = firebase.database().ref(type).child(id);
var obj = $firebaseObject(ref);
return $q(function(resolve,reject){
obj.$loaded().then(function(){
resolve(obj);
@r3wt
r3wt / index.js
Created January 14, 2018 20:16
random_password generator in javascript
const random_password = (len=64) => {
let chars='abcdefghijklmnopqrstuvwxyz123456789-_=+`~:;>,.<}{[]|)(*&^%$#@!';
let password = '';
while(password.length < len) {
password+= chars.charAt(Math.floor((Math.random() * chars.length) + 1) % chars.length);
}
return password;
};
@r3wt
r3wt / gist:83629275bd3a153915ef
Last active January 24, 2018 12:21
Rollback hhvm on ubuntu
1. go to http://dl.hhvm.com/ubuntu/pool/main/h/hhvm/ and right click and copy the link to the version of hhvm you want to rollback to
2. sudo apt-get autoremove hhvm -y
3. wget <link you just copied>
4. sudo dpkg -i <name of file u just downloaded>
5. apt-get install -f
6. service hhvm start
Edit: Don't worry when it errors out on step 4. that is expected. just continue to step 5.
@r3wt
r3wt / bind.js
Last active December 5, 2019 18:24
function bind()
/* partial implementation of Function.prototype.bind */
Function.prototype.bind || (Function.prototype.bind = function(/* context[,arg1,arg2...] */) {
var fn = this;
var args = Array.prototype.slice.call(this,arguments);//preset args
var context = args.shift() || undefined;
return function(){
var args2 = args.concat( Array.prototype.slice.call(arguments) );//spec states any passed args should be appended to preset arguments.
return fn.apply(context,args2);
};
});
@r3wt
r3wt / animateable.js
Last active July 4, 2021 14:48
@animateable decorator/mixin that can be used to add simple animations to any class object in javascript
const animateable = (a) => {
a.prototype.quad = function(x){
return x ** 2
};
a.prototype.linear = function(x){
return x;
};
a.prototype.animate = function({ duration=300, ease=this.quad, start, end, onUpdate, onComplete=()=>{}}){