Skip to content

Instantly share code, notes, and snippets.

View tylerdiaz's full-sized avatar

Tyler Diaz tylerdiaz

View GitHub Profile
@tylerdiaz
tylerdiaz / blockchain.es6.js
Created November 27, 2017 08:19
blockchain
const RushaClass = require('Rusha');
const rusha = new RushaClass();
const CONFIG = { difficulty: 3 }
// from: https://bitcoin.org/bitcoin.pdf
// and: https://www.igvita.com/2014/05/05/minimum-viable-block-chain/
// I do sha1 instead of sha256 here for performance
class Block {
@tylerdiaz
tylerdiaz / keybase.md
Created August 26, 2017 04:09
keybase.md

Keybase proof

I hereby claim:

  • I am tylerdiaz on github.
  • I am tylerdiaz (https://keybase.io/tylerdiaz) on keybase.
  • I have a public key ASCe4-xvvgZhDVIHz_7fGf56sEtXPDBVVFlK5Re3Sbe0_Ao

To claim this, I am signing this object:

@tylerdiaz
tylerdiaz / basic_locustfile.py
Created May 3, 2017 08:48
Simple way to use locust
# -*- coding: utf-8 -*-
from locust import HttpLocust, TaskSet, task
import json
class UserBehavior(TaskSet):
@task(1)
def index(self):
self.client.get(url="/")
class WebsiteUser(HttpLocust):
@tylerdiaz
tylerdiaz / The Technical Interview Cheat Sheet.md
Created December 18, 2016 14:44 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.

As developers it seems like we're in a land of plenty when it comes to code quality tools. There are many options, some more controversial than others. One such option I'd like to talk about today is the use of ESLint in Javascript with the consistent-return rule.

When you enable the consistent-return rule in ESLint the tool will automatically check that all code paths in a function either explicitly return a value or don't return a value. In functions that branch one might forget to return a value in one of the branches, and the consistent-return rule will warn you when that happens.

@tylerdiaz
tylerdiaz / object-to-form-data.js
Created March 14, 2016 15:13 — forked from ghinda/object-to-form-data.js
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@tylerdiaz
tylerdiaz / ed.clj
Created August 14, 2014 19:29
E. Distance algo
(defn square [x]
(* x x))
(defn euclidean-distance [p q]
(Math/sqrt (->> (map - q p) (map square) (reduce +))))
; This formula calculates the distance, which will be smaller for people who are more similar.
; However, you need a function that gives higher values for people who are similar.
; This can be done by adding 1 to the function (so you don’t get a division-by- zero error) and inverting it:
#!/usr/bin/env php
<?php
$db_connection_favorites = array(
'default' => array(
'host' => '127.0.0.1',
'user' => 'root',
'password' => 'root',
'db' => 'database_name'
),
);