Skip to content

Instantly share code, notes, and snippets.

View jonasporto's full-sized avatar
⌨️
Working and having fun!

Jonas Porto jonasporto

⌨️
Working and having fun!
  • Rio de Janeiro, Brazil
View GitHub Profile
@jonasporto
jonasporto / heroku_rails_phantomjs.md
Created February 4, 2016 21:08 — forked from edelpero/heroku_rails_phantomjs.md
Heroku, Ruby on Rails and PhantomJS

#Heroku, Ruby on Rails and PhantomJS

In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).

Let’s get started. This is a high-level overview of the required steps:

  • Modify your app to use multiple Heroku buildpacks.
  • Extend your app to use both the Ruby as well as the PhantomJS buildpacks.
  • Confirm that everything worked.
@jonasporto
jonasporto / tinder-api-documentation.md
Created January 31, 2016 17:02 — forked from rtt/tinder-api-documentation.md
Tinder API Documentation

Tinder API documentation

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

Note: this was written in April/May 2014 and the API may have changed since

API Details

capturaEnderecoUsuario: function() {
var me = this;
/**
* Quando o javascript olha pra Ext.Ajax.request,
* ele não tem como prever quando isso retornar.
* Por ser uma requisição externa pode ser muito rápido ou demorar muito por demandar processamento.
* Então, como ele resolve isso ?
* Ele te promete(promisse) que vai te dar uma resposta de sucesso(success) ou erro(failure) assim que acabar a requisição.
* e passa para o proximo passo sem bloquear seu codigo.
public function temAlcada(Usuario $usuario, $cliente_id, $returnMessage = false)
{
$indicadoresAtivos = TsIndicador::model()->ativos()->orderAsc()->findAll();
foreach ($indicadoresAtivos as $indicador) {
$indicadorContrato = $indicador->calculate($this, ['cliente_id' => $cliente_id]);
$indicadorProjeto = $indicador->valor_indicador;
$alcadaUsuario = TsAlcadaLiberacaoAcordo::model()->find();
if(!$alcadaUsuario) {
@jonasporto
jonasporto / gist:0c3e2a5460f2edb27e79
Created April 3, 2015 16:26
ODESK PHP If / Else Script
<?php
$array_of_zips = [53005, 53007, 53008, 53018, 53029, 53045, 53046, 53051, 53052, 53056, 53058, 53064, 53066, 53069, 53072, 53089, 53103, 53118, 53119, 53122, 53127, 53146, 53149, 53150, 53151, 53153, 53183, 53186, 53187, 53188, 53189];
$zip_parameter = $_GET['zip'];
$executeScript = 'script2';
if (in_array($zip_parameter, $array_of_zips)) {
$executeScript = 'script1';
@jonasporto
jonasporto / gist:4aca9f5c3b19800e2200
Created February 11, 2015 20:48
Multiplas maquinas com diferentes ips
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
end
config.vm.define :apache do |a_config|
a_config.vm.box = "ubuntu-i386"
function importTagToHead(tag){
var head = document.getElementsByTagName('head')[0];
head.appendChild(tag);
}
@jonasporto
jonasporto / gist:33c6b744e4f04a8b4bfa
Last active August 29, 2015 14:11
url query php
function url_query(){
$this->autoRender = false;
extract($this->params['named']);
$model = ClassRegistry::init($model);
if($conditions) $options['conditions'] = $conditions;
if($contain) $options['contain'] = explode(' ',$contain);
function altera_cpf(){
$pfs = $this->PessoasFisica->find('all',array('fields'=>array('cod_pessoa_fisica','cpf'),'recursive'=>-1));
//select * from pessoas_fisicas pf,pessoas_fisicas pfi where sem_pontuacao(pf.cpf) = sem_pontuacao(pfi.cpf) and pf.cod_pessoa_fisica != pfi.cod_pessoa_fisica;
foreach($pfs as $k => $pf){
if(strlen($pf['PessoasFisica']['cpf']) < 14){
$pfs[$k]['PessoasFisica']['cpf'] = $this->mask(str_replace(array('.','-'),'',$pf['PessoasFisica']['cpf']),'###.###.###-##');
$this->PessoasFisica->create();
$this->PessoasFisica->save($pfs[$k]);
}
}
@jonasporto
jonasporto / gist:27d3e15d9d2e19a670c6
Last active August 29, 2015 14:11
range javascript
var range = function(from,to){ var result = []; while (from < to) result.push(from++); return result; }