Skip to content

Instantly share code, notes, and snippets.

Andre-John Mas ajmas

Block or report user

Report or block ajmas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ajmas
ajmas / screenctl
Last active Oct 4, 2017
Script for turning on and off a connected screen, on a Raspberry Pi
View screenctl
#!/bin/bash
## script for turning and off the connected screen
## taken from https://www.raspberrypi.org/forums/viewtopic.php?t=7570
if [ $1 = 'on' ]; then
tvservice -p
fbset -depth 8
fbset -depth 16
fbset -depth 32
@ajmas
ajmas / addAll.js
Last active Sep 4, 2017
Javascript function, for adding all numbers from 1 to n, inclusive
View addAll.js
/**
* Adds all numbers from 1 to maxInteger, inclusive
*/
function addAll (maxInteger) {
let n = maxInteger;
let m = 0;
if (n%2 === 1) {
m = n;
n = n - 1;
}
@ajmas
ajmas / array-functions.js
Created Feb 27, 2017
Collection of array function
View array-functions.js
// ref: http://stackoverflow.com/questions/1068834/object-comparison-in-javascript
function anyOfInArray (array1, array2, findIndexComparator) {
var i=0;
var containsAny= false;
findIndexComparator = function (currentValue, index, arr) {
return JSON.stringify(currentValue) === JSON.stringify(this)
//return currentValue === this;
}
@ajmas
ajmas / confgurable-password-checker.js
Last active Feb 2, 2017
Configurable Password Checker
View confgurable-password-checker.js
// This version work on simply checking something that fails a rule, though
// it may be useful to check based on estimated password strength. For this
// each function would return a value indicating strength. This value could
// be positive or negative. For example, a string longer than 16 characters
// could get a rating of +5, but being digit only get a -5. Other methods
// could simply return 0/+1.
var ruleFunctions = {
duplicateChars: function(password, min) {
var prevChar, i;
View web-sensor-proxy.js
/**
* Creates an HTTP server to allow to read the sensor data via
* HTTP. Improvements could include caching the data, to avoid
* the sensor being hit too frequently.
*
* Not tested in-situ.
*/
const express = require('express');
const app = express();
const net = require('net');
@ajmas
ajmas / download-from-google-drive.js
Last active Jan 4, 2017
Downloads a directory structure from Google Drive. Also handles exporting of the Google Docs.
View download-from-google-drive.js
const fs = require('fs-extra');
const google = require('googleapis');
const OAuth2 = google.auth.OAuth2;
const key = require('./key.json');
var baseFolder = 'base';
function downloadFile(file, path) {
setTimeout(function () {
var filePath = path.concat(file.name).join('/');
View countryNameForCoord.js
// depends on turf and having a copy of the countries.gejson file for the value of the countryOutlines
// see: https://github.com/johan/world.geo.json as one source
findCountryName (latlon) {
var features, i, j, poly;
var point1 = turf.point([latlon[1], latlon[0]]);
if (this.countryOutlines) {
features = this.countryOutlines.features;
for (i=0; i<features.length; i++) {
@ajmas
ajmas / CoordinateParser.js
Last active Mar 31, 2016
Parsing text and producing a geo coordinate
View CoordinateParser.js
CoordinateParser = {
convertDegMinSecToDecDeg: function (deg, min, sec, direction) {
var value;
if (min === undefined) { min = 0; }
if (sec === undefined) { sec = 0; }
deg = parseFloat(deg);
min = parseFloat(min);
@ajmas
ajmas / IPv6Utils.js
Last active Mar 30, 2016
Some IPv6 utility functions I put together, improvements appreciated
View IPv6Utils.js
var ipv4Regex = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
function expandIPv6(ipv6ColonNotation) {
var pad = "0000"
var count = (ipv6ColonNotation.match(/:/g)|| []).length;
if (count == 0 || count > 7) {
// too few or too many colons
return "err";
}
@ajmas
ajmas / polar2cartesian.java
Last active Jan 20, 2016
Takes a panoramic image that is in a 'fisheye' view and unwraps it. See http://terra-azure.org/?loc=articles/programming/java/polar2cartesian for an explanation
View polar2cartesian.java
package ajmas74.experimental.graphics2d;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.DirectColorModel;
import java.awt.image.PixelGrabber;
import java.awt.image.Raster;
You can’t perform that action at this time.