Skip to content

Instantly share code, notes, and snippets.

View unplugandplay's full-sized avatar
💫

unplugandplay unplugandplay

💫
View GitHub Profile
@crucialfelix
crucialfelix / 0 Intro.md
Last active July 18, 2023 10:14
Get ChatGPT to encourage me TODO things

Given the title of https://frantic.im/todo-for-robots/ I was hoping the article was going to present a robot that would actually do my TODOs.

Which is a great idea; a TODO app that actually does your todos.

As a first step, I took the list of TODO app criticisms (nicely stated in the article) and asked ChatGPT to generate a list of generic strategies.

Then I fed it my "troublesome" list of TODOs and asked it to apply the strategies specifically to each task to encourage me.

These were in some cases helpful, some a bit off, but all of them gave a spark of randomness to the list I've been ignoring and that made it engaging.

#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@raysan5
raysan5 / custom_game_engines_small_study.md
Last active July 26, 2024 01:53
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like Unreal or Unity for their games (or that's what lot of people think) because d

@munificent
munificent / generate.c
Last active May 14, 2024 05:30
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@jsomers
jsomers / websockets.md
Created September 27, 2018 12:50
Using websockets to easily build GUIs for Python programs

Using websockets to easily build GUIs for Python programs

I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).

You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:

high-priority

(Each row represents a "worker" in my model, and each rectangle represents a "task.")

getHexColor = (color) ->
return "" unless color
return color if /^#/.test(color)
rgbValues = getRGBValues(color)
hexValues = rgbValues.map(numberToHex)
"#" + hexValues.join("")
numberToHex = (number) ->
"0#{number.toString(16)}".slice(-2).toUpperCase()
@jsn
jsn / ws.cr
Created October 22, 2017 12:47
require "http/server"
handler = HTTP::WebSocketHandler.new do |session|
session.on_message do |message|
puts "Received #{message}"
pp session.@ws.send message
end
end
HTTP::Server.new(8081, [handler, HTTP::LogHandler.new]).listen
@mankind
mankind / rails-jsonb-queries
Last active July 30, 2024 05:01
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@peduarte
peduarte / esnextbin.md
Last active August 25, 2022 14:55
Vanilla Debounce
@brandondrew
brandondrew / rubydo.cr
Last active May 15, 2019 14:35
examples of syntax for RubyDo
# goal: pass code to a Ruby interpreter running in background as a daemon
greeting = "hello"
source = "Ruby"
# desired syntax, which is impossible because the Crystal parser & lexer cannot ignore everything between `ruby do` & `end`
ruby do |greeting, source|
# put Ruby code here as just part of a normal block:
puts "#{greeting} from #{source}!"
end