Skip to content

Instantly share code, notes, and snippets.

View turizoft's full-sized avatar
👨‍💻

Nestor Turizo Jimenez turizoft

👨‍💻
View GitHub Profile
import clsx from 'clsx';
import React, {
SyntheticEvent, useCallback, useEffect, useMemo,
} from 'react';
import {
FieldValues, RegisterOptions, UseFormReturn,
} from 'react-hook-form';
import Skeleton from 'react-loading-skeleton';
import Icon, { IconName } from '@/components/icons/Icon';
@turizoft
turizoft / flatten.js
Created November 16, 2018 03:31
Flatten array
const testArray = [[1, 2, 3], 4, 5, [[6], [7, 8, [9, 10]], 11, 12], 13]
const flatten = (array) =>
array.reduce((memory, element) =>
Array.isArray(element)
? memory.concat(flatten(element))
: memory.concat(element)
, [])
flatten(testArray)
@turizoft
turizoft / solve.rb
Created August 25, 2017 18:28
Solve most influential people test
# We are going to find the most influential people in the in-it network.
# Each user in in-it follows a group of zero or more people.
# The list of "followings" are given to us as an array of pairs. Each pair is
# in the form of [x, y] which means the user with username x
# is following the user with username y.
# A user X influences a user Y if
# Y follows X or
# Y follows one of the users that X influences
@turizoft
turizoft / 0_reuse_code.js
Created June 6, 2016 21:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@turizoft
turizoft / gist:4d4140d3656b2efca40e
Created May 22, 2015 23:17
Task to read a games database from an API
require 'open-uri'
require 'nokogiri'
namespace :gamesdb do
#This method checks if there are new games in gamesdb and returns the api_id for the last added game
desc "Search for new games on Game db"
task :new_games? => :environment do
gamesdb_games = nokigiri_xml(game_list_url)
games = Game.where('api_id IS NOT NULL')
require 'test_helper'
class StudentsControllerTest < ActionController::TestCase
test "#create should create a student with complete info" do
assert_difference('Student.count') do
post :create, :student => { username: 'guillo', password: '123', password_confirmation: '123'}
end
assert_redirected_to new_confirmation_path
end
@turizoft
turizoft / gist:eb51292490722182d363
Created May 22, 2015 23:12
Business card model definition
class Card < ActiveRecord::Base
# Searchable
searchkick callbacks: :async, text_middle: [:name]
def search_data
as_json only: [:name, :description]
end
# Asociations
has_many :card_social_networks
source 'https://rubygems.org'
ruby '1.9.3'
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
gem 'rails', '4.1.6'
source 'https://rubygems.org'
ruby '2.2.0'
gem 'rails', '4.2.0'
group :development do
gem 'bullet'
gem 'byebug'
gem 'faker'
gem 'letter_opener'
@turizoft
turizoft / gist:52e2218a3fb612986079
Last active August 29, 2015 14:01
Download csv song collection using tinysong
# This script reads a csv file with song name and
# artist name in order to download them.
# This csv can be generated using for example http://groovebackup.com/
# if your collection is hosted on Grooveshark.
# Before running ensure watir-webdriver gems is installed.
# For windows you will also need Chromedriver.exe to be in your PATH.
# Finally the extension GroovesharkDownloader is required.
# Note that this technique is intrusive!