Skip to content

Instantly share code, notes, and snippets.

View BrianJVarley's full-sized avatar

Brian Varley BrianJVarley

View GitHub Profile
@keeguon
keeguon / countries.json
Created April 5, 2012 11:11
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
public class Linx
{
[Test]
public void Select()
{
var ints = new[] { 1, 2, 3 };
var squares = ints.Select(x => x * x);
CollectionAssert.AreEqual(new[] { 1, 4, 9 }, squares);
}
@patrickhammond
patrickhammond / gist:0b13ec35160af758d98c
Created March 8, 2015 02:30
Sample for how to use the Google Play Services dynamic security provider to keep the SSL library that the app will use to up date.
package com.mycompany.myapp.app;
import android.app.Application;
import android.content.Intent;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.security.ProviderInstaller;
import com.google.android.gms.security.ProviderInstaller.ProviderInstallListener;
public class MainApplication extends Application {
@GeoffCox
GeoffCox / Global.asax.cs
Created April 16, 2015 00:07
Allow multiple origins for CORS using ASP.NET MVC
protected void Application_BeginRequest()
{
this.SetupCorsHeaders();
//OPTIONS request comes before the POST to know the permissions. this forces to send the reply.
if (((IList)Request.Headers.AllKeys).Contains("Origin") && Request.HttpMethod == "OPTIONS")
{
Response.Flush();
}
}
anonymous
anonymous / gist:557284161332bf9d1d1d
Created May 23, 2015 18:57
Simple IoC container
internal class ResourceManager
{
#region Singleton
private static Lazy<ResourceManager> instance = new Lazy<ResourceManager>(() => new ResourceManager());
internal static ResourceManager Instance { get { return instance.Value; } }
private ResourceManager()
{
@seanislegend
seanislegend / rxjs-example-poll-url.js
Last active August 12, 2019 09:43
RxJS - Poll a URL
let timeout = 1000;
/**
* Create a custom observable that creates a XHR request and returns complete when the promise is fulfilled
*/
let observable = Rx.Observable.create((o) => {
dataService.fetch('test.json')
.then((data) => {
o.onNext(data);
o.onCompleted();
@wmertens
wmertens / full stack redux.md
Last active February 8, 2022 22:46
making an awesome server with the redux model, Work In Progress

Thought experiment: Redux-like stateless server

Description

We describe a model for client-server processing where the Redux model is used to minimize stateful code. This should allow live-reloading server code, and make it possible to share code (e.g. optimistic updating) between client and server.

Dramatis Personae

  • Assume a server consisting of multiple worker processes that do not share memory and may be running on multiple hosts.
    • Workers have middleware, root reducers and an app state object
  • Workers can be dynamically added and removed
@btroncone
btroncone / ngrxintro.md
Last active June 26, 2024 08:27
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@bertrandg
bertrandg / ngrx-effects-advance-example.js
Last active October 3, 2022 02:22
ngrx/effects advance example
// Nothing changed here, works as previously.
@Effect() actionX$ = this.updates$
.ofType('ACTION_X')
.map(toPayload)
.switchMap(payload => this.api.callApiX(payload)
.map(data => ({type: 'ACTION_X_SUCCESS', payload: data}))
.catch(err => Observable.of({type: 'ACTION_X_FAIL', payload: err}))
);
@obliviusm
obliviusm / Fastfile
Created October 2, 2017 20:26
android/fastlane/Fastfile
desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do
# need to use `react-native bundle` instead of bundleReleaseJsAndAssets from grdale
# because it causes 134 error (out of memory) on Circle CI
sh "cd ../.. && react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/"
gradle(
task: "assembleRelease",
flags: "-x bundleReleaseJsAndAssets"
)
crashlytics(