This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
Fmt "fmt" | |
Time "time" | |
Rand "math/rand" | |
) | |
func main() { | |
// Makes a constantly-changing number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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("> ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* Explanation | |
Arrays in C are just pointers. So, basically they points | |
to the address of the first element and when we indexing | |
using [], we're just performing an addition and the order | |
doesn't matter at all for that operator in C. Also, the | |
array identifier is also the first element itself, as I | |
said, is just a pointer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gintro/gobject | |
import gintro/gio | |
import gintro/gtk4 | |
proc activate(app: gtk4.Application) = | |
let win = gtk4.newApplicationWindow(app) | |
win.defaultSize = (800, 600) | |
win.present() | |
let app = gtk4.newApplication("org.gtk.example") |