Skip to content

Instantly share code, notes, and snippets.

View alexalannunes's full-sized avatar
👨‍💻
I'm coding

Alex Alan Nunes alexalannunes

👨‍💻
I'm coding
View GitHub Profile
angular
.module('home', [])
.controller('home_ctrl', function ($scope, $q, $http) {
$scope.title = 'Home';
let vm = $scope;
let cancelador = $q.defer();
vm.buscar = () => {
vm.count = function() {
var root = angular.element(document.getElementsByTagName("body"));
var watchers = [];
var f = function(element) {
angular.forEach(["$scope", "$isolateScope"], function(scopeProperty) {
if (element.data() && element.data().hasOwnProperty(scopeProperty)) {
angular.forEach(element.data()[scopeProperty].$$watchers, function(
watcher
function prettyPrintNumber(number) {
var numberString;
var scale = "";
if (isNaN(number) || !isFinite(number)) numberString = "N/A";
else {
var negative = number < 0;
number = negative ? -number : number;
if (number < 1E3) scale = "";
else if (number < 1E6) {
scale = "K";
@alexalannunes
alexalannunes / mesComercial.php
Created February 1, 2020 17:56 — forked from franciscopessoa/mesComercial.php
Calcular mês comercial, 26 a 25
<?php
function dataCompetencia($data)
{
$dia = (int) substr($data, 8, 2);
$AnoMes = substr($data, 0, 7);
if ($dia >= 26) {
$date['inicial'] = $AnoMes . '-26';
$date['final'] = date('Y-m', strtotime('+ 1 Month', strtotime($AnoMes))) . '-25';
} else {
/**
* download de um arquivo
*
* @param {Blob} file
* @example
* ...
* exec(response.data)
* ...
*/
function exec(file, type = "text/csv") {
@alexalannunes
alexalannunes / _treat_model_form.ng.js
Last active May 26, 2020 20:55
Tratar model (angularjs) no qual os campos precisam ser enviados, mesmo sento nulls ou [ ]. Ideal para métodos GET ou DELETE
function _treat_model_form() {
let model = angular.copy(vm.filter);
for (let m in model) {
const value = model[m];
model[m] =
value == null || value.length == 0
? ""
: Array.isArray(value)
? value.join(",") // para metodos GET|DELETE
@alexalannunes
alexalannunes / app.panGestureHandler.js
Created June 30, 2020 00:04
A simple react native draggable card (down | up)
import { StatusBar } from "expo-status-bar";
import React, { useEffect } from "react";
import { StyleSheet, Text, View, Animated, Easing } from "react-native";
import { PanGestureHandler, State } from "react-native-gesture-handler";
export default function App() {
let offset = 0;
let y = new Animated.Value(0);
const _onPanGestureEvent = Animated.event([{ nativeEvent: { translationY: y } }], { useNativeDriver: false });
@alexalannunes
alexalannunes / touchpad-gnome.sh
Last active July 1, 2020 14:47
enable ubuntu gnome touchpad
sudo apt install xserver-xorg-core && sudo apt install xorg-input-abi-22 && sudo apt install xserver-xorg-input-libinput
@alexalannunes
alexalannunes / getFields.js
Last active July 10, 2020 18:44
get specific properties from object
const getFields = (obj, ...keys) => keys.reduce((a, c) => ({ ...a, [c]: obj[c] }), {});
var person = {
id: 23892,
name: 'Alex',
pic: 'image.jpeg'
}
getSubset(person, 'id', 'name');
@alexalannunes
alexalannunes / README.md
Created September 1, 2020 17:02 — forked from MauricioAires/README.md
Documentação sobre CRONTAB, tudo sobre o que, para que serve, variáveis e como utilizar.

CRONTAB

O que é o crontab

Traduzido do inglês-O utilitário de software cron é um agendador de tarefas baseado em tempo em sistemas operacionais de computador tipo Unix. Os usuários que configuram e mantêm ambientes de software usam o cron para agendar tarefas para serem executadas periodicamente em horários, datas ou intervalos fixos.

A maioria das distrubuições Linux já vem com o cron instalado e conficurado para verificar se o cron já está funcionando é só rodar o comando.

Verificar status do cron