Skip to content

Instantly share code, notes, and snippets.


Paul Daniels paulpdaniels

  • Singapore
View GitHub Profile
paulpdaniels / ConcurrentPriorityQueue.cs
Last active Aug 29, 2015
A simple Scheduler for use in Xna Games
View ConcurrentPriorityQueue.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace System.Collections.Concurrent
/// <summary>Provides a thread-safe priority queue data structure.</summary>
/// <typeparam name="TKey">Specifies the type of keys used to prioritize values.</typeparam>
paulpdaniels / ZipEach.cs
Created Aug 18, 2014
Linq enumerate multiple collections simultaneously
View ZipEach.cs
public static class EnumerableExtensions
/// <summary>
/// Enumerates over two sequences simulateneously and performs the action on both
/// </summary>
/// <typeparam name="T1"></typeparam>
/// <typeparam name="T2"></typeparam>
/// <param name="source1"></param>
/// <param name="source2"></param>
/// <param name="eacher">The action which takes a value from each sequence</param>
paulpdaniels / IndexOf.cs
Created Aug 21, 2014
Linq fast indexOf
View IndexOf.cs
namespace System.Linq {
public static class EnumerableExtensions {
public static int IndexOf<T1>(this IEnumerable source, Func<T1, bool> predicate) {
var enumerator = source.GetEnumerator();
bool lastEval = false;
int index = -1;
paulpdaniels / UsingLatest.cs
Last active Aug 29, 2015
Reactive Observable for UsingLatest
View UsingLatest.cs
/// <summary>
/// Creates an observable that will attach the latest value from a second source observable for each value.
/// </summary>
/// <typeparam name="TSource1">The source observable</typeparam>
/// <typeparam name="TSource2">The attached observable</typeparam>
/// <typeparam name="TResult">The result type</typeparam>
/// <param name="source1">The type of the incoming observable</param>
/// <param name="source2">The type of the attached observable</param>
/// <param name="resultSelector"></param>
/// <returns>An observable that is the result of applying <paramref name="resultSelector"/> on the two observables</returns>
View bad_encryption.js
var key = "ZzLlQqUuAa1RrBb2YyCc3XxDd4WwEe5VvFf6TtGg7SsHh8PpIi9JOoj0KkMmNn";
var cardtype = document.studio_form.CARD_TYPE.value;
var cardnumber = document.studio_form.CARD_NUMBER.value;
var carddate = document.studio_form.CARD_DATE.value;
var cardname = document.studio_form.CARD_NAME.value;
var cardaddress = document.studio_form.CARD_ADDRESS.value
+ ", " + document.studio_form.CARD_CITY.value
+ ", " + document.studio_form.CARD_STATE.value
+ ", " + document.studio_form.CARD_ZIP.value
+ " " + document.studio_form.CARD_COUNTRY.value;
View marketing_example.html
<a href="your_link_goes_here" style="float: right;">
<img src="img_src"/>
paulpdaniels / Example.scala
Last active Aug 23, 2020
An example of the relay node specification with Caliban
View Example.scala
object Example extends GenericSchema[Clock] {
implicit val extractorStrategy: ExtractorStrategy = ExtractorStrategy.hyphen
case class User(id: String)
case class Team(id: String)
case class NodeArg(id: String)
val userSchema = gen[User]
val teamSchema: Schema[Clock, Team] = gen[Team]
View EntityResolver.scala
package sangria.federation
import play.api.libs.json.{JsError, JsObject, JsSuccess, Reads}
import sangria.schema.{LeafAction, ObjectLikeType, Value}
trait EntityResolver[Ctx] {
def typename: String
def resolve(obj: JsObject): LeafAction[Ctx, Option[Any]]
View ApplicationLoader.scala
import zio._
class Components(context: ApplicationLoader.Context)
extends BuiltInComponentsFromContext(context) {
// Initialize the layer
val appLayer = ++ ++
// Create a new runtime backed by the application layer