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
@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 / _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
/**
* download de um arquivo
*
* @param {Blob} file
* @example
* ...
* exec(response.data)
* ...
*/
function exec(file, type = "text/csv") {
@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 {
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";
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
angular
.module('home', [])
.controller('home_ctrl', function ($scope, $q, $http) {
$scope.title = 'Home';
let vm = $scope;
let cancelador = $q.defer();
vm.buscar = () => {
<?php
// intervalo de datas
// 1 day
// 30 minutes
$d1 = '2019-01-01';
$d2 = '2019-01-20';
$i = 0;
while ($d1 <= $d2) {
// echo $i. '<br>';
<?php
define('DRIVER', 'pgsql');
define('HOST', 'localhost');
define('USER', 'postgres');
define('PASS', 'a0l11e4x23');
define('DATABASE', 'alexalannunes');
define('OPTIONS', array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
sudo apt install xserver-xorg-core && sudo apt install xorg-input-abi-22 && sudo apt install xserver-xorg-input-libinput