Skip to content

Instantly share code, notes, and snippets.

Chun-Fu Chao FrankNine

Block or report user

Report or block FrankNine

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@FrankNine
FrankNine / promise_monad.md
Created Aug 17, 2019 — forked from MaiaVictor/promise_monad.md
async/await is just the do-notation of the Promise monad
View promise_monad.md

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

View BlockRotation.cs
using UnityEngine;
public class BlockRotation : MonoBehaviour
{
private bool _isOverlapped;
private void Update()
{
if (Input.GetKeyDown(KeyCode.E) && _isOverlapped)
{
View gist:46a268e66eaa8ad3270697b3a96a928f
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//
// Buffer Definitions:
//
// cbuffer ModelViewProjectionConstantBuffer
// {
//
// float4x4 worldmat; // Offset: 0 Size: 64 [unused]
@FrankNine
FrankNine / .gitattributes
Created Jun 13, 2018 — forked from nemotoo/.gitattributes
.gitattributes for Unity3D with git-lfs
View .gitattributes
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
View AddFramework.cs
static void _AddFrameWork(string pathToBuiltProject)
{
string pbxProjectPath = Path.Combine (pathToBuiltProject, "./Unity-iPhone.xcodeproj/project.pbxproj");
PBXProject pbxProject = new PBXProject ();
pbxProject.ReadFromFile (pbxProjectPath);
string targetGUID = pbxProject.TargetGuidByName ("Unity-iPhone");
pbxProject.AddFrameworkToProject (targetGUID, "CoreData.framework", weak:false);
pbxProject.AddFrameworkToProject (targetGUID, "Social.framework", weak:false);
View gist:3971671
function getXMLConfig() : XML
{
var conf = new Config()
var ba:ByteArrayAsset = ByteArrayAsset( conf );
var xml:XML = new XML( ba.readUTFBytes( ba.length ) );
return xml;
}
function create_gallery(e:Event):void
You can’t perform that action at this time.