Skip to content

Instantly share code, notes, and snippets.

@felipeborges
felipeborges / WebkitSample.js
Last active February 22, 2024 20:56
JavaScript (Gjs)(GTK3) Webkit Sample. Run: "gjs WebkitSample.js"
// Updated in August 2022
imports.gi.versions.Gtk = '3.0';
const { Gtk, GObject, WebKit2: WebKit } = imports.gi;
Gtk.init(null);
const WebBrowser = GObject.registerClass(
class WebBrowser extends Gtk.Application {
@felipeborges
felipeborges / install-java3d-fedora.md
Last active December 20, 2015 22:49
Installing Java3D on Fedora (tested on Fedora 19)

How to install java3d on Fedora

First of all, make sure you have Oracle's Java installed. (installing Java is outside the scope of this tutorial).

  1. First of all, start by downloading the java3d linux binaries on http://java3d.java.net/binary-builds.html

  2. Secondly, unzip it:

const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
Gtk.init(null, 0);
print("Gtk Version: " + Gtk.MAJOR_VERSION +"."+Gtk.MINOR_VERSION+"."+Gtk.MICRO_VERSION);
let test_window = new Gtk.Window({
default_width: 800,
default_height: 600
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
Gtk.init(null, 0);
print("Gtk Version: " + Gtk.MAJOR_VERSION +"."+Gtk.MINOR_VERSION+"."+Gtk.MICRO_VERSION);
let test_window = new Gtk.Window({
default_width: 800,
default_height: 600
@felipeborges
felipeborges / replace_contents_async_bug.js
Last active August 29, 2015 14:01
Bug in GFile.replace_contents_async
const ByteArray = imports.byteArray;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
let byteArray = ByteArray.fromString('lala');;
let file = Gio.file_new_for_path("output.json");
file.replace_contents_async(byteArray, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null,
Lang.bind(this, function() {
log("bye!");
@felipeborges
felipeborges / hover_image.js
Created May 14, 2014 15:06
Hover effect in Gtk Image
const GdkPixbuf = imports.gi.GdkPixbuf;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
Gtk.init(null, 0);
let test_window = new Gtk.Window({
default_width: 128,
default_height: 128
from gi.repository import Gtk
def log_key_events(widget, event):
print(event.get_keyval()[1])
w = Gtk.Window()
w.connect('key-press-event', log_key_events)
w.show()
import math
pi = math.pi
cos = math.cos
def f(x):
return cos(pi*(x+1)/8.0) + (0.148*(x)) -0.9062
def mod(x):
if x > 0:
@felipeborges
felipeborges / gnu_police.py
Created October 1, 2014 01:20
A Twitter bot which replies how to refer properly to the computer operating system commonly called Linux.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@felipeborges
felipeborges / facebook-psychological-predictions.json
Last active August 29, 2015 14:13
Apply Magic Sauce's predictionAPI translates individuals' digital footprints into detailed psychological profiles. This is my Facebook psychological profile based on my last 100 Likes. http://applymagicsauce.com/test.html
{
"uid": "1525548425",
"predictions": [
{
"trait": "Relationship_Married",
"value": 0.1472537849883816
},
{
"trait": "Concentration_Journalism",
"value": 0.10400347649614775