Skip to content

Instantly share code, notes, and snippets.

Do
Msgbox "This is a simple infinite loop"
Loop
@naranjja
naranjja / index.js
Last active March 10, 2022 00:16
Google Analytics tracking using Dialogflow API v2 and some REST API
const ua = require("universal-analytics");
const request = require("request-promise");
const { https } = require("firebase-functions");
function getUserID (obj) {
if (!obj.source) {
return "dialogflow";
} else {
switch (obj.source) {
case "twilio":
@naranjja
naranjja / settings.json
Created June 1, 2021 22:55
Windows Terminal Settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
@naranjja
naranjja / remove_outliers.py
Created September 5, 2018 03:17
Remove outliers using Pandas
import pandas as pd
import numpy as np
def drop_outliers(df, field_name):
distance = 1.5 * (np.nanpercentile(df[field_name], 75) - np.nanpercentile(df[field_name], 25))
df.drop(df[df[field_name] > distance + np.nanpercentile(df[field_name], 75)].index, inplace=True)
df.drop(df[df[field_name] < np.nanpercentile(df[field_name], 25) - distance].index, inplace=True)
if __name__ == "__main__":
# assuming df exists and contains numeric variables
@naranjja
naranjja / parsear-meses.r
Last active August 10, 2020 15:52
Cómo parsear meses en R sin día ni año
library(readr) # para leer fechas en español
library(dplyr) # para usar mutate y pipes
# asumiendo un data.frame cualquiera con una columna "x2" con
# los nombres de los meses, sin día y sin año
df = data.frame(
x1 = c('1', '2', '3'),
x2 = c("ENERO", "DICIEMBRE", "AGOSTO")
)
@naranjja
naranjja / watches.sh
Created June 28, 2018 07:46
Increase number of file watches on VSCode
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@naranjja
naranjja / last_n_sort.sql
Created February 4, 2020 22:43
Get last N_ROWS and sort ascending afterwards in Oracle 11.g
select *
from (
select *
from TABLE
order by SORT_COLUMN desc
) temp
where rownum <= N_ROWS
order by SORT_COLUMN asc;
@naranjja
naranjja / wlan.sh
Created February 4, 2020 21:46
Create a internetless wireless LAN on *buntu
# Requierements
sudo apt install util-linux bash procps hostapd iproute2 iw haveged net-tools dnsmasq iptables
cd /opt && git clone https://github.com/oblique/create_ap
cd create_ap && sudo make install
# Get wireless adapter ID
iwconfig
# Create temporary WLAN (closing this process will remove WLAN)
sudo create_ap -n wlp0s20f3
const int pot = A0; // potentiometer
const int led = D8;
int potValue = 0;
long timestamp;
void setup () {
Serial.begin(9600);
Serial.println("Initializing...");
timestamp = millis();
create temp table user_info as
select A.*, B.sends_to_role
from users as A
left join role_plans as B on A.role_id = B.role_id
where 1 = 1
and (A.id = '{user_id}' or A.sap_id = '{user_id}')
and A.doc_id = '{doc_id}'
and A.is_active = true;