This file contains 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 std/uri | |
proc `?+`*(url: Uri, ql: openArray[tuple[string, string]]): Uri = | |
var qs = @ql | |
if url.query.len() != 0: | |
for k, v in url.query.decodeQuery(): | |
qs.add( (k, v) ) | |
return url ? qs |
This file contains 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
-- Determines if this script is running on Windows | |
os.is_win = package.config:sub(1, 1) == "\\" | |
-- Return the path to the temp dir | |
function os.get_temp_dir() | |
if os.is_win then | |
-- Windows. Same as: | |
-- os.getenv("TEMP") | |
-- os.getenv("TMP") | |
return os.getenv("UserProfile") .. "/AppData/Local/Temp" |
This file contains 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") |
This file contains 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 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 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 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 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 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 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 |
NewerOlder