This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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! |
NewerOlder