Skip to content

Instantly share code, notes, and snippets.

View oscarr-reyes's full-sized avatar

Oscar Reyes oscarr-reyes

  • Colombia Medellin
View GitHub Profile
@oscarr-reyes
oscarr-reyes / diet_static-vs-diet_static_stream.json
Created August 2, 2016 08:01
Benchmark comparison between diet-static and diet-static-stream
{
"benchmark": {
"Resolve time":{
"diet-static":{
"small - 1mb":{
"test #1": "1.126ms",
"test #2": "0.824ms",
"test #3": "0.698ms",
"test #4": "0.611ms",
"test #4": "0.488ms"
var cy = cytoscape({
container: document.getElementById("cy"),
elements: [
// nodes
{data: {id: "a", name:"1"}},
{data: {id: "b", name:"2"}},
{data: {id: "c", name:"3"}},
{data: {id: "d", name:"4"}},
{data: {id: "e", name:"5"}},
{data: {id: "f", name:"6"}},
@oscarr-reyes
oscarr-reyes / ng-restful.js
Last active September 11, 2016 22:01
ngRestful usage example
var app = angular.module("example", ["ngRestful"]);
// Define global domain for resource
app.config(["ngRestful", function($restful){
$restful.setDomain("http://localhost/tree/server");
}]);
app.controller("exampleController", ["$resource", function($resource){
// Domain is already defined, accounts will be appended with the domain url
var resource = new $resource("accounts");
@oscarr-reyes
oscarr-reyes / accounts.factory.js
Created September 19, 2016 22:32
Factory example using ngrestful
(function() {
'use strict';
// Pass the accountsFactory to the app
angular
.module('y')
.factory('accountsFactory', accountsFactory);
// Define the accountsFactory
function accountsFactory($resource) {
(function() {
'use strict';
// Pass the userService to the app
angular
.module('y')
.factory('userService', userService);
-- MySQL dump 10.13 Distrib 5.6.31, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: tree
-- ------------------------------------------------------
-- Server version 5.6.31-0ubuntu0.15.10.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
var diet = require("diet");
var app = diet();
app.listen(8000);
require("./index.js")(app);
var data = {
"id": "3",
"create_at": "2016-10-15 05:28:10",
"account": {
"username": "mgrantbt"
},
"ticket": {
"status_id": "2"
},
"amount": {
@oscarr-reyes
oscarr-reyes / linkService.js
Created January 19, 2018 02:02
Link preview service for Angular.js
app.factory("$Link", function($q, $http){
var LINKREGEX = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+ = &%@!\-\/]))?/g;
var YOUTUBEREGEX = /(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'<> #]+)/;
var IMAGEREGEX = /(.+\w+\.(png|jpg|jpeg|ico|svg)$)/;
var SERVICE = "https://api.linkpreview.net";
var KEY = "<api-key>";
var $Link = {};
/**
* Verifies if the provided text contains a link
@oscarr-reyes
oscarr-reyes / file.js
Last active September 25, 2018 04:14
Get stats for all directories in a path
const fs = require("fs");
const path = require("path");
const pathDir = "C:/Users/Oscar/Downloads";
const dirs = fs.readdirSync(pathDir);
dirs.forEach(async dir => {
const stats = await readStats(path.resolve(pathDir, dir));