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 / directus-prevent-uri-too-large.md
Last active March 18, 2025 19:32
Directus: Prevent URI too large

Here we can see the alternative solutions to prevent request URI too long / large (414 code)

@joselcvarela
joselcvarela / directus-extension-change-role.md
Last active March 17, 2025 06:44
Switch Directus role based on current role and User Agent

Change Role

Directus custom hook extension to change role of current user based on current role and User-Agent This allows to dynamically allow some permissions in on App and allow other permissions on another App or Directus App

@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();
})()
var ip = "localhost"
var dbName = "DBNAME"
var viewType = "VIEWTYPE"
var viewName = "VIEWNAME"
$.getJSON("http://"+ip+":5984/"+dbName+"/_design/"+viewType+"/_view/"+viewName+"/", function(data) {
    data.rows.forEach(function (doc) {
var __id = doc.value._id
delete doc.value._id
var newDoc = doc.value
newDoc.values = Object.assign({}, doc.value.values, {newValue: false})
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) {