Skip to content

Instantly share code, notes, and snippets.

View AndresMWeber's full-sized avatar
💭
Katas for Life!

Andres Weber AndresMWeber

💭
Katas for Life!
View GitHub Profile
@AndresMWeber
AndresMWeber / README.md
Created February 16, 2020 00:07
Explanation for For the Love of IoT

Yeah I don't have a specific tutorial but here's what worked for me:

I did Tools-->Port-->(change this one by one and hit upload). That should help you find the successful proper serial port you connected your arduino to on your computer.

After that this is what the example cURL command was that I sent to the Heroku REST API that successfully POSTs and shows up on my device screen (I just tested it now too):

curl --location --request POST 'messaging-thing-api.herokuapp.com/api/messaging' \
--header 'Content-Type: application/json' \
--data-raw '{
@AndresMWeber
AndresMWeber / convert.js
Created October 7, 2019 17:41
Convert CSV to JSON Example
/**
* This is meant to be run on data.csv coming in from Talal. It only converts to JSON and hardcodes the filepath.
*/
function convertCSVtoJSON() {
csv()
.fromFile('data.csv')
.then((crimeDataSet) => {
fs.writeFile("data.json", JSON.stringify(crimeDataSet), 'utf8', function(err) {
if (err) {
@AndresMWeber
AndresMWeber / source.py
Last active June 26, 2019 01:39
Showing where to put the source
class PlotLoop(object):
def __init__(self):
self.data = Data('data_source_file')
self.source = ColumnDataSource(data=dict(xs=np.random.rand(50, 2).tolist(), ys=np.random.rand(50, 2).tolist()))
self.init_plot()
def init_plot(self):
""" Initialize the plot with data from self.data
"""
@AndresMWeber
AndresMWeber / UI_loop_template.py
Created June 25, 2019 18:53
Template for updating a bokeh loop with data to plot.
class Data(object):
def __init__(self, source_file):
self.source = source_file
self.routes = None
def update(self):
self.routes = self.calculate()
return self.routes
def calculate(self):
@AndresMWeber
AndresMWeber / coroutine.py
Created June 25, 2019 18:17
Testing out a Notifier to connect a loop to a separate function
import asyncio
async def shout(msg):
print(msg.upper())
class Notifier(object):
def __init__(self):
self._listeners = []
/**
* Counts a guest's name that is not highlighted nor has strikethrough
*
* @return The value of all the guests.
* @customfunction
*/
function COUNTGUESTS(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var formula = SpreadsheetApp.getActiveRange().getFormula();
# hand_instance.controls.finger.fk[0]
# hand_instance.finger.controls.fk[0]
# hand_instance.controls_finger_ik_0
# hand_instance.fk.controls.finger[0]
# hand_instance.finger.fk.controls[0]
# hand_instance.fingers[0].controls[2]
# hand_instance.fingers[0].controls.fk[2]
hand_instance.hierarchy = {‘fingers’: [
@AndresMWeber
AndresMWeber / TicTacToe.py
Last active December 12, 2017 21:32
Fo bobbay
class State(object):
X = 'X'
O = 'O'
NULL = '-'
def __init__(self, row1=None, row2=None, row3=None):
self.rows = [row or [self.NULL]*3 for row in [row1, row2, row3]]
self.turn = self.O
@property
def horizontal_rows(self):
@AndresMWeber
AndresMWeber / validator.py
Last active November 21, 2017 20:37
Input Validator Abstraction
from functools import wraps
def verify_inputs(filterers=None, validators=None):
""" Verify the inputs going into any function with equal length lists of:
filterers (for filtering out objects we do not care about) and
validators (to check the object itself is valid).
"""
filterers = filterers if filterers is not None else []
validators = validators if validators is not None else []
import maya.cmds as mc
"""
I have two lists:
1. Materials
2. Locators
I want to compare each list and if the locator has the same name as the material then:
getAttr transforms from the locator and setAttr color to the material.
If I define the name of the material and locator as 'someMaterial', it works.