Skip to content

Instantly share code, notes, and snippets.

View JoseGonzalez321's full-sized avatar
💭
GraphQL is interesting

Jose Gonzalez JoseGonzalez321

💭
GraphQL is interesting
View GitHub Profile
// Find duplicates in an array of ints
// IMO, a bit messier/complicated than should be. But it works.
function findDupes(arr) {
var counted = arr.reduce((all, item) => {
all[item] = (all[item] || 0) + 1;
return all;
}, {});
return Object.keys(counted).filter(x => counted[x] > 1).map(x => parseInt(x);
}
// find duplicate primitive elements in an array (e.g. array of ints)
function findDuplicates(data) {
let result = [];
data.forEach(function(element, index) {
// Find if there is a duplicate or not
if (data.includes(element, index + 1)) {
@JoseGonzalez321
JoseGonzalez321 / Maybe.cs
Created March 22, 2018 17:09
Jose's failure to understand Maybe :)
using System;
using System.Collections.Generic;
using System.Linq;
namespace Playground.Utils
{
public struct Maybe<T>
{
readonly IEnumerable<T> _values;
@JoseGonzalez321
JoseGonzalez321 / rockman-demo-steps.md
Last active October 28, 2017 01:51
Step by step guide on for the React Rockman Robot Masters App

Note: These are my personal notes for the presentation. Feel free to contribute or contact me for any clarifications.

  • Do npm install before the talk starts. It's a lot of dead time...and you know WIFI issues.

Add

constructor() {
    super();
    this.state = {
 robots: ['Proto Man', 'Mega Man']
@JoseGonzalez321
JoseGonzalez321 / Demo-steps.md
Last active September 29, 2017 20:17
Steps for Robot Masters Demo
  • You may wanna do a npm install before the talk starts. It's a lot of dead time...and you know WIFI issues.

  • Remove everything inside `render()

Add

constructor() {
    super();
    this.state = {
 robots: ['Proto Man', 'Mega Man']
@JoseGonzalez321
JoseGonzalez321 / JumpStart-React-Resources.md
Last active September 21, 2017 17:12
Resources for presentation: Get a Jump-Start on React
public void GetData(int customerId, string businessCode)
{
var query =
$@"SELECT c.*
FROM Customer c
INNER JOIN Business b ON c.BussinessCode = b.BussinessCode AND c.CustomerId = b.CustomerId
WHERE c.customerId = {customerId}
AND b.businessCode = '{businessCode}'";
//Do all the grunt work
public void GetData(int customerId, string businessCode)
{
StringBuilder query = new StringBuilder();
query.AppendLine("SELECT c.*");
query.AppendLine("FROM Customer c");
query.AppendLine("INNER JOIN Business b ON c.BussinessCode = b.BussinessCode AND c.CustomerId = b.CustomerId");
query.AppendLine("WHERE c.customerId = " + customerId + "");
query.AppendLine("AND b.businessCode = '" + businessCode.ToString() + "'");
@JoseGonzalez321
JoseGonzalez321 / StringInterpolationExample.cs
Last active August 27, 2017 16:44
String Interpolation for post
var person = new Person {FirstName = "Jose", LastName = "Gonzalez"};
var name = string.Format("My name is {0} {1}", person.FirstName, person.LastName);
// With C# 6 string interpolation becomes
var name = "My name is {person.FirstName} {person.LastName}";