Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Slothninja Indonesia Autorefresh
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.slothninja.com/indonesia/game/show/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=slothninja.com
// @grant none
// ==/UserScript==
from ctypes import c_float, c_int32, cast, byref, POINTER
def a(number):
threehalfs = 1.5
x2 = number * 0.5
y = c_float(number)
i = cast(byref(y), POINTER(c_int32)).contents.value
i = c_int32(0x5f3759df - (i >> 1))
y = cast(byref(i), POINTER(c_float)).contents.value
@hcarver
hcarver / redis-migrate.rb
Created October 6, 2016 20:08
For migrating between Redis databases on Heroku, when the source database doesn't support the sync Redis command
# For migrating between Redis databases on Heroku, when the source database doesn't support sync
# This is useful for migrating away from Redis Cloud, for example.
require "redis"
# You need to have created a new database first, with
# heroku addons:create heroku-redis:hobby-dev -a $APP
# OR
# heroku addons:create heroku-redis:premium-0 -a $APP
@hcarver
hcarver / two_iterators.rb
Last active March 21, 2017 16:42
Two ways of iterating a tree breadth-first in ruby
# We need an iterator to be called on the root node of a tree structure
# The iterator must iterate through the entire first level of the tree
# then the second level, then the third etc.
require 'ostruct'
# First make a tree!
# 1
# / \
# 2 3

Keybase proof

I hereby claim:

  • I am hcarver on github.
  • I am hywelc (https://keybase.io/hywelc) on keybase.
  • I have a public key whose fingerprint is C779 F580 45CC 044A 9DEF 45E5 00C1 470B BD39 16CB

To claim this, I am signing this object: