Skip to content

Instantly share code, notes, and snippets.

Avatar

Igor Santos igorsantos07

View GitHub Profile
@igorsantos07
igorsantos07 / proportionalPieces.js
Created Jun 6, 2018
Calculates unequal but proportional pieces of 100%
View proportionalPieces.js
//used this through trial and error to find the correct proportions for a progress bar where one element is 10%, with 5 pieces
//based on https://stackoverflow.com/a/40094266/102960
function proportionalPieces(proportion, size) {
const pieces = [1]
for (let i = 1; i < size; i++) {
pieces[i] = pieces[i-1] * proportion
}
const sum = pieces.reduce((acc, piece) => acc + piece)
View check-migrations (laravel)
#!/usr/bin/env php
<?php
define('ROOT', dirname(dirname(__DIR__)));
chdir(ROOT);
$pending_migrations = (int)trim(`./artisan migrate:status --no-ansi | grep -c '| N'`);
echo "===> Pending migrations: $pending_migrations";
if ($pending_migrations) {
$migrations = array_filter(explode("\n", `./artisan migrate:status --no-ansi | grep '| N'`));
$migrations = array_map(function($line) { return ' > '.trim($line, " |N\t"); }, $migrations);
@igorsantos07
igorsantos07 / 1 General info.md
Last active Apr 22, 2016
CSS tools on React
View 1 General info.md

Main comparison

  1. Traditional CSS

  • Simple approach, known API
  • we would have to deal with namespace conflicts
  • leverages browser caching, storing the entire app style in the first load and reducing following reloads
  1. Style-based implementations
View public-index.php
<?php
use Luracast\Restler\Restler;
use Luracast\Restler\Explorer;
require __DIR__ . '/../vendor/autoload.php';
$r = new Restler();