Skip to content

Instantly share code, notes, and snippets.

View rc1's full-sized avatar

Ross Cairns rc1

View GitHub Profile
@SalvatorePreviti
SalvatorePreviti / gist:0ec6a73cb14cd33f12350ae27468f2e7
Last active May 20, 2024 02:00
GetFrustumLineIntersection - find the intersection of an infinite line with a view frustum in Unity (improved, with tolerance, stable on corner cases)
/// <summary>
/// Computes the intersection points between a frustum and an infinite line.
/// Finds the visible part of a segment in respect of a camera frustum.
/// Returns false if the line is not visible at all.
/// </summary>
/// <example>
/// var planes = GeometryUtility.CalculateFrustumPlanes(camera);
/// if (GetFrustumLineIntersection(camera, planes, ray, out d1, out d2)) {
/// Gizmos.DrawLine(ray.GetPoint(d1), ray.GetPoint(d2));
/// }
using System;
namespace UniRx {
public static class SwitchExtensions {
public static IObservable<OUT> SwitchSelectWhenTrue<OUT>( this IObservable<bool> observable, Func<IObservable<OUT>> resultIfTrue ) {
return observable.Select(value => value == true ? resultIfTrue() : Observable.Empty<OUT>()).Switch();
}
@almost
almost / proposal.md
Last active September 12, 2019 09:07
Reactive 2016 Lightning Talk Proposal: Get Flow

This is a proposal for a lightning talk at the Reactive 2016 conference.

NOTE: If you like this, star ⭐ the Gist - the amount of stars decides whether it makes the cut! You could also Retweet if you want :)

Get Flow

Type checking JavaScript with Flow

JavaScript is a dynamic language, and there's nothing wrong with that. It allows quick iteration and lowers barriers. However, sometimes some compile-time type checking is just what you need to keep your code in line and give yourself the confidence to build bigger and faster. Flow gives the best of both worlds. You can have normal JavaScript but you can also add types where they're helpful, and it adds zero cost at runtime. In this talk I'll show Flow as it applies to a Redux & React codebase.

@tmslnz
tmslnz / ios-refresh.md
Last active August 29, 2015 14:24
How to free space and fully back up iOS
  1. Connect to computer via USB
  2. Backup via iTunes (make sure you choose encrypted backup)
  3. Transfer purchases via iTunes
  4. Ensure iCloud backup for Docs and Data is on for the apps that need their data restored
  5. Force-trigger an iCloud backup (fromthe Settings, on Wi-Fi and connected to power)
  6. Erase all content and Settings on iOS
  7. Connect to iTunes and use Restore from Backup
@acarabott
acarabott / buildAndRun.sh
Last active October 12, 2016 20:50
openFrameworks Sublime Text Build
#!/bin/bash
# This lives in your project directory, alongside src/, bin/, config.make, etc
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
make Debug && make RunDebug;
@willurd
willurd / web-servers.md
Last active September 19, 2024 12:43
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@trevorturk
trevorturk / gist:1756760
Created February 7, 2012 02:37
Bare minimum html5 template
<!DOCTYPE html>
<html>
<head>
<title>title</title>
</head>
<body>
<p>body</p>
</body>
</html>
@kilokeith
kilokeith / less-ie-rgba-mixin
Created October 5, 2011 02:03
LESS IE rgba mixin
.ie_rgba(@hex, @alpha:256){
@newhex: `"#" + (Math.round("@{alpha}" * 256)).toString(16) + "@{hex}"`;
background: transparent;
-ms-filter: ~'"progid:DXImageTransform.Microsoft.gradient(startColorstr=@{newhex},endColorstr=@{newhex})"'; /* IE8 */
filter: ~'progid:DXImageTransform.Microsoft.gradient(startColorstr=@{newhex},endColorstr=@{newhex})'; /* IE6 & 7 */
zoom: 1;
}
@notlion
notlion / Plask.sublime-build
Created June 16, 2011 21:29
Plask Build File for SublimeText 2
{
"cmd": [ "Plask", "${file}" ],
"selector": "source.js",
"path": "< path to >/Plask.app/Contents/MacOS/",
"working_dir": "${file_path}"
}
@kentbrew
kentbrew / node-on-ec2-port-80.md
Last active February 4, 2024 19:14
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);