Skip to content

Instantly share code, notes, and snippets.

View twitterFollowerCuratorBot.php
<?php
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// https://gist.github.com/levelsio/6ee6c47283ee414ef3aace1d81986717
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
@marcaube
marcaube / fa.sublime_snippet
Created Jul 18, 2017 — forked from calebporzio/fa.sublime_snippet
Font Awesome sublime snippet for creating icon tags
View fa.sublime_snippet
<snippet>
<content><![CDATA[
<i class="fa fa-fw fa-${1}"></i>&nbsp;
]]></content>
<tabTrigger>fa</tabTrigger>
<description>Font Awesome Icon</description>
<scope>text.blade, text.html.blade, text.html</scope>
</snippet>
@marcaube
marcaube / .gitconfig
Created May 1, 2017 — forked from imkevinxu/.gitconfig
`git random` alias that will commit a random commit message from http://whatthecommit.com/
View .gitconfig
[alias]
random = !"git add -A; git commit -am \"$(echo $(curl -s http://whatthecommit.com/index.txt)\" (http://whatthecommit.com)\")\"; git pull --rebase; git push"
@marcaube
marcaube / CastsValueObject.php
Created Jan 16, 2017 — forked from cmaas/CastsValueObject.php
A Trait to automatically cast value objects in Laravel without needing a Mutator and an Accessor.
View CastsValueObject.php
<?php
trait CastsValueObjects
{
protected function castAttribute($key, $value)
{
$castToClass = $this->getValueObjectCastType($key);
// no Value Object? simply pass this up to the parent
if (!$castToClass) {
return parent::castAttribute($key, $value);
@marcaube
marcaube / harlem-shake.js
Created Apr 8, 2016
Harlem Shake, a script to make those XSS dance
View harlem-shake.js
// Source: http://pastebin.com/aJna4paJ
javascript:(function(){function c(){var e=document.createElement("link");e.setAttribute("type","text/css");e.setAttribute("rel","stylesheet");e.setAttribute("href",f);e.setAttribute("class",l);document.body.appendChild(e)}function h(){var e=document.getElementsByClassName(l);for(var t=0;t<e.length;t++){document.body.removeChild(e[t])}}function p(){var e=document.createElement("div");e.setAttribute("class",a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s=d(i);return s.height>e&&s.height<n&&s.width>t&&s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e&&!isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.
View keybase.ms
### Keybase proof
I hereby claim:
* I am marcaube on github.
* I am marcaube (https://keybase.io/marcaube) on keybase.
* I have a public key whose fingerprint is A323 88CD 3850 262E 1EA3 CC00 0A1A 7489 29EB 0696
To claim this, I am signing this object:
@marcaube
marcaube / strlen_benchmark.php
Created Jan 22, 2015
Benchmarking "strlen($string) > 25" vs "isset($string[25])" for speed
View strlen_benchmark.php
<?php
/**
* @param array $functions An associative array of closures to benchmark
* @param int $iterations The number of iterations
*/
function benchmark($functions, $iterations)
{
foreach ($functions as $name => $function) {
$start = microtime(true);
@marcaube
marcaube / is_array_benchmark.php
Last active Aug 29, 2015
Benchmarking "(array) $var === $var" vs "is_array($var)" for speed
View is_array_benchmark.php
<?php
/**
* @param array $functions An associative array of closures to benchmark
* @param int $iterations The number of iterations
*/
function benchmark($functions, $iterations)
{
foreach ($functions as $name => $function) {
$start = microtime(true);
@marcaube
marcaube / gist:9529442
Created Mar 13, 2014
Nice commit graph
View gist:9529442
git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
View phone-regex.md

US/CAN phone regex

A simple regex I wrote to loosely validate phone number format. I want it to match a US/CAN phone number without being anal about it and alienating my users with a rigit format. It will match any of those:

  • 1-800-555-5555
  • 1 (800) 555-5555
  • 1 555 555 5555
  • 555-555-5555
  • 555 555-5555
  • 555 555 5555