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
"""An example of a cache decorator.""" | |
import json | |
from functools import wraps | |
from redis import StrictRedis | |
redis = StrictRedis() | |
def cached(func): |
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
import Foundation | |
class MyService: NSObject, MyServiceProtocol { | |
func upperCaseString(_ string: String, withReply reply: @escaping (String) -> Void) { | |
let response = string.uppercased() | |
reply(response) | |
} | |
} |
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
/// <summary> | |
/// Vertically flips a render texture in-place. | |
/// </summary> | |
/// <param name="target">Render texture to flip.</param> | |
public static void VerticallyFlipRenderTexture(RenderTexture target) | |
{ | |
var temp = RenderTexture.GetTemporary(target.descriptor); | |
Graphics.Blit(target, temp, new Vector2(1, -1), new Vector2(0, 1)); | |
Graphics.Blit(temp, target); | |
RenderTexture.ReleaseTemporary(temp); |
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
// NOTE: For an actively-maintained version of this script, see https://github.com/mminer/consolation. | |
using System.Collections.Generic; | |
using UnityEngine; | |
/// <summary> | |
/// A console to display Unity's debug logs in-game. | |
/// </summary> | |
public class Console : MonoBehaviour | |
{ |
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
local eventManager <const> = {} | |
function addEventListener(eventName, listener) | |
local eventListeners = eventManager[eventName] | |
if not eventListeners then | |
eventListeners = {} | |
eventManager[eventName] = eventListeners | |
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
using System; | |
using System.Text.RegularExpressions; | |
using UnityEngine; | |
/// <summary> | |
/// Holds the result of parsing the ytInitialPlayerResponse JSON from a YouTube page. | |
/// </summary> | |
/// <remarks> | |
/// This is an incomplete list of fields in ytInitialPlayerResponse. | |
/// The full object contains many more, but we only care about a few. |
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; | |
public class Marquee : MonoBehaviour | |
{ | |
public string message = "Where we're going, we don't need roads."; | |
public float scrollSpeed = 50; | |
Rect messageRect; | |
void OnGUI () |
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
import Foundation | |
let progress = Progress(parent: nil, userInfo: [ | |
.fileOperationKindKey: Progress.FileOperationKind.downloading, | |
.fileURLKey: URL(fileURLWithPath: "/Users/mminer/Downloads/somefile.zip"), | |
]) | |
progress.isCancellable = true | |
progress.isPausable = false | |
progress.kind = .file |
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
import json | |
import tornado.web | |
class JsonHandler(BaseHandler): | |
"""Request handler where requests and responses speak JSON.""" | |
def prepare(self): | |
# Incorporate request JSON into arguments dictionary. | |
if self.request.body: | |
try: |
NewerOlder