Skip to content

Instantly share code, notes, and snippets.

Oscar Reyes oscarr-reyes

Block or report user

Report or block oscarr-reyes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@oscarr-reyes
oscarr-reyes / ProtectedRoute.js
Created Mar 11, 2019
Flow throws error for rendering Component passed from a prop
View ProtectedRoute.js
// @flow
import React, { Component } from "react";
import { Redirect, Route } from "react-router-dom";
import CookieStorage from "./../services/CookieStorage";
import type { Component as ComponentType } from "react";
type Props = {
component: ComponentType<any, any>
}
@oscarr-reyes
oscarr-reyes / file.js
Last active Sep 25, 2018
Get stats for all directories in a path
View file.js
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));
@oscarr-reyes
oscarr-reyes / linkService.js
Created Jan 19, 2018
Link preview service for Angular.js
View linkService.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
View tree.js
var data = {
"id": "3",
"create_at": "2016-10-15 05:28:10",
"account": {
"username": "mgrantbt"
},
"ticket": {
"status_id": "2"
},
"amount": {
View app.js
var diet = require("diet");
var app = diet();
app.listen(8000);
require("./index.js")(app);
View bill_has_bill.sql
-- 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 */;
View userService.js
(function() {
'use strict';
// Pass the userService to the app
angular
.module('y')
.factory('userService', userService);
@oscarr-reyes
oscarr-reyes / accounts.factory.js
Created Sep 19, 2016
Factory example using ngrestful
View accounts.factory.js
(function() {
'use strict';
// Pass the accountsFactory to the app
angular
.module('y')
.factory('accountsFactory', accountsFactory);
// Define the accountsFactory
function accountsFactory($resource) {
@oscarr-reyes
oscarr-reyes / ng-restful.js
Last active Sep 11, 2016
ngRestful usage example
View ng-restful.js
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");
View cytoscape-data.js
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"}},
You can’t perform that action at this time.