Skip to content

Instantly share code, notes, and snippets.

View cecyc's full-sized avatar
🙈

Cecy Correa cecyc

🙈
View GitHub Profile
@cecyc
cecyc / smart_props_example.rb
Created March 8, 2022 23:05
Example of SmartProperties in Ruby
require "smart_properties"
require "date"
class User
include SmartProperties
property! :email, accepts: String, converts: :to_s
property :dob, accepts: Date
property :zip_code, accepts: [90210, 48378, 93893, 94238]
end
const axios = require('axios');
// JS STUDY NOTES
const removeFirstTwoChars = (list) => {
const [, , ...arr] = list;
return arr;
}
console.log(removeFirstTwoChars([1,2,3,4,5,6,7]));

A regex for checking for specific US States

Example:

/(OR)|(or)$|([Oo]regon)$/gm

Matches: Eugene, OR eugene, or Somewhere, oregon

.container {
    -ms-overflow-style: none;  // IE 10+
    overflow: -moz-scrollbars-none;  // Firefox
}
.container::-webkit-scrollbar { 
    display: none;  // Safari and Chrome
}
@cecyc
cecyc / docker_and_kubernetes_cheatsheet.md
Created August 29, 2018 19:22
A quick reference doc for Docker and Kubernetes for those starting out

Docker and Kubernetes cheatsheet

Docker

Basics

Basic commands:

  • docker ps list all currently running containers
  • docker-compose build build a series of containers based on a docker-compose file
@cecyc
cecyc / uploading_to_s3.py
Last active August 20, 2019 13:36
Sample script for batch processing data and uploading output to S3. This snippet processes batch data from the WHOIS Bulk API based on a CSV list of IPs to search in WHOIS.
import argparse
import boto3
import json
import logging
import os
import pandas
from pandas import DataFrame, read_csv
import requests
import time
import random
@cecyc
cecyc / open-csv.py
Last active August 20, 2019 13:38
Open a CSV in Python
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--csv", required=True, help="csv to parse ips from")
flags = vars(parser.parse_args())
csv_file = flags["csv"]
results = []
with open(csv_file, newline='') as f:
csvreader = csv.reader(f)
@cecyc
cecyc / docker-for-flask.md
Last active July 17, 2018 15:22
Dockerfile and docker-compose for a simple Flask app

Dockerfile

FROM python:3.4
RUN apt-get update -y
RUN apt-get install -y python-pip build-essential
COPY ./path-to-app /app
WORKDIR /app
RUN pip install --no-cache-dir -r requirements.txt
ENV FLASK_APP=app.py
| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|
| boop |
|          |
|__________|
(\_❀) ||
(•ㅅ•) ||
/   づ
@cecyc
cecyc / getUrl.js
Last active July 17, 2018 15:26
Simple script to request a video from YouTube API
// Request to YouTube
const API_KEY=""
const videoUrl = "https://www.youtube.com/watch?v="
let reqUrl = `https://www.googleapis.com/youtube/v3/search?key=API_KEY&part=snippet&q=${query}&maxResults=25`
//Get a random int to pick a random video from the results
const getRandomInt = () => {
let num = Math.random
//maxResults are 25 index 0, get a random number between 0 and 24
return Math.floor(num * 24)