Skip to content

Instantly share code, notes, and snippets.

View Miqueas's full-sized avatar
👍
Average nerd

Miqueas Miqueas

👍
Average nerd
View GitHub Profile
@Miqueas
Miqueas / Problem.c
Last active October 14, 2021 04:52
The 3x + 1 problem
#include <stdio.h>
#include <stdlib.h>
int problem(int n) {
if (n == 1) {
printf("End\n");
return n;
} else if ((n % 2) == 0) {
printf("Even: %d\n", n);
return problem(n / 2);
@Miqueas
Miqueas / Guess.py
Created April 6, 2021 16:44
[Python] Classic guessing game
from random import randint as rand
MagicNum = rand(1, 100)
Lives = 3
print("Guess the number!")
print("Enter your choice:")
choice = int(input("> "))
while True:
@Miqueas
Miqueas / Password.vala
Last active March 17, 2021 04:41
[Vala + Gtk 3] Generic password window
// From my other gist: https://gist.github.com/Miqueas/c52a7f6684036030572a66d1f58ba574
Gtk.Grid build_grid() {
var grid = new Gtk.Grid() {
visible = true,
column_spacing = 6,
row_spacing = 6,
halign = Gtk.Align.CENTER,
valign = Gtk.Align.CENTER
};
@Miqueas
Miqueas / Password.c
Last active March 17, 2021 02:03
[C + Gtk 3] Generic password window
#include <gtk/gtk.h>
GtkWidget *user, *pass, *confirm, *clear, *check;
GRegex *patt;
GtkWidget* build_grid() {
GtkWidget *label;
GtkWidget *grid = g_object_new(
GTK_TYPE_GRID,
@Miqueas
Miqueas / Guess.lua
Last active February 24, 2021 18:25
[Lua] Classic guessing game
-- Generates a constantly-changin number
-- Note: Lua 5.4 don't need this
math.randomseed(os.time())
local MagicNum = math.random(100)
local Lives = 3
print ("Guess the number!")
print ("Enter your choice:")
io.write("> ")
@Miqueas
Miqueas / App.rb
Created February 17, 2021 23:27
[Ruby + GTK 3] Simple GTK app
require "gtk3"
app = Gtk::Application.new "com.example.ruby-gtk3", :FLAGS_NONE
app.signal_connect :activate do |app|
head = Gtk::HeaderBar.new
head.visible = true
head.title = "Ruby GTK+ 3 example"
head.show_close_button = true
@Miqueas
Miqueas / Guess.go
Created February 17, 2021 21:54
[Go] Classic guessing game
package main
import (
Fmt "fmt"
Time "time"
Rand "math/rand"
)
func main() {
// Makes a constantly-changing number
@Miqueas
Miqueas / Guess.rb
Last active February 18, 2021 01:21
[Ruby] Classic guessing game
# Magic number to guess
MagicNum = rand 100
# User lives
lives = 3
puts "Guess the number!\n"
puts 'Enter your choice:'
print '> '
# User input
choice = gets.chomp.to_i
@Miqueas
Miqueas / JSON.go
Created February 11, 2021 03:14
[Go] Decode and encode JSON
package main
import (
Fmt "fmt"
Str "strings"
Bytes "bytes"
JSON "encoding/json"
)
// Our JSON string to decode
@Miqueas
Miqueas / Flags.go
Created February 10, 2021 20:57
[Go] Basic example of using commandline arguments
package main
import (
// For printing
Fmt "fmt"
// For arguments parsing
Flag "flag"
)
// Defines a flag for the commandline. Refers to the doc for details: