Skip to content

Instantly share code, notes, and snippets.

View jrasanen's full-sized avatar
🦁

Jussi Räsänen jrasanen

🦁
  • Internet
View GitHub Profile

Emscripten as a linker for Zig and C

This shows how to build a nontrivial program using Zig+Emscripten or C+Emscripten. In both cases Emscripten is only used as a linker, that is the frontend is either zig or clang.

"Nontrivial" here means the program uses interesting Emscripten features:

  • Asyncify
  • Full GLES3 support
  • GLFW3 support
@YukiSnowy
YukiSnowy / main.cpp
Last active October 8, 2023 13:56
example SDL2 Direct3D9 application
// g++ *.cpp -o d3d9 -lmingw32 -lSDL2main -lSDL2 -I/dxsdk/include -L/dxsdk/lib -DUNICODE -ld3d9 -ld3dx9
// http://blog.fourthwoods.com/2011/08/11/setting-up-mingw-for-directx/
// http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-4
#include <iostream>
using namespace std;
#include <SDL2/SDL.h>
#include <windows.h>
@nnarhinen
nnarhinen / index.html
Created August 9, 2013 07:42
POST Form to new window and wait for postMessage
<html>
<head>
<title>Post form in a new window without losing handle to the window</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function() {
$('form').on('submit', function(ev) {
var form = $(this);
form.attr('target', 'new-window');
@octaharon
octaharon / slack_filter.user.js
Created November 13, 2020 15:07
Tampermonkey script for filtering slack messages by user
// ==UserScript==
// @name Slack filter messages by UID
// @namespace Slack
// @version 0.1
// @description removes messages from unwanted people in slack channels and threads, or replaces them with kittens
// @author Octaharon <Alexander Uskov>
// @include https://app.slack.com/client/*
// @grant none
// ==/UserScript==
@xeekworx
xeekworx / sdl_box_move_example.cpp
Last active January 5, 2023 23:01
SDL Renderer & Keyboard State Example
#include <SDL.h>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <format>
int main(int argc, char* argv[])
{
std::string app_title = "SDL Box Movement Example - Use the arrow keys!";
@roman01la
roman01la / clojurescript-repl-workflow.md
Last active October 22, 2022 12:07
ClojureScript REPL Workflow

ClojureScript REPL Workflow

Short write up on using REPL when developing UIs in ClojureScript.

Hot-reload on save or Eval in REPL?

Everyone's standard approach to hot-reloading is to use a tool (Figwheel or shadow-cljs) that reloads changed namespaces automatically. This works really well: you change the code, the tool picks up changed files, compiles namespaces and dependants, notifies REPL client which then pulls in compiled changes, and re-runs a function that re-renders UI.

The other approach is to use ClojureScript's REPL directly and rely only on eval from the editor. This more or less matches Clojure style workflow. This approach might be useful when you don't want tools overhead or hot-reloading becomes slow for you or you just used to this style of interactions. Also changing code doesn't always mean that you want to reload all the changes. On the other hand it is very easy to change a couple of top-level forms and forget to eval one of them.

@randrews
randrews / main.lua
Created August 8, 2012 04:16
Example code for nice-feeling player movement in Love
require 'point'
function love.load()
math.randomseed(os.time())
love.physics.setMeter(32)
love.graphics.setBackgroundColor(64, 120, 64)
world = love.physics.newWorld(0, 0)
crates = { makeCrate(world, 5, 5),
makeCrate(world, 5, 6) }
@voter101
voter101 / Gulpfile.js
Last active November 29, 2021 01:17
Gulpfile for Rails application with replaced Sprockets with Gulp
'use strict'
var gulp, sass, babelify, browserify, watchify, source, util;
gulp = require('gulp');
sass = require('gulp-sass');
babelify = require('babelify')
browserify = require('browserify');
watchify = require('watchify');
source = require('vinyl-source-stream');
@madwork
madwork / attachment.rb
Last active July 25, 2021 09:13
Polymorphic attachments with CarrierWave and nested_attributes
class Attachment < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Associations
belongs_to :attached_item, polymorphic: true
# Validations
validates_presence_of :attachment
@zethon
zethon / gist:dc7a5c71b0ac3cff35017febd1f15511
Last active June 27, 2021 04:04
Changing the color of macOS app title bar in Qt with CMake

In CMake, add/link the Carbon library to the executable

    FIND_LIBRARY(CARBON_LIBRARY Carbon)
    set(EXTRA_LIBS
        ${CARBON_LIBRARY}

Make sure to add ${CARBON_LIBRARY} in the TARGET_LINK_LIBRARIES call for the executable.

Then create a file to hold the Object-C code, in this case changetitlebarcolor.mm