Skip to content

Instantly share code, notes, and snippets.

View joshmarinacci's full-sized avatar
💭
energized

Josh Marinacci joshmarinacci

💭
energized
View GitHub Profile
var SerialPort = require('serial-port');
var sp = new SerialPort('/dev/ttyUSB0');
sp.on('open', function() {
sp.write('<ID01><PA>', function(err, res){
if(!err) {
sp.write('<ID01><PA>$1', function(err, res) {
if(!err) {
console.log("yay!");
}
@joshmarinacci
joshmarinacci / main.rs
Created October 19, 2014 20:51
Simple ray tracer in Rust
use std::num;
struct Vector {
x:f32,
y:f32,
z:f32
}
impl Vector {
protected override void OnStart(string[] args)
{
string[] imagePathArgs = Environment.GetCommandLineArgs();
if (imagePathArgs.Length >= 2)
{
int value = 0;
if (Int32.TryParse(imagePathArgs[1], out value)) MaxCPUUsage = value;
else
{
eventLog.WriteEntry("Fail to convert parameter 1:" + imagePathArgs[1]);
private void Process()
{
while (!finalizeService)
{
PerformanceCounter PC = new PerformanceCounter();
PC.CategoryName = "Processor";
PC.CounterName = "% Processor Time";
PC.InstanceName = "_Total";
PC.ReadOnly = true;
var value = PC.NextValue();
private void SendAlertMessage(AlertType alertType, double value, long ramValue)
{
List<RTPMProcess> list = new List<RTPMProcess>();
lstPerformance = new List<PerformanceCounter>();
Process[] processes = System.Diagnostics.Process.GetProcesses();
for (int i = 0; i < processes.Length; i++)
{
PerformanceCounter pc = new PerformanceCounter("Process", "% Processor Time", processes[i].ProcessName, true);
try
{
protected override void OnStop()
{
try
{
eventLog.WriteEntry("Unsubscribe channel " + channel);
mrePubNub = new ManualResetEvent(false);
pubnub.Unsubscribe<string>(channel, UnsubscribeCallback, SubscribeMethodForConnectCallback, UnsubscribeMethodForDisconnectCallback, ErrorCallback);
mrePubNub.WaitOne(manualResetEventsWaitTimeout);
eventLog.WriteEntry("Channel " + channel + " unsubscribed.");
finalizeService = true;
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PhoneRTPM"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:System="using:System"
x:Class="PhoneRTPM.MainPage"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
private void ReceivedMessageCallbackWhenSubscribed(string result)
{
if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim()))
{
List<object> deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToListOfObject(result);
if (deserializedMessage != null && deserializedMessage.Count > 0)
{
object subscribedObject = (object)deserializedMessage[0];
if (subscribedObject != null)
{
@joshmarinacci
joshmarinacci / 1.html
Last active February 20, 2021 14:54 — forked from stephenlb/1.html
Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
Chat Output
<div id=box></div>
<script src=https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.11.min.js></script>
<script>(function(){
var pubnub = new PubNub({ publishKey : 'demo', subscribeKey : 'demo' });
function $(id) { return document.getElementById(id); }
pubnub.publish({
channel : 'mouseMoves',
message : {
x: 400,
y: 200
}
});