gem 'simple_form'rails generate simple_form:install| 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, |
| 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 |
| const powerOfTwo = (num) => { | |
| let pot = Math.pow(2, Math.ceil(Math.log2(num))) - num; | |
| if (pot === 0) { | |
| return "true"; | |
| } else { | |
| return "false"; | |
| } | |
| }; |
| 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")); |
Magic words:
psql -U postgresSome 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)| # 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 |
| # A Django project's configuration lives in settings.py. | |
| DATABASES = { | |
| 'default': { | |
| 'ENGINE': 'django.db.backends.postgresql', | |
| 'NAME': 'dbname', | |
| } | |
| } |