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'
@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 / 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

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(' ')
@utsukushiihime
utsukushiihime / enum-access.js
Created September 22, 2020 23:29 — forked from bnoguchi/enum-access.js
How to access enumValues in mongoose from a Model or Document
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);