Skip to content

Instantly share code, notes, and snippets.

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

Ever Daniel Barreto everdaniel

🏠
Working from home
View GitHub Profile
@everdaniel
everdaniel / delphi.rb
Created May 6, 2013 14:45
Generate a CSV file with all projects listed at Embarcadero App Showcase
require "mechanize"
require "csv"
agent = Mechanize.new
page = agent.get("http://www.embarcadero.com/index.php?option=com_mmportfolio&view=projects&layout=appshowcase&format=raw")
projects = []
page.search("div.appitem").each do |item|
puts "Fetching: " + item.text
id = item["rel"]
name = item.text
@everdaniel
everdaniel / gist:5849900
Created June 24, 2013 13:07
PostgreSQL PL/PgSQL Trigger example
-- Function: im_detalle_1_actualiza_ingreso()
-- DROP FUNCTION im_detalle_1_actualiza_ingreso();
CREATE OR REPLACE FUNCTION im_detalle_1_actualiza_ingreso()
RETURNS trigger AS
$BODY$
DECLARE
-- Declaramos las variables con el mismo tipo del definido en la tabla
iva_5 ingreso_mercaderia.im_impuesto_5%TYPE;
@everdaniel
everdaniel / gist:5943969
Created July 7, 2013 16:22
JS Config Object in Header / CodeIgniter
<script type="text/javascript">
/* <![CDATA[ */
// Global My App Namespace
window.myapp = window.myapp || {};
// AJAX Namespace
myapp.ajax = myapp.ajax || {};
myapp.ajax.csrf = '98dd0f785e';
myapp.ajax.paths = {
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
<?php
//Pull historical daily; assumes that historical has at least as many years as the generated.
$sql = "select * from verde_historical_daily where year <= :year";
$core = Core::getInstance();
$stmt = $core->dbh->prepare($sql);
$stmt->bindParam(':year', $totalYears, PDO::PARAM_INT);
try {
$stmt->execute()
Script baseLineData execution took 0.31350111961365 seconds <br />Array
(
[0] => Array
(
[0] => 21
[1] => 21
[2] => 21
[3] => 21
[4] => 21
[5] => 21
Script baseLineData execution took 0.33139801025391 seconds <br />Array
(
[1] => Array
(
[6] => Array
(
[median] => 19
[minimum] => 18
[maximum] => 22
)
Script baseLineData execution took 0.32932496070862 seconds <br />Array
(
[1] => Array
(
[6] => Array
(
[213] => 19
[183] => 22
[184] => 22
[185] => 21
Array
(
[0] => Array
(
[high_rva] => Array
(
[0] => stdClass Object
(
[demand_id] => 22
[si] => 0.41666666666667
Array
(
[0] => Array
(
[high_rva] => Array
(
[0] => stdClass Object
(
[22] => 0.41666666666667
)