Skip to content

Instantly share code, notes, and snippets.

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

Luis Naia lnaia

🏠
Working from home
View GitHub Profile
@lnaia
lnaia / sample.html
Created October 1, 2015 21:56
simple xhr post w/ jquery Raw
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>example</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
</head>
<body>
@lnaia
lnaia / sample_output.txt
Last active September 16, 2015 08:40
Text metadata generator
+--------------------------------------------+--------+
| Metadata |
+--------------------------------------------+--------+
| Type | Result |
+--------------------------------------------+--------+
| number_of_words | 454 |
| number_of_characters | 3150 |
| number_of_characters_excluding_white_space | 2690 |
| number_of_sentences | 54 |
| number_of_paragraphs | 5 |
@lnaia
lnaia / word_histogram.rb
Created August 18, 2015 12:11
Display top 10 words, % and also a histogram distribution.
#!/usr/bin/ruby
#encoding: UTF-8
require 'terminal-table'
require 'histogram/array'
# Usage:
# echo "a e i o u" | word_histogram
top_words = 10
@lnaia
lnaia / pdo.php
Created July 23, 2015 11:33
php pdo example
<?php
define("DB_DSN", "mysql:host=localhost;dbname=DATABASE_NAME_GOES_HERE");
define("DB_USERNAME", "");
define("DB_PASSWORD", "");
// Example usage
function mysql_custom_query()
{
@lnaia
lnaia / time-ago.filter.js
Last active September 16, 2015 08:31
Angular JS time-ago.filter.js
angular.module('app')
.filter('timeAgo', function() {
return function(input) {
var res = '',
day = 24 * 60 * 60 * 1000,
hour = 60 * 60 * 1000,
minute = 60 * 1000,
second = 1000,
difference = new Date() - new Date(input);
@lnaia
lnaia / hosts_config.js
Last active September 16, 2015 08:34
Hosts module config
(function() {
'use strict';
angular
.module('edustorage.hosts')
.config(configure);
configure.$inject = ['$routeProvider'];
function configure($routeProvider) {
@lnaia
lnaia / requests_config.js
Last active September 16, 2015 08:34
Requests config
(function() {
'use strict';
angular
.module('edustorage.requests')
.config(configure);
configure.$inject = ['$routeProvider'];
function configure($routeProvider) {
@lnaia
lnaia / index.html
Last active August 29, 2015 14:22 — forked from csusbdt/index.html
How to save json to drive
<html>
<head>
<!--
In this example, I started with the 5-minute example provided by Google
on the following page:
https://developers.google.com/drive/
I modified the example code, so that I could write the following
@lnaia
lnaia / paginator.php
Last active September 16, 2015 08:35
JR - php
<?php
function getPaginator($current_page, $total_pages, $boundaries, $around) {
$paginator = array();
$suspensionPoints = false;
$paginator[$total_pages] = null;
$paginator[$current_page] = null;
@lnaia
lnaia / paginator.rb
Created June 5, 2015 14:56
Sapo exercice in ruby
require "awesome_print"
def pagination(current_page, total_pages, boundaries, around)
elements = []
# add boundaries elements
(1..boundaries).to_a.each { |val|
elements.push(val)
elements.push(total_pages-val+1)
}