Skip to content

Instantly share code, notes, and snippets.

View utsukushiihime's full-sized avatar
🎯
Focusing

Crystal McNeil utsukushiihime

🎯
Focusing
View GitHub Profile
@utsukushiihime
utsukushiihime / Query
Created June 25, 2021 00:17 — forked from lukecav/Query
MySQL script to get all WooCommerce orders including metadata
select
p.ID as order_id,
p.post_date,
max( CASE WHEN pm.meta_key = '_billing_email' and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email,
max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_first_name,
max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_last_name,
max( CASE WHEN pm.meta_key = '_billing_address_1' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_1,
max( CASE WHEN pm.meta_key = '_billing_address_2' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_2,
max( CASE WHEN pm.meta_key = '_billing_city' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_city,
max( CASE WHEN pm.meta_key = '_billing_state' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_state,
@utsukushiihime
utsukushiihime / wordpress-list-users.sql
Created June 24, 2021 23:37 — forked from petenelson/wordpress-list-users.sql
WordPress: MySQL query to list user names, emails, and first & last name
SELECT wp_users.user_login, wp_users.user_email, firstmeta.meta_value as first_name, lastmeta.meta_value as last_name FROM wp_users left join wp_usermeta as firstmeta on wp_users.ID = firstmeta.user_id and firstmeta.meta_key = 'first_name' left join wp_usermeta as lastmeta on wp_users.ID = lastmeta.user_id and lastmeta.meta_key = 'last_name'
git log --since="last month" --pretty=format:'%h,%an,%ar,%s' > log.csv
@utsukushiihime
utsukushiihime / Simple Form.md
Created January 8, 2021 03:48 — forked from stevenyap/Simple Form.md
Simple Form Cheatsheet

Gemfile

gem 'simple_form'

Installation

rails generate simple_form:install
@utsukushiihime
utsukushiihime / .js
Created December 12, 2020 06:42
powerOfTwo JavaScript
const powerOfTwo = (num) => {
let pot = Math.pow(2, Math.ceil(Math.log2(num))) - num;
if (pot === 0) {
return "true";
} else {
return "false";
}
};
@utsukushiihime
utsukushiihime / .js
Last active December 12, 2020 06:44
toSnakeCase JavaScript
function SnakeCase(str) {
const regex = /\W+/g;
for (char in str) {
let newStr = str.toLowerCase().replace(regex, "_");
return newStr;
}
}
console.log(SnakeCase("This*is a Great-Night"));
@utsukushiihime
utsukushiihime / postgres-cheatsheet.md
Created November 28, 2020 01:16 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@utsukushiihime
utsukushiihime / 0 AWS Cloud9
Last active December 1, 2020 22:12 — forked from yshmarov/0 AWS Cloud9
Ruby on Rails 6: Learn 25+ gems and build a Startup MVP 2020
# All AWS C9 envments
https://eu-central-1.console.aws.amazon.com/cloud9/home?region=us-east-1
# Instance management
https://console.aws.amazon.com/ec2/home?region=eu-central-1#Instances:sort=instanceId
# Create AWS C9 environment
https://eu-central-1.console.aws.amazon.com/cloud9/home/create
Setting - set tabs to 2
@utsukushiihime
utsukushiihime / settings.py
Created October 3, 2020 20:27
Django Project Postgres Database Configuration
# A Django project's configuration lives in settings.py.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'dbname',
}
}

Big-O Notation Exercises

What is the worst-case time complexity for the following algorithms?

#1

function wordOccurrence(word, phrase){
  let result = 0
  const array  = phrase.split(' ')