Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;
@naranjja
naranjja / .bashrc
Created October 18, 2019 22:37
Jose's Path
# ...
export PATH=~/.npm-global/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_11_2
export PATH=$LD_LIBRARY_PATH:$PATH
export TNS_ADMIN=/opt/oracle
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export ANDROID_HOME="/usr/lib/android/sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}
module.exports = {
root: true,
env: {
browser: true,
node: true,
commonjs: true,
es6: true,
},
parserOptions: {
parser: "babel-eslint",
@naranjja
naranjja / hash.R
Created October 14, 2019 22:46
Hash minute timestamp + userId on Node.js, Nativescript, and R
# import digest library (default R-base library)
library(digest)
# get current date in UTC as ISO string and keep all chars up until minutes
# eg. 2019-10-14T17:40
date <- strftime(as.POSIXlt(Sys.time(), tz = "UTC"), "%Y-%m-%dT%H:%M")
# get userId
userId <- "0000123"
@naranjja
naranjja / users-permissions.sql
Created August 20, 2019 00:16
List all users and permissions in Azure SQL
SELECT DP1.name AS DatabaseRoleName,
isnull (DP2.name, 'No members') AS DatabaseUserName
FROM sys.database_role_members AS DRM
RIGHT OUTER JOIN sys.database_principals AS DP1
ON DRM.role_principal_id = DP1.principal_id
LEFT OUTER JOIN sys.database_principals AS DP2
ON DRM.member_principal_id = DP2.principal_id
WHERE DP1.type = 'R'
ORDER BY DP1.name;