Skip to content

Instantly share code, notes, and snippets.

@grisevg
grisevg / AnimatedImage.cpp
Last active August 30, 2023 02:49
UMG Animated Image.
#include "AnimatedImage.h"
void UAnimatedImage::SetCurrentFrame(int32 Frame)
{
CurrentFrame = Frame;
if (CurrentFrame < 0) CurrentFrame = 0;
if (CurrentFrame > TotalFrames - 1) CurrentFrame = TotalFrames - 1;
SynchronizeProperties();
}
@grisevg
grisevg / FAsyncQueue.h
Last active October 20, 2023 03:39
Utility class for asynchronous/coroutine style programming in UE4 C++
#pragma once
/**
* FAsyncQueue can be used to run asynchronous delegates in sequence, parallel and combinations of the above
*
* Use Add() to enqueue delegates matching FAsyncDelegate signature:
* a void function that accepts a single argument of another void function with no arguments.
*
* Static factories MakeSync, MakeSequence and MakeParallel can be used to wrap different type of delegates and
* delegate collections into a single FAsyncDelegate which can be enqueued with Add().
@dotproto
dotproto / getPushIdTimestamp.js
Last active February 14, 2024 01:54
Convert a Firebase Push ID into Unix time (https://gist.github.com/mikelehen/3596a30bd69384624c11/)
var getPushIdTimestamp = (function getPushIdTimestamp() {
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
return function getTimestampFromId(id) {
var time = 0;
var data = id.substr(0, 8);
for (var i = 0; i < 8; i++) {
time = time * 64 + PUSH_CHARS.indexOf(data[i]);
}
@staltz
staltz / introrx.md
Last active May 27, 2024 03:11
The introduction to Reactive Programming you've been missing
@iclems
iclems / Firebase Lazy-Safe Iterator
Last active June 21, 2018 09:48
This snippet enables to iterate over a Firebase reference in a non-blocking way. If you need to iterate over a large reference, a child_added query may block your Firebase as it will query the whole data before iteration. With this snippet, children are retrieved one by one, making it slower / safer.
// By Clément Wehrung
function Iterator(queueRef, processingCallback) {
this.queueRef = queueRef;
this.processingCallback = processingCallback;
this.processed = {};
this.processNext();
}
Iterator.prototype.processNext = function() {
@Marlunes
Marlunes / hide_status_bar
Created July 16, 2013 07:54
FORCE HIDE STATUS BAR FOR IOS 7 AND 6
//viewDidload
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
@apisit
apisit / gist:5893320
Created June 30, 2013 00:55
Remove that 1px line from UINavigationBar in iOS7
[self.navigationController.navigationBar.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]){
UIView* v = obj;
[[v.subviews objectAtIndex:1] removeFromSuperview];
*stop=YES;
}
}];
@zoul
zoul / AVAssetExportSession+Testing.m
Created November 8, 2010 08:35
Export assets synchronously. Good for testing.
@implementation AVAssetExportSession (Testing)
- (void) exportSynchronously
{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[self exportAsynchronouslyWithCompletionHandler:^{
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);