Skip to content

Instantly share code, notes, and snippets.

@Hypnopompia
Hypnopompia / pressure.ino
Created May 29, 2018 21:45
Particle Photon pressure transducer firmware
// On the photon, analog reading values are: 0 = 0.0V and 4095 = 3.3V.
// Do NOT put more than 3.3V into an analog input pin on a photon or you'll damage the photon.
// Since the pressure tranducer can output more than 3.3V (up to 4.5V), we'll need to create a voltage divider to protect the photon:
// https://learn.sparkfun.com/tutorials/voltage-dividers/all
const float PHOTON_VOLTAGE_COEFFICIENT = 3.3 / 4096;
const float SENSOR_MIN_V = 0.5;
const float SENSOR_MAX_V = 4.5;
const float SENSOR_MIN_PSI = 0.0;
@Hypnopompia
Hypnopompia / DuskTestCase.php
Last active March 20, 2017 22:40
Larval dusk on circle-ci
<?php
namespace Tests;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase {
use CreatesApplication;
@Hypnopompia
Hypnopompia / transcode.php
Created November 7, 2016 22:13
transcode a toxbox archive webm file containing variable dimensions to an mp4
#!/usr/bin/env php
<?php
$input = isset($argv[1]) ? $argv[1] : null;
$output = isset($argv[2]) ? $argv[2] : null;
if (!$input || !file_exists($input)) {
die("No valid input file specified.\n");
}
if (!$output) {
@Hypnopompia
Hypnopompia / gps.ino
Last active March 23, 2016 21:54
Electron Asset Tracker Read Test
// echo all the raw GPS data to the USB serial port?
#define GPSECHO false
#define gpsSerial Serial1
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28" // turn off output
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28" // turn on GPRMC and GGA
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F" // Set the update rate 1 Hz update rate
#define PGCMD_NOANTENNA "$PGCMD,33,0*6C" // Mute antenna status events
@Hypnopompia
Hypnopompia / broken.php
Created July 7, 2014 22:34
namespaces and typehinting
<?php
namespace foo;
class Foobar {
public function foo (\boolean $barf) { // Catchable fatal error: Argument 1 passed to foo\Foobar::foo() must be an instance of boolean, boolean given
echo $barf ? "yep" : "nope";
}
public function bar (boolean $barf) { // Catchable fatal error: Argument 1 passed to foo\Foobar::bar() must be an instance of foo\boolean, boolean given
echo $barf ? "yep" : "nope";
@Hypnopompia
Hypnopompia / app.js
Last active August 29, 2015 14:01
Node app to listen for spark events and tweet the data
// To run, first install the twit and eventsource packages:
// npm install twit eventsource
// then:
// node app.js
// From the spark core, call:
// Spark.publish("tweet", "Hello Twitter. (Test post, please ignore)", 60, PRIVATE);
var EventSource = require('eventsource');
@Hypnopompia
Hypnopompia / cc3000flood.py
Created February 13, 2014 03:54
Kill CC3000 ARP cache with ARP flooding
#! /usr/bin/env python
# on Ubuntu:
# sudo apt-get install python-scapy
# You'll need to run this script as root to send these ARP packets
from scapy.all import *
victim = '192.168.1.131' # ip address of CC3000
@Hypnopompia
Hypnopompia / gist:2855492
Created June 1, 2012 22:26
Twitter firehose client in nodejs
// Twitter firehose client.
// Written by TJ Hunter
// https://dev.twitter.com/docs/api/1/post/statuses/filter
var https = require('https');
// Command line args
var username = process.argv[2];
var password = process.argv[3];
var keyword = process.argv[4] || "zombie";
@Hypnopompia
Hypnopompia / scope.php
Created April 18, 2012 15:10
Facebook Permissions
<?php
$scope = "";
// From: https://developers.facebook.com/docs/authentication/permissions/
/*********************
* User and Friends Permissions
* You can ask for the following permissions for users and friends in the scope parameter as part of the authentication process.
* If you are using the Enhanced Auth Dialog, the following permissions are not user-revokable within the authentication flow.
* If you request these permissions from the user as part of first-time authentication, the user must grant these permissions
@Hypnopompia
Hypnopompia / loggly-access.php
Created December 10, 2011 01:22
PHP Script to send apache access and error log lines to loggly.
<?php
/*
loggly-access.php
Sends apache access log lines to loggly via HTTP input
Author: TJ Hunter (tjhunter@gmail.com)
Add the following line to your apache config:
CustomLog "|php /path/to/loggly-access.php VirtualHostServerNameHere logglyInputHash" combined
*/