Skip to content

Instantly share code, notes, and snippets.

@alganet
alganet / greppy.php
Last active August 30, 2017 13:38
Greppy
<?php
// Simple empty matching. Explains a lot of how the idea works:
//
// By default, expressions are delimited by a line, which
// implies /^$/. Everything goes inside that. Calling nothing
// else more matches any line.
//
// p() is a function call. Could be Pattern::create(), but I
// believe providing a function is sane. It can be provided
@alganet
alganet / streams_respect.md
Last active July 3, 2020 18:50
Respect Prático: Streams

Respect Prático: Streams

Agora que você já viu como trabalhar com streams no PHP, vou mostrar um pouco do suporte a streams do Respect!

Respect\Rest

O Respect\Rest foi o primeiro projeto PHP a suportar o controle de rotas com streaming e é o mais completo nisso. Fazer o stream de qualquer coisa é simples.

@andelf
andelf / sendMail.go
Last active March 21, 2025 03:36
golang send mail net/smtp SMTP
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"
@alganet
alganet / php_pratico_streams.md
Last active August 15, 2021 20:41
PHP Prático: Streams

PHP Prático: Streams

A palavra stream significa corrente. Em geral, qualquer conexão de rede é uma stream, e existem vários tipos de protocolos para streams. Esses protocolos definem como os dados fluem na corrente.

No PHP, vários protocolos são suportados de forma transparente:

<?php
@nikicat
nikicat / git2dch.sh
Last active August 29, 2021 12:00
Shell script to regenerate debian changelog from git log
#!/bin/sh
sudo apt-get install -y moreutils git-buildpackage
>debian/changelog
prevtag=initial
pkgname=`cat debian/control | grep '^Package: ' | sed 's/^Package: //'`
git tag -l v* | sort -V | while read tag; do
(echo "$pkgname (${tag#v}) unstable; urgency=low\n"; git log --pretty=format:' * %s' $prevtag..$tag; git log --pretty='format:%n%n -- %aN <%aE> %aD%n%n' $tag^..$tag) | cat - debian/changelog | sponge debian/changelog
prevtag=$tag
@benbahrenburg
benbahrenburg / app.js
Last active December 10, 2015 03:28
Luhn Credit Card Validation algorithm implemented as CommonJS module
/*jslint maxerr:1000 */
var my = {tools:{}};
//Import our module into our project
my.tools.cardHelper = require('credit_card_helper');
//Our test credit card number that we got from http://www.getcreditcardnumbers.com/
var testCreditCardNumber ="49713268648235453";
//Call our verify method to check if our credit card number is in a correct format
var ccCheck = my.tools.cardHelper.verifyCardWithLuhn(testCreditCardNumber);
//alert the result back to the user
alert(ccCheck);
@rdohms
rdohms / MyAbstractType.php
Created December 5, 2012 15:22
Binding Events in Parent Form
<?php
abstract class MyAbstractType extends AbstractType
{
/** CODE */
}
@alganet
alganet / phpeficiente.md
Created November 24, 2012 03:19
PHP Eficiente

PHP Eficiente

Um hbook para qualquer programador.

Rascunho, links provavelmente estão quebrados.

Olá Mundo!

@netojoaobatista
netojoaobatista / Example.php
Created November 14, 2012 16:25
To mock or not to mock, that is the question
<?php
class Example {
public function getInsertSQL() {
return 'INSERT INTO `example` (
`email`,
`name`
) VALUES (
:email,
:name
);';
<?php
namespace Admin\Controller;
use Zend\View\Model\ViewModel;
use Core\Controller\ActionController;
use Admin\Model\User;
use Admin\Form\User as UserForm;
use Doctrine\ORM\EntityManager;