Skip to content

Instantly share code, notes, and snippets.

View joselcvarela's full-sized avatar
🤓
Developing the world

José Varela joselcvarela

🤓
Developing the world
View GitHub Profile
@joselcvarela
joselcvarela / custom-endpoint.ts
Created August 22, 2024 07:29
Clear cache on a Directus custom extension
import type { Accountability } from '@directus/types';
export default defineEndpoint((router, context) => {
const { services, getSchema } = context;
const { UtilsService } = services;
router.get('/', async (req, res) => {
const utilsService = new UtilsService({
schema: await getSchema(),
accountability: createDefaultAccountability({admin: true})
@joselcvarela
joselcvarela / example.js
Created August 7, 2024 11:48
Util class to make requests easily in Javascript
const { Request } = require('./request.js')
function start({token = "", body = null} = {}) {
const request = Request.get('http://ip.jsontest.com')
if (auth) request.header('Authorization', `Bearer ${token}`)
const response = await request.json(body)
if (!response.ok) throw response
@joselcvarela
joselcvarela / postgres.docker-compose.md
Last active February 17, 2021 10:37
POSTGRES DOCKER COMPOSE

DUMP ALL

docker-compose exec -u postgres postgres pg_dumpall -c > prod_`date +%d-%m-%Y"_"%H_%M_%S`.sql

DUMP TABLE FROM DATABASE

docker-compose exec -u postgres postgres pg_dump -d "DATABASE" -t 'TABLE' > TABLE_`date +%d-%m-%Y"_"%H_%M_%S`.sql
@joselcvarela
joselcvarela / Tizen Build Package
Created July 21, 2020 21:30
Tizen Build Package
## Tizen configuration
1. Download Tizen CLI from here https://developer.tizen.org/development/tizen-studio/download
2. `chmod 755 web-cli_Tizen_Studio_3.7_ubuntu-64.bin`
3. `~/tizen-studio/tools/ide/bin/tizen certificate -a ProfileName -p 1234 -f profile_filename`
4. `~/tizen-studio/tools/ide/bin/tizen security-profiles add -n ProfileName -a ~/tizen-studio-data/keystore/author/profile_filename.p12 -p 1234`
5. Edit `~/tizen-studio-data/profile/profiles.xml` and change password fields like this:
```
<profileitem ...profile_filename.p12" password="" rootca=""/>
<profileitem ...tizen-distributor-signer.p12" password="tizenpkcs12passfordsigner" rootca=""/>
@joselcvarela
joselcvarela / logOnDOM.html
Created September 19, 2019 15:37
console.log, consoler.error, console.info, fetch on DOM
<script>
(function() {
var a = console.log;
var b = console.error;
var c = console.info;
var d = fetch;
var output = document.createElement("div");
output.style.cssText =
"position:fixed; background: white; width: 50vw; height: 100vh; z-index: 99; right: 0; top: 0; overflow: auto; word-wrap: pre-wrap;";
document.body.appendChild(output);
@joselcvarela
joselcvarela / downloadInline.js
Created January 13, 2019 07:53
Download html element from console
(function(){
var blob=new Blob([$0.outerHTML]);
var link=document.createElement('a');
link.href=window.URL.createObjectURL(blob);
link.download="myFileName.txt";
link.click();
})()
@joselcvarela
joselcvarela / jsconfig.json
Last active November 18, 2018 12:47
Set multiple root paths
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": [
"*",
"src/*"
]
}
}
#MOTION
*Popmotion (https://popmotion.io/)
*Gsap (https://greensock.com/)
#VR
*Aframe
#SVG
*d3.js (https://d3js.org/)
ColumnLayout {
width: parent.width
TextMontserrat {
text: title
font.bold: true
color: colors.white
Layout.fillWidth: true
Layout.maximumHeight: 310
fontSizeMode: Text.Fit
var ip = "http://localhost"
var dbName = "DB_NAME"
var viewType = "VIEW_TYPE"
var viewName = "VIEW_NAME"
$.getJSON(ip+":5984/"+dbName+"/_design/"+viewType+"/_view/"+viewName+"/", function(data) {
    data.rows.forEach(function (doc) {
        $.ajax({
            url: ip+":5984/"+dbName+"/" + doc.value._id + '?rev=' + doc.value._rev,
            type: 'DELETE',
            success: function(result) {