Skip to content

Instantly share code, notes, and snippets.

View VitorLuizC's full-sized avatar

Vitor L Cavalcanti VitorLuizC

View GitHub Profile
@VitorLuizC
VitorLuizC / breakpoint.scss
Last active December 29, 2016 17:06
CSS Breakpoints mixin for SASS + example usage
$_BREAKPOINTS: (
print: print,
xs: screen, // mobile-first fallback
sm: 48rem,
md: 64rem,
lg: 75rem
) !global;
@mixin breakpoint($point, $type: min) {
@if (type-of($point) == string) {
@VitorLuizC
VitorLuizC / main.js
Last active December 10, 2018 17:42
JavaScript micro-function to check vars types
import { is, getType } from './type.js'
const isFields = (fields) => values.every((field) => is(field, 'Object'))
const getName = (value) => {
const names = {
'String': () => value,
'Number': () => `Number ${value}`,
'Array': () => `List (${value.join(', ')})`
}
@VitorLuizC
VitorLuizC / breakpoint.js
Last active January 10, 2017 19:27
Simple module to watch media queries in JavaScript
const points = {
print: 'print',
xs: 'screen',
sm: '48rem',
md: '64rem',
lg: '75rem'
};
/**
* Launch callback when breakpoint start/stop working.
@VitorLuizC
VitorLuizC / create-service.js
Last active March 8, 2017 15:22
Node.js simple service. Run a callback in an interval.
class Service {
/**
* Creates a new service.
* @param {function} service
* @param {number} time Time interval in minutes.
*/
constructor(service, time) {
const MINUTE = 1000 * 60;
this.time = MINUTE * time;
@VitorLuizC
VitorLuizC / ie.pug
Created March 16, 2017 18:15
HTML IE Conditionals + Pug / Jade
mixin ie(method, version)
-
version = (typeof version === 'number') ? `IE ${version}` : 'IE';
method = method || '==';
var condition = '';
switch (method) {
case '==':
condition = version;
@VitorLuizC
VitorLuizC / available.js
Created April 12, 2017 15:42
Continuous check connection
const available = (function () {
const url = `//${location.hostname}:${location.port}/ok`
const available = {
isAvailable: false,
onChange: () => undefined
}
check()
function check() {
@VitorLuizC
VitorLuizC / animate.js
Created April 22, 2017 05:34
Simple way to handle a animation loop
/**
* @typedef Animation
* @property {function} animation
*/
/**
* Create a new animation object.
* @param {function} animation
* @returns {Animation}
*/
@VitorLuizC
VitorLuizC / data.json
Last active May 10, 2017 23:05
Todos o municípios de São Paulo em JSON
[
"Adamantina",
"Adolfo",
"Aguaí",
"Águas da Prata",
"Águas de Lindóia",
"Águas de Santa Bárbara",
"Águas de São Pedro",
"Agudos",
"Alambari",
@VitorLuizC
VitorLuizC / package.json
Last active August 9, 2017 13:48
Webpack hangs on building modules
{
"name": "landing-page-unopar",
"version": "0.0.1",
"description": "Landing Page de Unopar.",
"private": true,
"author": "Vitor Cavalcanti",
"maintainers": [],
"license": "MIT",
"keywords": [
"landing-page",
const levelup = require('levelup')
const { NotFoundError } = require('level-errors')
const database = levelup('./app/database', { createIfMissing: true })
/**
* Opções do repositório.
* @typedef RepositoryOptions
* @type {Object}
* @property {*} initialValue