Edit: moved to here https://blog.haicon.moe/posts/logitech-f310-to-work-with-macbook-usb-c-port/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: |
- Download the installer from the page https://golang.org/dl/ and install the package.
Type go
in terminal, to verify the installation.
- Create a Go workspace and set GO PATH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# some fish! | |
fish = %w{ fish fish2 fish3 fish4 fish5 fish6 fish7 } | |
# At least 3 lines | |
lines = rand(4) + 3 | |
output = "" |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
NewerOlder