Skip to content

Instantly share code, notes, and snippets.

View diazvictor's full-sized avatar
✍️
Haciendo realidad mi imaginación....

Víctor Eduardo Diex Díaz Urbaneja diazvictor

✍️
Haciendo realidad mi imaginación....
View GitHub Profile
@diazvictor
diazvictor / StatusIcon.lua
Last active February 9, 2021 08:13
StatusIcon – A Simple Tray Icon Application Using LGI (Lua + Gtk)
local lgi = require('lgi')
local Gtk = lgi.require('Gtk', '3.0')
function message (title)
--[[
Function to display messages to the user.
]]
-- Create Window
local window = Gtk.Dialog {
@diazvictor
diazvictor / PngImageView.lua
Last active February 9, 2021 08:28
PngImageView - Converting An Image To Base64 And Vice Versa For Display In An Image Using LGI (Lua + Gtk)
#!/usr/bin/lua5.1
--[[--
@package
@filename PngImageView.lua
@version 1.0
@author Díaz Urbaneja Víctor Eduardo Diex <victor.vector008@gmail.com>
@date 22.05.2020 17:20:01 -04
]]
local base64 = require('base64') -- github.com/iskolbin/lbase64
@diazvictor
diazvictor / WindowScreen.lua
Last active February 11, 2021 14:43
WindowScreen - How To Set Window To Current Screen Resolution Using LGI (Lua + Gtk)
local lgi = require('lgi')
local Gtk = lgi.require('Gtk', '3.0')
local Gdk = lgi.require('Gdk', '3.0')
--- I collect the value of the screen resolution
-- and I pick up its width and height
local screen = Gdk.Screen:get_default()
local width, height = screen:get_width(), screen:get_height()
-- Creates the window
@diazvictor
diazvictor / ProviderCSS.lua
Last active February 28, 2021 05:53
How To Link Your CSS Styles With LGI (Lua + Gtk)
local lgi = require('lgi')
local Gtk = lgi.require('Gtk', '3.0')
local Gdk = lgi.require('Gdk', '3.0')
assert = lgi.assert -- With this function I will confirm if a file (in this case custom.css) exists.
--- I load my css
local provider = Gtk.CssProvider()
-- Show a message if custom.css does not exist
assert(provider:load_from_path('custom.css'), 'ERROR: file.css not found')
@diazvictor
diazvictor / Bytes.lua
Last active February 11, 2021 17:24
How To Get the Size (In Bytes) Of A File Using Lua
-- This is a port of Bytes.go <https://gist.github.com/M1que4s/70965ab7ea03d85f43a379e0860d86eb>
function check(err, msg, ...)
local msg = string.format(msg, ...)
if err ~= nil then
print(msg)
return err
end
end
@diazvictor
diazvictor / GistsScrapper.lua
Created February 11, 2021 08:17
How to download RSS files with and display their content with Lua
-- This is a port of GistsScrapper.go <https://gist.github.com/M1que4s/b92073803b658c207fbdfaebc10a1512>
local curl = require('cURL') -- <https://github.com/Lua-cURL/Lua-cURLv3>
local feedparser = require('feedparser') -- <https://github.com/slact/lua-feedparser>
file_exist = function (file)
local file_found = io.open(file, "r")
if (file_found == nil) then
return false
end
@diazvictor
diazvictor / ToggleDarkMode.lua
Created February 12, 2021 06:11
How to change to dark theme of an application with LGI (Lua + GTK)
-- I require LGI
local lgi = require("lgi")
local Gtk = lgi.require("Gtk", "3.0")
-- I create the application
local app = Gtk.Application {
-- The application ID
application_id = "com.gists.github.diazvictor.ToggleDarkMode"
}
@diazvictor
diazvictor / PlaceholderTextView.lua
Created February 16, 2021 16:09
How To Set Placeholder Text in Gtk.TextView With LGI (Lua + Gtk)
local lgi = require('lgi')
local Gtk = lgi.require('Gtk', '3.0')
--- Some widgets were added to keep the initial focus on others.
local window = Gtk.Window {
title = 'TextView With Placeholder',
width = 400,
height = 400,
window_position = Gtk.WindowPosition.CENTER,
{
@diazvictor
diazvictor / CreatingObjects.js
Created February 18, 2021 19:58
How To Create An Object With Javascript
// This is a practice of the <https://www.sololearn.com/learning/1024/> course.
var currentDate = new Date();
function person (name, age) {
this.name = name;
this.age = age;
this.yearOfBirth = currentDate.getFullYear() - this.age;
this.seeInfo = function () {
@diazvictor
diazvictor / InventoryGame.js
Last active November 14, 2023 23:24
Small Example Of A Game Inventory With Javascript
/* jshint esversion: 8 */
// This example is a port of: https://gist.github.com/diazvictor/6fe3372bce79587a3c21123a19881cb1
// I create the Inventory class
class Inventory {
// What to do when the class is initialized
constructor() {
this.items = [];
}