Skip to content

Instantly share code, notes, and snippets.

View ralphchristianeclipse's full-sized avatar
🏠
Working from home

Ralph Eclipse ralphchristianeclipse

🏠
Working from home
View GitHub Profile
@ralphchristianeclipse
ralphchristianeclipse / get-invoicely-preview-links.js
Created January 22, 2020 23:59
Get Invoicely Invoice Preview Links on Reports Page
Stop-Process -Name f5fpclientW
$wshell = New-Object -ComObject wscript.shell;
$config = ([xml](Get-Content account.xml)).root
Write-Host $config
Invoke-Item -path "C:\Program Files (x86)\F5 VPN\f5fpclientW.exe"
Start-Sleep 1
$wshell.AppActivate((Get-Process f5fpclientW).MainWindowTitle)
Start-Sleep 1
$wshell.SendKeys('{ENTER}')
Start-Sleep 4
@ralphchristianeclipse
ralphchristianeclipse / basic-auth-url-login.js
Created January 23, 2019 16:51
Login the user using url encoded username and password for Basic Auth Type Authorization Header
function loginWithBasicAuth(options) {
options.secure = options.secure === undefined ? true : options.secure;
var popup = window.open();
var credential =
encodeURIComponent(options.username) +
':' +
encodeURIComponent(options.password);
var protocol = options.secure ? 'https:' : 'http:';
var link = protocol + '//' + credential + '@' + options.url;
popup.location.href = link;
const parseColonBasedValues = text => {
const regex = /(?<key>.*):\s*(?<value>[^;\n]*)/gim;
let result = {};
let parsed;
return new Promise((resolve, reject) => {
while ((parsed = regex.exec(text))) {
const { key, value } = parsed.groups;
console.log(key, value);
result[key] = value;
}
@ralphchristianeclipse
ralphchristianeclipse / automagica-notepad.py
Last active November 20, 2018 19:17
Use automagic to automate writing from csv file to notepad and open a screenshot
from automagica import *
import csv
# Business Objects
def AttachToNotepad():
isRunning = ProcessRunning(name="notepad")
if not isRunning:
notepad = OpenNotepad()
@ralphchristianeclipse
ralphchristianeclipse / cipher.cpp
Created November 16, 2018 13:04
Cipher on C++
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
int cipher(int f, int s, int mf, int ms);
@ralphchristianeclipse
ralphchristianeclipse / cipher.js
Last active November 12, 2018 02:09
Cipher JS TJ
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const charCipher = (first, second) => (firstIndex, secondIndex) => {
const firstIndexNum = firstIndex + 1
const secondIndexNum = secondIndex + 1
const result = ((first * firstIndexNum) + (second * secondIndexNum)) % 26 + 1
return result - 1
}
@ralphchristianeclipse
ralphchristianeclipse / highlightedSpeak.js
Last active November 9, 2018 19:37
Speak Highlighted (press S to Speak X to Stop )
const speech = new SpeechSynthesisUtterance();
const speaker = speech => message => {
speech.text = message;
speechSynthesis.speak(speech);
};
const speak = speaker(speech);
@ralphchristianeclipse
ralphchristianeclipse / factorio-mod-downloader.js
Created September 28, 2018 21:08
Factorio Mod Source Code Link scraper and downloader
const getSourceCodeLinks = () => {
const hrefs = document.querySelectorAll(".source-code-link");
return Array.from(hrefs).map(href => href.href);
};
const getModDownloadLinks = () =>
getSourceCodeLinks().map(link => `${link}/archive/master.zip`);
const downloadLinks = links => Promise.all(links.map(link => fetch(link)));
async function getJSON(url) {
return await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
}).then(result => result.json())
}