Skip to content

Instantly share code, notes, and snippets.

View alecklandgraf's full-sized avatar

Aleck Landgraf alecklandgraf

View GitHub Profile
@Miceuz
Miceuz / chirp.py
Created July 24, 2015 20:11
I2C soil moisture sensor with RaspberryPi
#!/usr/bin/python
# cannot use python3 because smbus not working there
# Modified script from https://github.com/JasperWallace/chirp-graphite/blob/master/chirp.py
# by DanielTamm
import smbus, time, sys
class Chirp:
def __init__(self, bus=1, address=0x20):
self.bus_num = bus
from scapy.all import *
import requests
import time
MAGIC_FORM_URL = 'http://put-your-url-here'
def record_poop():
data = {
"Timestamp": time.strftime("%Y-%m-%d %H:%M"),
"Measurement": 'Poopy Diaper'
}
@alecklandgraf
alecklandgraf / RadarChart.js
Last active September 2, 2015 15:57 — forked from nbremer/.block
Building Comparison Demo
//Practically all this code comes from https://github.com/alangrafu/radar-chart-d3
//I only made some additions and aesthetic adjustments to make the chart look better
//(of course, that is only my point of view)
//Such as a better placement of the titles at each line end,
//adding numbers that reflect what each circular level stands for
//Not placing the last level and slight differences in color
//
//For a bit of extra information check the blog about it:
//http://nbremer.blogspot.nl/2013/09/making-d3-radar-chart-look-bit-better.html
@gaearon
gaearon / connect.js
Last active October 13, 2025 06:56
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@ccnokes
ccnokes / axios-instance-config.js
Created July 6, 2017 16:23
Good default configuration for axios in node.js
const axios = require('axios');
const http = require('http');
const https = require('https');
module.exports = axios.create({
//60 sec timeout
timeout: 60000,
//keepAlive pools and reuses TCP connections, so it's faster
httpAgent: new http.Agent({ keepAlive: true }),
@andland
andland / first_orchard_simulation.R
Created January 13, 2020 16:09
Simulates the probability of winning the First Orchard Game https://www.habausa.com/my-very-first-games-first-orchard/
roll_die <- function(status, strategy) {
roll = sample(c(names(status), "basket"), 1)
if (roll == "basket") {
trees = status[names(status) != "raven" & status > 0]
if (strategy == "optimal") {
biggest_trees = trees[trees == max(trees)]
roll = sample(names(biggest_trees), 1)
} else if (strategy == "random") {
roll = sample(names(trees), 1)
} else if (strategy == "worst") {