Skip to content

Instantly share code, notes, and snippets.

View peterlozano's full-sized avatar

Pedro Lozano peterlozano

View GitHub Profile
@peterlozano
peterlozano / Readme.md
Created November 22, 2018 11:51
Bash aliases to copy/paste using Piknik

Install and configure https://github.com/jedisct1/piknik

Host ips need to be static or have a dns.

Add the bash aliases (either mac or linux) for easy copy/paste directly from clipboard to Piknik.

@peterlozano
peterlozano / enable-ntfs-rw.sh
Created November 18, 2018 17:03
Enable NTFS write in Macos without using third party drivers or apps.
echo "LABEL=DRIVELABEL none ntfs rw,auto" >> /etc/fstab
@peterlozano
peterlozano / lambda @ edge
Last active April 6, 2018 22:52
Redirect to www domain using AWS CloudFront Lambda @ Edge. Attach this function to the Viewer Request event.
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
if (request.headers['host'][0].value !== 'www.example.com') {
/*
* Generate HTTP redirect response with 302 status code and Location header.
*/
const response = {
status: '302',
statusDescription: 'Found',
# https://stackoverflow.com/questions/32431465/mamp-ssl-error-error14077410ssl-routinesssl23-get-server-hellosslv3-alert
1. brew install openssl
2. Download and unpack the latest cURL
3. In the cURL source directory:
LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" ./configure --prefix=/Applications/MAMP/Library/
4. make
5. make install
6. Restart MAMP
@peterlozano
peterlozano / node_user.php
Last active July 8, 2016 09:40
Drupal 8: Get user entity for node author
<?php
$user = $node->uid->entity;
$email = $node->uid->entity->mail->value;
@peterlozano
peterlozano / drupal_8_create_node_url.php
Last active June 24, 2016 18:33
Create absolute link to node in D8
<?php
$url = \Drupal\Core\Url::fromRoute('entity.node.canonical', array('node' => $nid), array('absolute' => TRUE))->toString();
@peterlozano
peterlozano / drupal_8_send_email.php
Created June 23, 2016 14:03
Sending mail from drupal 8
<?php
// To be passed to hook_mail
$params = array();
// To be passed to hook_mail
$key = 'my_mail_key';
$langcode = \Drupal::languageManager()->getDefaultLanguage();
\Drupal::service('plugin.manager.mail')
<?php
// For field of type datestamp
db_insert('table')
->fields(array(
'created' => date_create()->format('Y-m-d H:i:s'),
))
->execute();
<?php
$module = 'module_name';
$name = 'table_name';
$table = drupal_get_module_schema($module, $name);
db_create_table($name, $table);