Skip to content

Instantly share code, notes, and snippets.

View iamtchelo's full-sized avatar

Marcelo Silva iamtchelo

  • Brazil - São Paulo
View GitHub Profile
@iamtchelo
iamtchelo / UIVisualEffect.swift
Created August 6, 2017 22:14 — forked from oboje/UIVisualEffect.swift
(Ab)using UIVisualEffectView effect settings
extension UIVisualEffectView {
private var filterLayer: CALayer? {
return layer.sublayers?.first
}
private var blurFilter: NSObject? {
return filterLayer?
.filters?.flatMap({ $0 as? NSObject })
.first(where: { $0.value(forKey: "name") as? String == "gaussianBlur" })
@iamtchelo
iamtchelo / gist:3d2f0d1b134dfb103247
Created May 26, 2015 11:34
Responsive flex navigation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flex Navigation with CSS3</title>
<style>
* {
margin: 0;
padding: 0;
}
@iamtchelo
iamtchelo / config.sh
Created November 3, 2014 15:08
A simple shell file to configure a server
#!/bin/bash
sudo apt-get update
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install mysql-server
sudo apt-get install phpmyadmin
@iamtchelo
iamtchelo / gist:1944d411b52cbfa2abb9
Last active August 29, 2015 14:08 — forked from netojoaobatista/gist:6703131
Regular Expression
<?php
$string = '04/09/2013 VANESSA RAFFLER 5199060 28/08/2013 13:40 EMISSAO CO IBITINGA 01 28/08/2013 18:58 TRANSFERENCIA TECA JAD SAO 29/08/2013 00:23 ENTRADA TECA JAD SAO 29/08/2013 02:50 TRANSFERENCIA CO CURITIBA 01 29/08/2013 10:23 TRANSFERENCIA CO UNIAO DA VITORIA 01 29/08/2013 20:20 TRANSFERENCIA CO CURITIBA 01 29/08/2013 23:52 TRANSFERENCIA CO CURITIBA 01 30/08/2013 06:50 TRANSFERENCIA CO UNIAO DA VITORIA 01 30/08/2013 12:44 TRANSFERENCIA CO CHAPECO 01 02/09/2013 08:01 ENTRADA CO CHAPECO 01 02/09/2013 09:50 EM ROTA CO CHAPECO 01 03/09/2013 09:22 ENTREGUE CO CHAPECO 01 03/09/2013 09:26 ENDERECO NAO LOCALIZADO CO CHAPECO 01 04/09/2013 09:40 EM ROTA CO CHAPECO 01 05/09/2013 09:06 ENTREGUE CO CHAPECO 01';
if (preg_match_all('/[^\s].*?(?=\d{2}\/\d{2}\/\d{4})/', $string, $matches)) {
$limit = 3;
$page = (isset($_GET['page'])) ? $_GET['page'] : (int) 1;
$split_data = array_chunk($matches[0], $limit);
$total_page = count($split_data);
$result = $split_data[$page-1];
@iamtchelo
iamtchelo / paginator.phtml
Last active August 29, 2015 14:06
A simple paginator with ZF2 and Bootstrap
<?php if ($this->pageCount): ?>
<ul class="pagination">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<li><a href="<?php echo $this->url($this->route, array('controller' => $this->controller, 'page' => $this->previous)); ?>">&laquo;</a></li>
<?php else: ?>
<li class="disabled"><a>&laquo;</a></li>
<?php endif; ?>
@iamtchelo
iamtchelo / server.js
Created July 3, 2014 14:15
Create a simple server with express.js
var express = require('express');
var app = express();
var port = process.env.PORT || 8080;
// routes
app.get('/test', function(request, response) {
response.send('Test router!');
});
// router with params
<?php
class Math
{
public function sum($a, $b)
{
if (!is_numeric($a) || !is_numeric($b)) {
throw new InvalidArgumentException('Invalid Numbers');
}
// sum
$result = $a + $b;
<?php
class Eclesiasticos
{
private $ano;
private $pascoa;
public function __construct($ano)
{
$this->ano = (int) $ano;
}