Skip to content

Instantly share code, notes, and snippets.

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

nj nevadajames

🏠
Working from home
View GitHub Profile
@nevadajames
nevadajames / gulpfile.js
Last active June 1, 2017 23:19
Gulpfile for some useful functions
var gulp= require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var cssnano = require('gulp-cssnano');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var imagemin = require('gulp-imagemin');
@nevadajames
nevadajames / colorized_strings.rb
Last active April 10, 2019 14:34
Rock, paper, scissors game built with Ruby
class String
def red
"\e[31m#{self}\e[0m"
end
def green
"\e[32m#{self}\e[0m"
end
def yellow
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
driver = webdriver.Chrome()
url = "http://www.fgc.cat/cat/index.asp"
@nevadajames
nevadajames / spain_phones.rb
Last active March 15, 2018 06:15
Spanish telephone validator
AREA_CODES = {
Marbella: [822], Badajoz:[ 824, 924], Guipuzcoa: [843,943],
Navarra: [848, 948], Granada: [858, 958], Murcia: [868, 968], Baleares:[871, 971],
Gerona: [872, 972], Lerida:[ 873, 973],Zaragoza: [876, 976],
Tarragona:[877, 977], Pontevedra: [886, 986], Madrid: [911, 912, 913, 914, 915, 916, 917, 918],
Segovia: [921], Salamanca: [923], Toledo: [925], Ciudad_Real: [926], Caceres: [927],
Barcelona: [931, 932, 933, 934, 935, 936, 937, 938], La_Rioja: [941], Cantabria: [942],
Vizcaya: [944, 946], Alava: [945], Burgos: [947], Guadalajara: [949], Almeria: [950],
Malaga: [951, 952], Jaen: [953], Sevilla: [954, 955], Cordoba: [957], Huelva: [959],
Valencia: [960, 961, 962, 963], Alicante: [965, 966], Albacete: [967], Cuenca: [969],
class PhoneGenerator
def self.generate_landline
area_code = AREA_CODES.values.sample
if area_code.is_a?(Array)
area_code = area_code.sample
end
create_phone(area_code, six_digit_extension)
end
def self.generate_mobile
@nevadajames
nevadajames / area_code.ex
Last active June 3, 2018 10:26
elixir lessons
defmodule AreaCode do
@moduledoc """
Returns map of provinces with corresponding area codes as a list
"""
def codes_by_province do
%{
marbella: [822], badajoz: [ 824, 924], guipuzcoa: [843,943],
navarra: [848, 948], granada: [858, 958], murcia: [868, 968], baleares: [871, 971],
gerona: [872, 972], lerida: [ 873, 973], zaragoza: [876, 976],
@nevadajames
nevadajames / table_size_in_gb.sql
Last active June 5, 2018 07:48
SQL script for getting table size in gigabytes ordered by largest
SELECT table_name,(data_length+index_length)/power(1024,3) tablesize_gb
FROM information_schema.tables
WHERE table_schema='database_name'
ORDER BY (data_length+index_length)/power(1024,3) DESC
@nevadajames
nevadajames / csv_reader.py
Last active June 1, 2018 11:28
Script to get data from csv
import csv
import sys
f = open('filename.csv', "rt")
reader = csv.reader(f)
row_count = 0
for row in reader:
if #do something with row get columns with row[index]:
@nevadajames
nevadajames / axios-catch-error.js
Created August 18, 2018 18:07 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
axios.put(this.apiBaseEndpoint + '/' + id, input)
.then((response) => {
// Success
})
.catch((error) => {
// Error
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data);
@nevadajames
nevadajames / groove.rb
Last active November 9, 2018 15:10
sonic pi simple song
live_loop :effects do
with_fx :reverb, mix: 0.7, room: 0.5 do
play 20, pan: -1
sleep 0.5
play 22, pan: 1
end
end
live_loop :prog do
sample :bd_haus, rate: 2