Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am shiggiddie on github.
* I am shiggiddie (https://keybase.io/shiggiddie) on keybase.
* I have a public key ASAUMzmuLKaZLU7s-KvZ8pWfmMUxiTNkRaxNif-k-dkg0Ao
To claim this, I am signing this object:
using System;
using Xamarin.Forms;
using System.Windows.Input;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.ComponentModel;
using System.Threading.Tasks;
[assembly:
InternalsVisibleTo ("TwinTechsLib.iOS"),
@Shiggiddie
Shiggiddie / index.js
Created October 7, 2016 14:32
Cooking with GAS - Subverting User-permission Authorization in Spreadsheet onEdit function
// Ideally one would get user information from onEdit using onEdit's event's .user attribute,
// however GAS does not give authorization to do so for the onEdit function (without some minor caveats).
// The following subverts this slightly by allowing the user to include their own user information that is
// then stored on the user's properties for the file/script.
function onEdit(e) {
var user = PropertiesService.getUserProperties().getProperty('user');
if (!user) {
var ui = SpreadsheetApp.getUi();
while (!user) {
@Shiggiddie
Shiggiddie / reddit_comment.js
Last active July 29, 2016 16:30
Reddit Comment Posting using only request-promise and session cookies
/*
* The purpose of this excercise was to understand how to preserve a session
* using only request-promise (https://www.npmjs.com/package/request-promise)
*
* USAGE:
*
* Grab dependencies:
* $ npm --save request
* $ npm --save request-promise
*
@Shiggiddie
Shiggiddie / 04052015_quiz
Last active August 29, 2015 14:20
Bad array function use
// Problem: given an array of elements, create the array function to turn that array into
// a string that will represent an html table containing the array elements, one element per row,
// with each element appended with "foo"
// E.g. The following array...
var arr = ["hi", "bye", "todo", "fly"];
// ...becomes:
// <html>
// <body>
// <table>
@Shiggiddie
Shiggiddie / gist:643e7153605354b84686
Last active December 16, 2015 02:59
Ruby/Rails HW: get/post routes, passing parameters into .erb templates, .erb if/else template logic
# 1) Make necessary modifications to a rails project such that an HTML response of "<h1>Hello World</h1>"
# is returned when hitting the path "/hello_world/index" with a GET request
# 2) Devise a shell utility "curl" command that makes a GET request of the path constructed in #1
# 3) Make necessary modifications to the rails project such that an HTML response of "<h1>Hello POST world</h1>"
# is returned when hitting the path "/hello_world/index" with a POST request, do not remove any code created in #1
# 4) Devise a shell utility "curl" command that makes a POST request of the path constructed in #2
@Shiggiddie
Shiggiddie / beer_me_learnings
Created January 15, 2015 02:41
beer_me learnings
After porting beer_me to a mean.js app, I kept seeing "exports": e.g. "exports.foo = function() {console.log('hi');}"
I assumed this had something to do with the way the functions were exposed elsewhere in a mean.js app's codebase.
This assumption was fairly correct, and confirmed after reading: http://www.sitepoint.com/understanding-module-exports-exports-node-js/
I do not understand this line: https://github.com/cpww/beer_me/blob/master/app/controllers/users.server.controller.js#L11
Where does the ".extend" method come from?
So the var "_" is assined the module.exports object from "lodash".
Therefore "_.extend" is accessing the "extend" function from within the "lodash" module.
@Shiggiddie
Shiggiddie / gist:6c0a70ec1eba06bde255
Created November 20, 2014 12:50
After writing tic-tac-toe, there were some subtle improvements possible, HW was assigned and these are the answers
//1) Fix computer algorithm (assigning to Anth)
// In Player's .makeMove method:
if (index == null) {
// No block? Try for center...
//console.log('computer is attempting to center');
if (grid.vectors[4].value == null) {
index = 4;
}
}
@Shiggiddie
Shiggiddie / tic-tac-toe elegant vs performant solutions
Last active August 29, 2015 14:08
The tic-tac-toe project presented itself with a problem of "checking for a win state", this gist contains an elegant non-performant, and a less-elegant performant solution.
/*
Background:
- The Grid object has an array of Vector objects accessible in the Grid's "vectors" attribute
- A Vector object has a "value" attribute that contains "O", "X", or null if not set
- The checkForWin method on the Grid returns true if and only if there is a win state in tic-tac-toe
* The win state is determined by looping through all the various winCombos, where winCombos is an array of arrays, whose inner arrays represent the 3 indexes of the Grid's "vectors" array that refer to row, collumn, or diagonal on a tic-tac-toe board which -if all containing the same Vector "value" value- constitutes a win.
*/
// Elegant, non-performant
// Month Names
var monthName = function() {
var names = ["January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"];
return {
name: function(number) { return names[number]; },
number: function(name) { return names.indexOf(name); }
};
}();