This file contains 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 CheckSlowPokeJob < ActiveJob::Base | |
def perform(slowpoke) # The slowpoke to check | |
slowpoke.check() | |
end | |
end | |
slowpoke = SlowPoke.find(1) | |
# Queues up a job to check slowpoke #1 later | |
CheckSlowPokeJob.perform_later(slowpoke) |
This file contains 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
my_bar = Bar.find(1) | |
my_baz = Baz.find(1) | |
my_bar.to_global_id # gid://foo/Bar/1 | |
my_baz.to_global_id # gid://foo/Baz/1 | |
my_bar.id == my_baz.id # true | |
my_bar.to_global_id == my_baz.to_global_id # false |
This file contains 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 Shufflebag < Enumerator | |
def initialize(arr) | |
i = 0 | |
super() do |y| | |
loop do | |
arr = arr.shuffle if i == 0 | |
y << arr[i] | |
i = (i + 1) % arr.length | |
end | |
end |
This file contains 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 LRS | |
SIZE = 10 | |
attr_accessor :key_history, :inner | |
def initialize() | |
self.key_history = [] | |
self.inner = {} | |
end | |
def get(key) |
This file contains 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
# Write a method called `word_wrap` that takes 1 to 2 arguments. | |
# The first argument is a string. | |
# The second argument is optional, and represents a maximum line length. The | |
# default value should be 80. | |
# `word_wrap` should a string formatted such that no line is longer than the | |
# line length specified by the second argument (i.e. no more than N characters | |
# between newlines). | |
# You should not break words apart, however, you can assume that the line width | |
# will never be shorter than the longest word. |
This file contains 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
# Write a method called `word_wrap` that takes 1 to 2 arguments. | |
# The first argument is a string. | |
# The second argument is optional, and represents a maximum line length. The | |
# default value should be 80. | |
# `word_wrap` should a string formatted such that no line is longer than the | |
# line length specified by the second argument (i.e. no more than N characters | |
# between newlines). | |
# You should not break words apart, however, you can assume that the line width | |
# will never be shorter than the longest word. |
This file contains 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 Node | |
attr_accessor :next | |
def initialize(nxt) | |
@next = nxt | |
end | |
def self.linked_list_with_cycle | |
node = linked_list_without_cycle | |
node.next.next.next = node |
This file contains 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
Shader "Unlit/StripeShader" | |
{ | |
Properties | |
{ | |
// Color property for material inspector, default to white | |
// _Color is the color of the grid lines, actually (need to flip these | |
// at some point) | |
_Color ("Main Color", Color) = (1,1,1,0.5) | |
// _Color2 is actually the main body color | |
_Color2 ("Other Color", Color) = (1,1,1,0.5) |
This file contains 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
using UnityEngine; | |
using System.Collections; | |
[ExecuteInEditMode] | |
public class StatsTest : MonoBehaviour { | |
[UnityEditor.Callbacks.DidReloadScripts] | |
private static void OnScriptsReloaded() { | |
Statistics stats = new Statistics(); | |
stats.Run(); | |
stats.Log(); |
This file contains 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
using UnityEngine; | |
using UnityEditor; | |
public class SkyboxCamera : MonoBehaviour { | |
const int TEXTURE_SIZE = 1024; | |
void Update() { | |
if(Input.anyKey) { | |
Capture(); | |
} |
OlderNewer