Skip to content

Instantly share code, notes, and snippets.

View ariesmcrae's full-sized avatar
💭
typescript, node.js, aws, java, go (golang)

Aries McRae ariesmcrae

💭
typescript, node.js, aws, java, go (golang)
View GitHub Profile
@ariesmcrae
ariesmcrae / ReadEmbeddedJSON
Created July 9, 2014 06:19
Javascript that reads an embedded JSON
<!doctype html>
<html>
<head>
<script>
function displayJSON() {
var scheduler = [
{"id": 7, "name": "Abc", "isOn": false, "count": 5, "date": "2014-01-05"},
{"id": 3, "name": "Gringo", "isOn": false, "count": 97, "date": "2017-09-21"},
{"id": 99, "name": "Schedule 1", "isOn": true, "count": 432, "date": "2013-12-16"},
{"id": 12, "name": "lol", "isOn": false, "count": 56, "date": "2014-10-13"}
@ariesmcrae
ariesmcrae / ReadExternalJSON
Created July 9, 2014 06:21
Read external JSON file using JavaScript
<!doctype html>
<html>
<head>
<script>
function init() {
loadJSON(function (response) {
displayJSON(response);
});
} // init
@ariesmcrae
ariesmcrae / RxJavaExamples.java
Last active November 19, 2019 18:05
RxJava examples using Java 8 Lambda. Examples include zip, map, take, filter, reduce
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import rx.Observable;
import rx.Observer;
import rx.functions.Func2;
public class RxJavaExamples {
@ariesmcrae
ariesmcrae / ping.bat
Last active May 27, 2017 05:47
Windows batch file what will ping all servers in servers.txt and will output offline.txt if the server can't be pinged. It can't discriminate between server-not-found or server-is-down.
@echo off
del log.txt 2>nul
for /f "delims=" %%a in (servers.txt) do ping -n 2 %%a >nul && (
>>online.txt echo %%a&echo %%a online) || (
>>offline.txt echo %%a&echo %%a offline)
@ariesmcrae
ariesmcrae / ping.py
Last active July 30, 2023 10:07
Python3 script that will ping a list of servers in an external file. Output is unreachable_or_timeout.txt, server-not-found.txt, and server-ok.txt
import subprocess
import csv
def ping(hostname):
p = subprocess.Popen('ping ' + hostname, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
pingStatus = 'ok';
for line in p.stdout:
output = line.rstrip().decode('UTF-8')
@ariesmcrae
ariesmcrae / DiffTool-IgnoreRowPositioning.py
Last active May 27, 2017 05:46
Compares two files together. If not the same, it writes the difference in error.txt. It disregards position of data within rows. For example in file1.txt, if row data 'ABC' exists in Row 10, but also exists in file2.txt but in Row 20, it will not report it as different. However, if file1.txt ABC is not found in file2.txt, it will report it.
'''
This program is free software.
It comes without any warranty, to the extent permitted by applicable law.
You can redistribute it and/or modify it under the terms of the WTFPL Version 2, as published by Sam Hocevar.
See wikipedia.org/wiki/WTFPL for more details.
Created on 2014-25-11
@author: Aries McRae
'''
@ariesmcrae
ariesmcrae / ChangeFilePermissionRecursively
Created April 23, 2015 05:46
Change file permission to all directories
#!/bin/bash
for dir in /opt/aaa/bbb/ccc/*/
do
dir=${dir%*/}
echo $dir
cd $dir
chmod 775 *
done
@ariesmcrae
ariesmcrae / Restful API HATEOAS Employees example
Last active May 27, 2017 05:46
curl api.mycompany.com/v1/employees
// curl api.mycompany.com/v1/employees
[
{
"employeeId":"1",
"firstName":"Tim",
"surname":"Smith",
"links":[
{
"rel":"self",
"href":"http://api.mycompany.com/v1/employees/1"
@ariesmcrae
ariesmcrae / Restful API HATEOAS Excel example
Last active May 27, 2017 05:48
curl api.mycompany.com/v1/summaries
// curl api.mycompany.com/v1/summaries
[
{
"key":"Summary_2016_09_05_20_52_48",
"value":"http://api.mycompany.com/v1/summaries/Summary_2016_09_05_20_52_48.xls",
"links":[
{
"rel":"self",
"href":"http://api.mycompany.com/v1/summaries/Summary_2016_09_05_20_52_48"
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>React Counter</title>
</head>
<body>
<br/><br/>
<div id="app"></div>