Skip to content

Instantly share code, notes, and snippets.

Sergio Melendez helpse

View GitHub Profile
@helpse
helpse / index.html
Created Mar 16, 2018
Next.JS + Django
View index.html
{% load static %}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
@helpse
helpse / webpack.config.js
Created Apr 1, 2017
Webpack + dev server + hot reloading + pug + sass
View webpack.config.js
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var src = path.join(__dirname, 'src');
var config = {
devServer: {
hot: true,
View Finances.rb
class Finances
@@sum = 0
def self.get_orders
Order.where(state: [1, 2, 3, 4])
end
def self.get_bids
BidRequest.where(state: [1, 2, 3, 5])
View queryString.js
/**
* queryString handler
* by Sergio Melendez
*
* Usage:
* url = location.pathname + getQuery().set('foo', 'bar').remove('baz');
*/
function getQuery() {
var data = {};
@helpse
helpse / TreeArray.php
Last active Nov 17, 2015
Get a tree from an array and indicators
View TreeArray.php
<?php
/**
* Author: Sergio Melendez
* www.inspiredsolutions.pe
*
* Usage:
* $data = TreeArray::factory($array, $indicators)->get();
*
* Input: [['a': 1, 'b': 2],['a': 1, 'b': 3]]
* Input: ['a']
View fuzzytime.py
import datetime
def prettydate(d):
diff = datetime.datetime.utcnow() - d
s = diff.seconds
if diff.days > 7 or diff.days < 0:
return d.strftime('%d %b %y')
elif diff.days == 1:
return '1 day ago'
elif diff.days > 1:
return '{} days ago'.format(diff.days)
View prueba.php
<?php
$server = $_SERVER['SERVER_NAME'];
$host = 'http://200.48.11.178';
$clientCarroceria = new SoapClient($host."/webservices/carroceria.php?wsdl");
var_dump($clientCarroceria);
//die();
View kohana.md

Favourite Kohana Tips

Passing a route as array

    $this->redirect($this->request->route()->uri(array(
				'controller' => 'welcome',
				'action' => 'home',
			)));
@helpse
helpse / Odbc.php
Last active Dec 28, 2015 — forked from ceeram/Odbc.php
ODBC for DBO Modified by Sergio Melendez It works for a Linux / Apache / PHP / PDO_ODBC / ODBC / MSSQL environment The PDO driver provided by Microsoft for Linux, doesn't implement some PDO methods, you have to modify Model.php and DboSource.php as well (You can ask me for details)
View Odbc.php
<?php
/**
* ODBC for DBO
* Modified by Sergio Melendez
*
* It works for a Linux / Apache / PHP / PDO_ODBC / ODBC / MSSQL environment
* The PDO driver provided by Microsoft for Linux, doesn't implement some PDO methods,
* you have to modify Model.php and DboSource.php as well (You can ask me for details)
*
* PHP versions 4 and 5
You can’t perform that action at this time.