Skip to content

Instantly share code, notes, and snippets.

View wesleyduff's full-sized avatar

Wes Duff wesleyduff

  • Denver Colorado
View GitHub Profile
@wesleyduff
wesleyduff / e6.js
Last active August 29, 2015 14:08
E6.js
/* Requirements
+ --
+ require.js
+ // load require.js like so
+ <script data-main="scripts/main" src="scripts/require.js"></script>
+ --
+
require(["helper/e6.js"], function(e6){
e6.init();
@wesleyduff
wesleyduff / smoothie.js
Created October 24, 2014 13:36
smoothie.js
//
// This file is part of Smoothie.
//
// Copyright (C) 2013,14 Torben Haase, Flowy Apps (torben@flowyapps.com)
//
// Smoothie is free software: you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
//This is our base class
class BaseStateManager {
constructor() {
/*
store shape :
name :
state : -1, 0, 1 // this could change : -1 = not changed : 0 = changed but needs more work : 1 = finsihed
*/
this.stores = [];
//Java
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("<your html file>"); //not in scope of this gist
webview.setWebViewClient(new WebViewClient(){
public void onPageFinished(WebView view, String url){
//Here you want to use .loadUrl again
//on the webview object and pass in
//"javascript:<your javaScript function"
webview.loadUrl("javascript:myJavaScriptFunc('" + argumentPassingIn + "')"); //if passing in an object. Mapping may need to take place
}
@wesleyduff
wesleyduff / locationFactoryApp.cs
Last active March 1, 2018 16:44
C# Factory Pattern Example : Based on location, you can have an home address with longitude and latitude and a business address with a longitude and latitude. DotNet Fiddle : https://dotnetfiddle.net/Ti4UBz
using System;
namespace Factory
{
// Location class
public class Location
{
public double Latitude {get; set;}
public double Longitude {get; set;}
}
@wesleyduff
wesleyduff / Character_Program.cs
Created March 2, 2018 17:55
C# composition over inheritance : DotNet Fiddle : https://dotnetfiddle.net/d6ZAG7
using System;
namespace Test {
//Interfaces : contracts for classes to be used for compoisiton
public interface IEat<T>{
//set the food level
int Consume(T Item);
}
public interface ISpecies{
@wesleyduff
wesleyduff / longest_palindrome.cs
Last active March 6, 2018 17:36
Longest Palindrome : C# : Working Example : https://dotnetfiddle.net/5lq3tQ
using System;
namespace PalindromeTest {
/* -------
* Table - store palindromes : Multi Dimensional Array
* =========
* Checks for palindrom
* - Each letter will be a palindrom
* - - Set this as "True" in our Table AND set the new longest palindrome
@wesleyduff
wesleyduff / nock.superagent.post.jest.test.js
Last active March 11, 2018 02:07
Mock a call to a service with npm nock and npm superagent using a POST
import nock from 'nock';
import request from 'superagent';
describe('Calling AWS SDK to sign up a user', () => {
let postData = {username: 'fake@fake.com', password: '@Password1'};
let _request = null;
beforeEach(() => {
nock('http://aws-sdk.aws.com/', {
@wesleyduff
wesleyduff / getNumber_s_Missing_From_array.cs
Created March 11, 2018 03:20
Get the number(s) missing from an array. C#. XOR. : Working example : https://dotnetfiddle.net/PKpGEm
using System;
public class Program
{
public static int GetMissingNumberFromArray(int[] arr)
{
Console.WriteLine("=======================");
int totalXor = 0;
int totalArrXor = 0;
@wesleyduff
wesleyduff / testing.jest.reduxactions.thunks.js
Created March 11, 2018 14:55
Testing with JEST : Redux Actions and Thunks
/* =============== CONSTANTS ============================ */
export const AWS_SIGN_UP_SAVING = 'AWS_SIGNUP_SAVE';
export const AWS_SIGN_UP_FAIL = 'AWS_SIGN_UP_FAIL';
export const AWS_SIGN_UP_SUCCESS = 'AWS_SIGN_UP_SUCCESS';
export const THROW_ERROR = 'THROW_ERROR';
export const CLEAR_ERROR = 'CLEAR_ERROR';