Skip to content

Instantly share code, notes, and snippets.

View phlegx's full-sized avatar
💪
never stop coding

Phlegx Systems phlegx

💪
never stop coding
View GitHub Profile
@phlegx
phlegx / Rails 4 - how to give alias names to includes() and joins() in active record quering
Last active February 12, 2024 19:12
Rails 4 - how to give alias names to includes() and joins() in active record quering
See question on stack overflow: http://stackoverflow.com/questions/28595636/rails-4-how-to-give-alias-names-to-includes-and-joins-in-active-record-que
- Model Student and model Teacher are both STI models with super class model User
- Model Story is a STI model with super class model Task
- includes() and joins(), both fails
Rails alias naming convention (includes() and joins())
- One model as parameter
- is base model (includes(:users))
@phlegx
phlegx / UBLOX_AT_CellularNetwork.cpp
Last active March 17, 2022 12:30
Mbed OS 5.15.8: Add +UMNOPROF set option, set +URAT only if required and add third RAT to RAT list.
nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
{
nsapi_error_t ret = NSAPI_ERROR_OK;
CellularNetwork::AttachStatus status;
get_attach(status);
if (status == Attached) {
tr_debug("RAT should only be set in detached state");
return NSAPI_ERROR_UNSUPPORTED;
}
@phlegx
phlegx / UBLOX_AT.cpp
Last active March 17, 2022 12:30
Mbed OS 5.15.8: Disable power save mode.
nsapi_error_t UBLOX_AT::init()
{
setup_at_handler();
_at->lock();
_at->flush();
_at->at_cmd_discard("", "");
nsapi_error_t err = NSAPI_ERROR_OK;
@phlegx
phlegx / ublox_low_level_api.h
Last active March 17, 2022 12:30
Mbed OS 5.15.8: GPIO reset some pins at init.
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@phlegx
phlegx / onboard_modem_api.c
Last active October 20, 2021 12:01
Mbed OS 5.15.7: Add wait on onboard modem deinit.
/* mbed Microcontroller Library
* Copyright (c) 2017 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
<template lang='pug'>
div.drop-zone(:class='{dragging: isDragging }'
@dragover.prevent='dragover'
@dragenter.prevent='dragover'
@drop.prevent.stop='onDrop'
@dragleave.prevent='dragleave')
div(:class='{ hidden: uploadInProgress }' @click='openFileBrowser')
slot
i {{label}}
input(type='file' :multiple='multiple' ref='input' style='display: none')
@phlegx
phlegx / array_validator.rb
Last active May 5, 2021 18:53 — forked from ssimeonov/array_validator.rb
Rails 6.1 array validator with indexed messages.
# Syntax sugar
class ArrayValidator < EnumValidator
end
@phlegx
phlegx / Ubuntu 18.04 setup.md
Created December 9, 2020 20:31 — forked from labbots/Ubuntu 18.04 setup.md
Ubuntu 18.04 Manual partitioning setup with LUKS encryption and LVM - https://labbots.com/ubuntu-18-04-installation-with-luks-and-lvm

Ubuntu 18.04 installation with LUKS and LVM

Installation Process

Pre-installation from live OS

This setup of Ubuntu with LUKS and LVM is tested on Ubuntu 18.04.

Boot Ubuntu from a Live OS and select the option to try Ubuntu without installing. Follow the steps I've outlined below. Let's assume you're installing to /dev/nvme0n1.

  1. Partition the drive with your tool of choice: I used gparted to set mine up.
curl -u elastic:xxxx localhost:9200/jt-metricbeat-staging-000003/_mapping | jq
{
"jt-metricbeat-staging-000003": {
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
module Authenticable
extend ActiveSupport::Concern
# Filter to use with before_action
def authenticate_user
jwt_token
rescue JWT::DecodeError => e
render json: { error: e.message }, status: :unauthorized
end