Skip to content

Instantly share code, notes, and snippets.

View emp-daisy's full-sized avatar
👑
Focusing

Jessica M emp-daisy

👑
Focusing
View GitHub Profile
@emp-daisy
emp-daisy / api-throttling-429-error-handling.js
Created December 30, 2021 11:28 — forked from benogle/api-throttling-429-error-handling.js
An example script consuming an API with various throttling and 429 "too many requests" error handling strategies.
// An example script consuming an API with various throttling and 429 error
// handling strategies.
//
// Blog post with more context
// https://www.useanvil.com/blog/2021-03-29-throttling-and-consuming-apis-with-429-rate-limits
//
// License: MIT
import fetch from 'node-fetch'
import mapLimit from 'async/mapLimit'
@emp-daisy
emp-daisy / import-db.sh
Created May 30, 2021 06:16 — forked from hartleybrody/import-db.sh
Copy data from Heroku Postgres into local database
# copy/import data from heroku postgres to localhost pg database
# useful for copying admin's work on live site into local database to reproduce errors
# https://devcenter.heroku.com/articles/heroku-postgres-import-export
# take heroku pg snapshot and download
heroku pg:backups:capture
heroku pg:backups:download
# load the dump into local postgres database, assuming $DATABASE_URL set locally
@emp-daisy
emp-daisy / fix_openssl_catalina.sh
Created January 22, 2020 16:53 — forked from llbbl/fix_openssl_catalina.sh
fix missing openssl files in catalina
#!/bin/bash
echo 'update brew'
brew update
echo 'upgrade brew'
brew upgrade
@emp-daisy
emp-daisy / validateObjectEs6.js
Created November 29, 2019 13:23
Check if object is contains required properties
/*
* Useful for check falsy values in object
* Can be helpful for form validation
* Object - The data to be validation
* props - The required properties that cannot be falsy (null, undefined, '', 0)
*/
const validateObject = (obj, props) => {
const valid = _.chain(props)
.map(prop => _.has(obj, prop) && !!obj[prop])
.without(false)
@emp-daisy
emp-daisy / killport.sh
Last active November 22, 2019 20:18
Create alias to kill port faster from command line (Free up port easily)
alias killport='function _killp(){ lsof -nti:$1 | xargs kill -9 };_killp'
# Running: `killport 3000` will free up port 3000
@emp-daisy
emp-daisy / critic-mind-hack-random.js
Created November 7, 2019 22:43
Critic Mind Hack - My Compiled solution to Random Challenges
function StockPrices(prices) {
let profit = -1;
let buy = Infinity
let sell = -Infinity
for (let i = 0; i < prices.length - 1; i++) {
if(prices[i] < buy) {
buy = prices[i]
sell = prices[i + 1]
} else if (prices[i] > sell) {
@emp-daisy
emp-daisy / critic-mind-hack-codility.js
Last active October 28, 2019 21:44
Critic Mind Hack - My Compiled solution to Codility Challenges/Lessons
function OddOccurrencesInArray(A) {
const counter = {};
for (let i of A){
if(counter[i]) delete counter[i];
else counter[i] = 1;
}
return +Object.keys(counter)[0];
}
function binaryGap(N) {
const bina = N.toString(2);
@emp-daisy
emp-daisy / slack-clone.html
Last active February 16, 2019 13:02
A simple chat interface
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" contwelvet="width=device-width">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/simple-scrollbar.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css">
<style>
.sidebar {
@emp-daisy
emp-daisy / slack-slash-google-script.gs
Last active October 11, 2019 10:15
Slack slash command with Google Script
function doPost(request){
console.log("GOT here");
var params = request.parameter;
var text = params.text; //the options provided after the command as a single string
//visit https://api.slack.com/slash-commands/#app_command_handling for available payload sent by slack
var names = text.split(" ");
var firstName = names[0];
var lastName = names[1];
addRow(firstName, lastName);//call function to add row as declared below