Skip to content

Instantly share code, notes, and snippets.

View MaxMorais's full-sized avatar
🏢
Building Solutions in Tech

Maxwell Morais MaxMorais

🏢
Building Solutions in Tech
View GitHub Profile
@vedantroy
vedantroy / demo.ts
Last active December 31, 2024 09:15
SQLite-backed key-value store with JS-like object manipulation and automatic JSON serialization.
import Database from 'better-sqlite3';
import { createDatabaseClient } from './proxy.ts';
// 1) Create an in-memory DB and your table(s).
const db = new Database(':memory:');
db.exec(`
CREATE TABLE users (
id TEXT PRIMARY KEY,
data JSON
);
@simonw
simonw / README.md
Created May 3, 2022 18:11
Simple declarative schema migration for SQLite
@ricardomaia
ricardomaia / Ativar-API-Token.MD
Last active February 27, 2025 18:47
GLPI API

Para obter um token de API no GLPI, você precisa seguir os seguintes passos:

  1. Habilitar a API REST no GLPI Primeiro, verifique se a API REST está habilitada:

Faça login no GLPI como administrador

  • Vá para Configuração > Geral > APIs
  • Certifique-se de que a opção "Habilitar API REST" esteja ativada
  1. Criar um token de API para um usuário
@naptar
naptar / hangouts.py
Last active January 12, 2022 00:54
Convert/Parse Google Takeout/Export Data Hangouts/Chat into individual conversations
# Run this in the same directory as the Hangouts.json file generated by Google Takeout / Data Export tool.
# python3 hangouts.py
import json
import datetime
import os
import shutil
import re
chat_dir = "hangouts"
@i8beef
i8beef / Node-Red OAuth2 For Google Actions.md
Last active July 30, 2018 18:37
Google Actions OAuth Flow

OAuth 2 Authorization Code Flow For Use With Google Actions

This flow provides a "fake" OAuth 2 implementation for use with the Google Actions API.

Exposes three endpoints:

  1. /google/oauth-auth - Main auth endpoint that Google will call to initialize an OAuth 2 handshake. Checks "client" and "client secret", and returns a login form.
  2. /google/oauth-login - Processes login form, verifies "auth key" provided and generates a new OAuth auth code that the caller (Google) can then exchange for a real OAuth 2 ticket via the last endpoint.
  3. /google/oauth-token - Allows the caller to exchange an "auth key" for a valid OAuth 2 token, or request a new token via refresh token.
@palankai
palankai / specification.py
Last active February 2, 2025 17:45
Python Specification Pattern
class Specification:
def __and__(self, other):
return And(self, other)
def __or__(self, other):
return Or(self, other)
def __xor__(self, other):
return Xor(self, other)
frappe.ui.form.on("Quotation", "refresh", function(frm, doctype, name) {
cur_frm.add_custom_button(__('Add Interaction'), function() {
var d = frappe.prompt([
{label:__("Type of Interaction"), fieldtype:"Select",
options: ["SMS", "Call", "Visit", "Webex"],
fieldname:"type_of_interaction"},
{label:__("Result"), fieldtype:"Select", options: ["Status Quo", "Warmer", "Colder"], fieldname:"result"},
{fieldtype: "Column Break"},
{'fieldname': 'responce_reson', 'fieldtype': 'Data', 'label': 'Responce Reson', 'reqd': 0},
{'fieldname': 'next_date', 'fieldtype': 'Date', 'label': 'Next Action Date', 'reqd': 0},
@austinhyde
austinhyde / js-observables-binding.md
Last active January 7, 2025 08:27
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@SevenW
SevenW / HTTPWebSocketsHandler.py
Last active November 5, 2024 15:41
HTTPWebSocketsHandler extends SimpleHTTPServer with WebSockets enabling the use of HTTP and WebSockets throught the same port
'''
The MIT License (MIT)
Copyright (C) 2014, 2015 Seven Watt <[email protected]>
<http://www.sevenwatt.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@drgarcia1986
drgarcia1986 / main.py
Last active August 29, 2015 14:02
[python-brasil] carregar processo independente
>>> import os
>>> programa = r'C:\Program Files (x86)\mongoDB\bin\mongod.exe'
>>> parametros = r'--logpath "C:\Foo\Bar\Base\install.log" --dbpath "C:\Foo\Bar\Base\data\db" --port 1124'
>>> os.path.dirname(programa)
'C:\\Program Files (x86)\\mongoDB\\bin'
>>> os.path.basename(programa)
'mongod.exe'
>>> os.spawnl(os.P_WAIT, os.path.dirname(programa), os.path.basename(programa), parametros)
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>