Skip to content

Instantly share code, notes, and snippets.

@adam-acosta
adam-acosta / lineCountPerFileInFolder.ps1
Created February 25, 2019 22:28
count of lines of each file in folder organized
Get-ChildItem -re -in "*.cs" |
Foreach-Object {
$fileStats = Get-Content $_.FullName | Measure-Object -line
$linesInFile = $fileStats.Lines
Write-Host "$_=$linesInFile"
}
@adam-acosta
adam-acosta / fieldlevelLoadThenAddRecipients.js
Last active July 30, 2018 04:25
fully automated script to load all coaches then add as recipient
var loadMoreCoachesAttempts = 0;
var loadMoreButtonSelector = '#main-app-content-container > div > ui-view > promote-container > div > div > div > div:nth-child(1) > promote-recipient-select > div > div.promote-recipient-select-pager.ng-scope > button';
function waitForElementToDisplay(selector, time) {
if (document.querySelector(selector) != null) {
document.querySelector(selector).click();
setTimeout(function() {
var lastScrollHeight = 0;
function autoScroll() {
var sh = document.documentElement.scrollHeight;
if (sh != lastScrollHeight) {
lastScrollHeight = sh;
document.documentElement.scrollTop = sh;
}
}
window.setInterval(autoScroll, 100);
@adam-acosta
adam-acosta / click buttons with text value.js
Last active July 29, 2018 20:16
easy fieldlevel add recipients by clicking all 'Add' buttons
// https://stackoverflow.com/a/45089849
function getElementsByText(str, tag = 'a') {
return Array.prototype.slice.call(document.getElementsByTagName(tag)).filter(el => el.textContent.trim() === str.trim());
}
var addButtons = getElementsByText('Add', 'button');
for(var i = 0; i <= addButtons.length-1; i++) {
addButtons[i].click();
}
@adam-acosta
adam-acosta / firebase_login_no-localhost.cmd
Created February 14, 2018 16:45
firebase login no-localhost; use this a lot in cloud9 c9
firebase login --no-localhost
@adam-acosta
adam-acosta / 0_reuse_code.js
Created March 4, 2014 17:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adam-acosta
adam-acosta / distinctLimitIntersect.sql
Created March 4, 2014 17:39
CartoDB PostGIS SQL Intersect. fucking cartodb temp solution to more than one row returned error, see distinctLimitIntersect.sql. not sure if the distinct and limit are both needed, i think at least limit is needed. it won't work with distinct alone.
UPDATE table
SET city_end = (
SELECT DISTINCT cityname
FROM cities
WHERE ST_Intersects(the_geom, table.the_geom)
LIMIT 1
)
@adam-acosta
adam-acosta / finalrow.vbs
Created October 16, 2012 14:53
last row, final row [excel/vba]
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
finalrow = Cells(Rows.Count, "C").End(xlUp).Row
finalrowORcolumn = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row ' or LookIn:=xlFormulas