Skip to content

Instantly share code, notes, and snippets.

@alenstarx
alenstarx / postjson.js
Created May 5, 2017 15:19
Post application/json in gjs
const Lang = imports.lang;
const Soup = imports.gi.Soup;
let _session = new Soup.SessionAsync();
function POSTJSON(url, params, callback) {
log('post started');
let request = Soup.Message.new('POST', url);
log('req created');
let _params = JSON.stringify(params)
@alenstarx
alenstarx / post.js
Created May 5, 2017 15:18
POST requests in gjs
const Lang = imports.lang;
const Soup = imports.gi.Soup;
let _session = new Soup.SessionAsync();
function POST(url, params, callback) {
let request = Soup.Message.new('POST', url);
let _params = Soup.form_encode_hash(params);
request.set_request('application/x-www-form-urlencoded',
@alenstarx
alenstarx / get.js
Created May 5, 2017 15:18
GET requests in gjs with libsoup
const Lang = imports.lang;
const Soup = imports.gi.Soup;
let _session = new Soup.SessionAsync();
function GET(url, callback) {
let request = Soup.Message.new('GET', url);
_session.queue_message(request, Lang.bind(this,
function(session, message) {
@alenstarx
alenstarx / opengl_wrappers.c
Created March 24, 2016 03:40 — forked from roxlu/opengl_wrappers.c
A couple of wrappers for opengl which are handy when you want to provide some openGL features in your library. Simply embed these into your cpp file. (Note that your executable will become slightly bigger because of this.)
/*
See https://gist.github.com/roxlu/6152fccfdd0446533e1b for the latest version.
Author: roxlu
Twitter: http://www.twitter.com/roxlu
*/
/* ------------------------------------------------------------------------*/
@alenstarx
alenstarx / H264_Decoder.cpp
Created March 24, 2016 03:30 — forked from roxlu/H264_Decoder.cpp
LibAV parser and decoder example with openGL (YUV420 -> RGB shader).
#include "H264_Decoder.h"
H264_Decoder::H264_Decoder(h264_decoder_callback frameCallback, void* user)
:codec(NULL)
,codec_context(NULL)
,parser(NULL)
,fp(NULL)
,frame(0)
,cb_frame(frameCallback)
,cb_user(user)