Skip to content

Instantly share code, notes, and snippets.

View girasquid's full-sized avatar
🦐

Luke Hutscal girasquid

🦐
View GitHub Profile
@dominicfreeston
dominicfreeston / nine_slice.rb
Created March 16, 2023 22:02
nine-slice (stretching) for dragonruby
def nine_slice sprite
x = sprite.x
y = sprite.y
w = sprite.w
h = sprite.h
path = sprite.path
t_x = sprite.tile_x
t_y = sprite.tile_y
o_w = sprite.tile_w
o_h = sprite.tile_h
@xenobrain
xenobrain / circles.rb
Last active October 12, 2023 14:42
circles for dragonruby
module GTK
class Runtime
def draw_circle c
radius = c.radius.to_i || 0
xc = c.x.to_i + radius
yc = c.y.to_i + radius
t = c.thickness || 1
r = c.r || 0
g = c.g || 0
b = c.b || 0
@jackblk
jackblk / LogitechF310_Macbook.MD
Created April 13, 2021 16:07
Getting Logitech F310 to work with Macbook USB-C port

Connect & use Logitech F310 with Macbook

Since my Macbook Pro only has USB-C port, I used an USB-A to USB-C adapter to connect my F310 to it, but it does not work (pressing MODE button does not turn on the LED).

How to

To make it work:

  • Disconnect F310 from Mac
  • On F310: switch X-input to D-input
  • Hold Logitech button (in the middle)
  • Connect F310 to Mac via adapter, now you can release the Logitech button.
@qrush
qrush / application_job.rb
Last active March 31, 2020 01:38
Use Honeycomb to trace ActiveRecord calls inside of ActiveJob
class ApplicationJob < ActiveJob::Base
around_perform do |job, block|
Honeycomb.start_span(name: job.class.name) do |span|
span.add_field 'type', 'worker'
span.add_field 'queue.name', job.queue_name
block.call
end
end
end
@sirupsen
sirupsen / ping_less.rb
Created March 7, 2019 12:33
Ping less patch for MySQL.
# frozen_string_literal: true
# By default, ActiveRecord will issue a PING command to the database to check
# if it is active at various points. This overhead is unnecessary; we instead
# attempt to issue queries without checking the connection, then if the query
# returns an error and the connection was closed, try to reconnect.
# This also allows for reconnection during a single UoW, improving resiliency
# under transient connection failure (e.g. ProxySQL restarts).
#
# To avoid amplifying load when a database is intermittently down, the attempt
@mholt
mholt / macapp.go
Last active April 15, 2025 20:34
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
@sathiyaseelan
sathiyaseelan / golang_setup.md
Last active April 1, 2024 18:51
Basics to setup a golang project repo in your local

Simple Guide to setup Golang in your Mac and clone a repo.

Setup Go and workspace

Type go in terminal, to verify the installation.

  • Create a Go workspace and set GO PATH
@stevedev
stevedev / fish
Created August 28, 2017 20:06
Fish tank generator for slack. Because.
#!/usr/bin/ruby
# some fish!
fish = %w{ fish fish2 fish3 fish4 fish5 fish6 fish7 }
# At least 3 lines
lines = rand(4) + 3
output = ""

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

package {
import starling.core.Starling;
import starling.animation.Transitions;
import starling.animation.Tween;
public class Utils {
// This function accepts an originalX and originalY so that you can shake things that
// are on screen but not necessarily originally located at 0, 0 (compared to the original
// implementation which only ever moved things back to 0, 0)
public static function screenShake(drawable:Shakeable, shakeDuration:Number, intensity:Number, originalX:Number, originalY:Number):void {