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 / InventoryGame.moon
Last active February 28, 2021 05:45
Small Example Of A Game Inventory With MoonScript
-- I create the Inventory class
class Inventory
-- What to do when the class is initialized
new: =>
@items = {}
--- I look at what I carry in my inventory.
-- @return bool true or false if there are items.
getItem: =>
if #@items != 0 then
@diazvictor
diazvictor / GtkClock.lua
Created February 24, 2021 08:36
A simple clock with LGI (Lua + GTK)
--[[--
@desc A simple clock with LGI (Lua + GTK)
@author Díaz Urbaneja Víctor Eduardo Diex <victor.vector008@gmail.com>
@date 23.02.2021 03:57:22 -04
]]
-- I require the LGI libraries
local lgi = require('lgi')
local Gtk = lgi.require('Gtk', '3.0')
local GLib = lgi.require('GLib', '2.0')
@diazvictor
diazvictor / PathsLGI.md
Last active November 25, 2023 06:39
Paths of standard files of a GTK project for LGI.

Paths of standard files of a GTK project for LGI.

This information has been collected by observing the GNOME projects. Especially those of PGI

com.github.project is the name of your project.

com.github.project/
├── data/
│ ├── appdata/
@diazvictor
diazvictor / WidgetMessages.lua
Last active February 20, 2021 08:53
Widget To Display Messages ("For" And "From") With LGI (Lua + GTK)
--[[
These widgets are used in the MoonZaphire project <https://github.com/diazvictor/MoonZaphire/>
@date 20.02.2021 04:12:56 -04
]]
-- I require the LGI libraries
local lgi = require('lgi')
local Gtk = lgi.require('Gtk', '3.0')
local GLib = lgi.require('GLib', '2.0')
@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 = [];
}
@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 / 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 / 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 / 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 / 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