Skip to content

Instantly share code, notes, and snippets.

@kaugesaar
kaugesaar / mod.vb
Created February 14, 2024 16:58
SHA256 Excel Formula
Function SHA256Hash(Text As String) As String
Dim asc As Object
Dim enc As Object
Dim TextBytes() As Byte
Dim HashBytes() As Byte
Dim i As Integer
Set asc = CreateObject("System.Text.UTF8Encoding")
Set enc = CreateObject("System.Security.Cryptography.SHA256Managed")

Keybase proof

I hereby claim:

  • I am kaugesaar on github.
  • I am kaugesaar (https://keybase.io/kaugesaar) on keybase.
  • I have a public key ASD7LjbP-URx80ZScAvtOuo_YOrbKrv0_hbnDItCKlTSjwo

To claim this, I am signing this object:

function main() {
var labels = getAllBudgetLabels();
parseCampaignBudgets(labels,'videoCampaigns')
parseCampaignBudgets(labels,'campaigns')
parseCampaignBudgets(labels,'shoppingCampaigns')
}
function getMaxSpendFromLabel(label) {
return parseInt(label.getName().replace('budget::',''));
@kaugesaar
kaugesaar / resize.js
Last active March 17, 2017 12:19
Resize an image based on the area of another image while maintaining the same ratio as before.
/**
* Resize an image based on the area of another image
* while maintaining the same ratio as before.
*
* @param width {Number} the width of the image not to be resized
* @param height {Number} the height of the image not to be resized
* @param rWidth {Number} the width of the image to be resized
* @param rHeight {Number} the height of the image to be resized
* @param resize {Float} decimal percentage of how much to resize
*/
if(new Date().getDay() === 1) {
var headers = document.getElementsByClassName('_5pbw');
for(var i = 0; i < headers.length; i ++) {
var e = headers[i];
if(e.innerText.indexOf('Bubach') > -1) {
var notHidden = true;
var parent;
while(notHidden) {
parent = parent.parentNode || e.parentNode;
if(typeof parent.className !== 'undefined') {
@kaugesaar
kaugesaar / diffForHumans.js
Last active April 1, 2020 12:22
The difference between now and an utc-timestamp readable for humans.
/**
* The difference between now and a prior or an
* upcoming event, returned as readable text for humans.
*
*
* @param {Number} unixTime milliseconds that have elapsed since
* 00:00:00 Thursday, 1 January 1970
* @param {boolean} ms set true if unixTime is not in milliseconds
* @return {String}
*/
var BayesianTesting = function() {
/**
* The propability B beats A in a binary-outcome test
* (eg. conversion rate). Based on
* http://www.evanmiller.org/bayesian-ab-testing.html
*
* @param {int} alphaA number of success for A
* @param {int} betaA number of failures for A
* @param {int} alphaB number of success for B
@kaugesaar
kaugesaar / GeoSearch.js
Last active October 17, 2021 12:37
Fake your Google searches location with uule parameter.
var GeoSearch = function() {
this.baseUrl = 'https://www.google.se/search?';
this.pws = true;
this.lang = 'sv';
var key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
var makeHash = function(loc) {
loc = loc.toLowerCase().replace(/[åä]/g,'a').replace(/[ö]/g,'o');
return 'w+CAIQICI' + key[loc.length%key.length] + btoa(loc).replace(/\=/g,'').trim();
@kaugesaar
kaugesaar / mcc-ad-disaproval-reasons.js
Last active March 21, 2016 00:19 — forked from russorat/mcc-ad-disaproval-reasons.js
This script will run through all your AdWords accounts and look for Ads that have been disapproved
/********************************************************************************
* This script will run through all your AdWords accounts and look for Ads that
* have been disapproved
*
* @author Russell Savage <russellsavage@gmail.com>
* @version 1.1
* - added functionally to run on specific accounts.
*
* FreeAdWordsScripts.com
*
if(! Date.toAdWordsString) {
Date.prototype.toAdWordsString = function () {
var y = String(this.getFullYear());
var m = this.getMonth() + 1;
var d = this.getDate();
m = (m < 10) ? '0' + m : String(m);
d = (d < 10) ? '0' + d : String(d);
return y + m + d;
};
}