Skip to content

Instantly share code, notes, and snippets.

View deyvin's full-sized avatar
🏠
Working from home

Deyvid Nascimento deyvin

🏠
Working from home
View GitHub Profile
@deyvin
deyvin / dynamic_thumbnail_with_php.php
Created January 14, 2013 16:27
This script is a perfect method to create thumbnail with uploaded images. Enjoy us!
<?php
# ----------------------------------------------------------------------
# DFN Thumbnailer
# http://www.digifuzz.net
# digifuzz@gmail.com
# ----------------------------------------------------------------------
# Constants
<?php
$bebeu_agua = "Não";
$ta_com_sede = "To";
if($bebeu_agua == "Não") {
if($ta_com_sede == "To") {
echo "Água, Água, Água mineral, Água mineral...";
}
}
@deyvin
deyvin / ecommerce.rb
Last active December 20, 2015 02:29
Script para pesquisar preço dos ecommerce a partir do código interno do produto
require 'nokogiri'
require 'open-uri'
require 'mysql2'
class Ecommerce
attr_accessor :id, :name, :price, :bank_price, :con
@@con = Mysql2::Client.new(:host => 'localhost', :username => 'root', :password => '1234', :database => 'ecommerce')
def acessar_site(url)
Nokogiri::HTML(open(url, :proxy_http_basic_authentication => ['http://192.168.254.200:8080', 'deyvin', 'fdcsistemas123'] ))
@deyvin
deyvin / mysql_count_all_tables.php
Created October 17, 2013 21:02
Dynamic sql count - all mysql database tables
<?php
mysql_connect("localhost", "root", "1234");
$banco = 'ecommerce';
$db_selected = mysql_select_db($banco);
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_assoc($result)) {
<?php
define('TOTALAPLICADO', 1000);
define('PERC_RENDIMENTO', 15);
define('DIAS', 31);
$total_por_dia = ((TOTALAPLICADO * PERC_RENDIMENTO) / 100) / DIAS;
@deyvin
deyvin / acrescimo.php
Last active January 4, 2016 03:39
Como chegar a um valor de acréscimo aplicando um percentual de desconto para chegar ao valor fixo.
<?php
$valor_desejado = 500;
$percentual = 20;
echo ($valor_desejado * 100) / (100 − $percentual);
<?php
$db = ibase_connect ('localhost:/usr/db/db.gdb', 'SYSDBA', 'masterkey');
$tr = ibase_trans( IBASE_DEFAULT, $tr ); #abre a transação do firebird
$insert = "INSERT INTO CLIENTES (ID, NOME) VALUES (1, 'JOSE')";
ibase_query($tr, $insert);
$insert = "INSERT INTO CLIENTES (ID, NOME) VALUES (1, 'JOSE')";
@deyvin
deyvin / jquery.serialize_replace.js
Created March 2, 2012 14:13
Forçar serialize() do jQuery reconhecer checkboxes mesmo não marcado
$(function() {
$.fn.serialize = function (options) {
return $.param(this.serializeArray(options));
};
$.fn.serializeArray = function (options) {
var o = $.extend({
checkboxesAsBools: false
}, options || {});
server {
root /var/www/promo;
index index.php index.html index.htm;
server_name example.com.br;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$args;
}
@deyvin
deyvin / get_remote_file_titanium_mobile.js
Created March 27, 2012 13:45
Get remote file with Titanium Mobile
function get_remote_file(filename, url, fn_end, fn_progress ) {
Ti.API.info("[filename]" + filename);
Ti.API.info("[url]" + url);
var file_obj = {file:filename, url:url, path: null};
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,filename);
if ( !file.exists() ) {