Skip to content

Instantly share code, notes, and snippets.

@nonlogos
nonlogos / script.babel
Created September 27, 2017 21:36
Visualized Algorithms: Linked List
/*
LinkedList
Name your class / constructor (something you can call new on) LinkedList
LinkedList is made by making nodes that have two properties, the value that's being stored and a pointer to
the next node in the list. The LinkedList then keep track of the head and usually the tail (I would suggest
keeping track of the tail because it makes pop really easy.) As you may have notice, the unit tests are the
same as the ArrayList; the interface of the two are exactly the same and should make no difference to the
consumer of the data structure.
@nonlogos
nonlogos / redux form
Created September 4, 2017 19:03
redux form example
import React from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import TextField from 'material-ui/TextField';
import FlatButton from 'material-ui/FlatButton';
import * as actions from '../../actions/itnItems.actions';
import './quotedPriceForm.css';
@nonlogos
nonlogos / Jest testing
Last active August 20, 2017 16:30
New React and React Router 4
import React from 'react';
import { shallow } from 'enzyme';
import preload from '../../data.json';
import ShowCard from '../ShowCard';
test('search should render correct amount of shows', () => {
const component = shallow(<Search />);
expect(component.find(ShowCard.length)).toEqual(preload.shows.length));
});
https://medium.com/@ekeyur/bluebirds-map-and-mapseries-explained-by-cooking-pasta-7dd03a19ea61
// through iteration - my initial attempt
class Tree {
constructor() {
this.root = null;
}
add(value) {
const newNode = new Node(value);
if (!this.root) this.root = newNode;
else{
// Apex controller
public with sharing class ListRacesController {
@AuraEnabled
public static List<Race__c> getRacesDB() {
return [SELECT Id, Name, DateTime__c FROM Race__c];
}
}
// helper function
({
@nonlogos
nonlogos / Advanced Aggregate Query
Last active November 29, 2023 17:02
Salesforce Apex Snippets
// Aggregate query for non-null Social Id Field
// In this case we query all contactsfor social custom fields and group them by accountId
List<AggregateResult> totals =
[SELECT AccountId,
count(twitterId__c) twits,
count(FacebookID__c) likes,
count(linkedInID__c) Links,
FROM Contact
WHERE AccountID IN :mapToAccounts.keyset()
// we have seen the ListPage component, but it isn't containing anything yet. It would be nice to have a preview component for every Pokemon in our Pokedex that switches to a detailed view whenever we click on it.
export default Relay.createContainer(
PokemonPreview,
{
fragments: {
pokemon: () => Relay.QL`
fragment on Pokemon {
id
name
@nonlogos
nonlogos / General_Ideas
Last active February 3, 2017 17:44
All things GraphQL
Problems with Rest API
- no idea the data structure from the api
- too many network apis /proprietory api - baking api into applications for react native and needs to deploy each version api endpoint for each version app api/v1/user, api/v2/user...etc
// ---------------------------------------------
// GraphQL Server
- query language for both client and server
- client specified queries not api request
1. Exposes a single endpoint
@nonlogos
nonlogos / API_SERVER_basic_authentication
Last active November 23, 2024 11:16
basic API Server with Node, Express and Passport Authentication
// mkdir server
// dependencies
// npm install --save express mongoose morgan body-parser nodemon bcrypt-nodejs jwt-simple passport passport-jwt cors
- express
- mongoose
- morgan
- body-parse
- nodemon
- bcrypt
- jwt-simple