Skip to content

Instantly share code, notes, and snippets.

View fntneves's full-sized avatar

Francisco Neves fntneves

View GitHub Profile
@fntneves
fntneves / pretty_error.sh
Last active August 29, 2015 14:11
Pretty errors function
#!/bin/bash
# Print pretty errors
# Usage: pretty_error <type> <message> <name>
pretty_error()
{
# Text colors
COLOR_NONE='\033[0m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
@fntneves
fntneves / com.googlecode.iterm2.plist
Last active August 29, 2015 14:13
minimal theme for iterm2 with oh-my-zsh
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AdjustWindowForFontSizeChange</key>
<true/>
<key>AllowClipboardAccess</key>
<true/>
<key>AnimateDimming</key>
<true/>
@fntneves
fntneves / properties.sh
Last active August 29, 2015 14:19
.properties property modifier
#!/bin/bash
sed -E "s/^$1=[^ ]*$/$1=$2/g" $3
@fntneves
fntneves / utc.js
Created July 26, 2015 22:59
Moment.JS - Convert UTC to Local Time
$.fn.format = function() {
return this.each(function() {
var $this = $(this);
var time = $this.attr("datetime");
var localTime = moment.utc(time).local().format();
$this.attr("datetime", localTime).timeago();
return this;
});
@fntneves
fntneves / image_data_uri_validation_rule.php
Last active December 24, 2015 22:30
Validator extension for Image Data URI
<?php
Validator::extend('image_uri', function($attribute, $value, $parameters, $validator) {
$matches = [];
$pattern = '/^data:image\/(jpe?g|png|bmp|gif|svg);base64\,.+$/';
return preg_match($pattern, $value, $matches) > 0 && in_array($matches[1], $parameters);
});
var activities = {
resting: { bpm: 70 },
walking: { bpm: 90 },
running: { bpm: 150 },
};
var activityStatus = {
previousActivity: activities.resting,
activity: activities.resting,
inTransition: false,
@fntneves
fntneves / JwtInterceptor.js
Last active May 3, 2016 08:12
Json Web Token Interceptor for VueJS
import Auth from '../../modules/Auth';
const LOGIN_NAMED_ROUTE = 'login';
const EXPIRED_ERROR = 'token_expired';
export default function () {
return {
request: (request) => {
let token = Auth.token();
@fntneves
fntneves / Str.php
Last active September 9, 2016 10:22
[Laravel] Support method to convert a given string to a searchable string (ascii+lowercase), according to the given minimum length.
<?php
namespace App\Support;
class Str extends \Illuminate\Support\Str
{
/**
* Returns the searchable string.
*
* @param string $string String to convert
@fntneves
fntneves / .php_cs
Last active January 9, 2020 00:24
Laravel Coding Standards
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_equals' => false],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
export default class FileReaderPromise {
constructor(file) {
this.file = file;
}
readAsText() {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = e => resolve(e.target.result);
reader.onerror = e => reject(new Error(`Error reading ${this.file.name}: ${e.target.result}`));