Skip to content

Instantly share code, notes, and snippets.

View proclnas's full-sized avatar
💡
Working

Rodrigo Nas proclnas

💡
Working
View GitHub Profile
@proclnas
proclnas / bitbucket-pipelines.yml
Created March 1, 2019 19:04 — forked from mcnamee/bitbucket-pipelines.yml
Bitbucket Pipelines - Deploy via FTP to shared hosting
# Installation ---
# 1. In Bitbucket, add $FTP_USERNAME $FTP_PASSWORD and $FTP_HOST as environment variables.
# 2. Commit this file to your repo
# 3. From Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:Init (this will
# push everything and initial GitFTP)
#
# Usage ---
# - On each commit to master branch, it'll push all files to the $FTP_HOST
# - You also have the option to 'init' (from Bitbucket Cloud) - pushes everything and initialises
# - Finally you can also 'deploy-all' (from Bitbucket Cloud) - if multiple deploys fail, you
# Geral
du -cha --max-depth=1 / | grep -E "M|G"
# By dir
du -cha --max-depth=1 /var | grep -E "M|G"
@proclnas
proclnas / expo-get-ip.php
Created October 1, 2018 17:45
expo-get-ip.php
<?php
// REACT_NATIVE_PACKAGER_HOSTNAME=$(ifconfig | awk '/wlp2s0/{getline; print}' | php get-ip.php) npm start
echo array_values(
array_filter(
explode(' ', fgets(STDIN)),
function($var){
if (
preg_match('#\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b#',
$var,
$match)
(ns http)
(defn http-get [url]
(def client (java.net.URL. url))
(def response (slurp (.openStream client)))
(println response))
(http-get "http://proclnas.github.io")
<?php
// Exemplo de refatoraço
interface Style {}
interface PptStyle extends Style {}
interface PdfStyle extends Style {}
class Style {
// Propriedades
<?php
// Forma procedural
function getPdoHandle() { /* ... */ }
function fetchAll($handle, $tabela) {
// Whitelist simples de tabelas permitidas
$tabelasPermitidas = ['produtos', 'lojas', 'marcas'];
if (!in_array($tabela, $tabelasPermitidas)) return false;
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
<?php
/**
* Monta string à partir de um array de chave/valor
*/
// rodrigo@blue-wind[~/repositorios/php] $ php reduce.php
// <a href="http://google.com" id="java" class="php"/>
$a = [
<?php
$request = ['id_usuario' => 1, 'id_campo' => 2, 'id_loja' => 3, 'id_campanha' => 4];
$colunasModelA = ['id_usuario', 'id_campo'];
$colunasModelB = ['id_loja', 'id_campanha'];
$dadosParseados = [
'modelA' => [],
'modelB' => []
];
<?php
// run with php7
// php ex-pthreads.php -t thread
$opt = getopt('t:');
if (!isset($opt['t']))
exit (sprintf('php %s -t threads' . PHP_EOL, $argv[0]));
$myArray = [
'http://wikipedia.org',
'http://yahoo.com',