Skip to content

Instantly share code, notes, and snippets.

View AlexanderMike's full-sized avatar

Mike Alexander AlexanderMike

View GitHub Profile
@AlexanderMike
AlexanderMike / gist:9c79582178ca2e002416d8c83839f714
Created May 9, 2019 04:09
curl sed shell script to get datetime from api
curl -s "http://worldtimeapi.org/api/ip"|sed 's/\(.*"datetime":"\)\(.*\)\(","abb.*$\)/datetime: \2/'
#datetime: 2019-05-06T17:45:26.224134-05:00
@AlexanderMike
AlexanderMike / base64decode.py
Created December 12, 2018 18:40
base64 encoding python
#base64 needs bytes like object so encode string first
import base64
test = 'test'
test = test.encode('utf-8')
test_b64encoded = base64.b64encode(test)
#!/bin/bash
#Get all files older than current month and archive them
OIFS=$IFS
IFS=$'\n'
curr_seconds=$(date +%s)
prev_seconds=$(date -v1d -v11H -v59M -v59S -v-1d +%s)
echo $prev_seconds
https://security.stackexchange.com/a/19658
import io
#http://stackoverflow.com/questions/22459020/python-decode-utf-16-file-with-bom
#https://docs.python.org/2/library/codecs.html
#http://stackoverflow.com/questions/19644507/convert-different-encodings-to-ascii
import io
import os
import math
os.chdir('C:\Users\malexander\Dropbox\SFMC\Admin\Backups')
>>>title_list = ['psm']
>>>de_types = ['3P','IP','NL']
>>> for x in title_list:
for y in de_types:
de = '_'.join([x,y,'import'])
print de
psm_3P_import
psm_IP_import
def shuffle(deck):
s1 = len(deck)
temp_deck = []
for card in deck:
temp_deck.append(card)
shuffled_deck = []
s2 = s1 - 1
while s1 != 0:
rand1 = random.randint(0,s2)
shuffled_deck.append(temp_deck.pop(rand1))
Here's a handy query for finding duplicates in a table. Suppose you want to find all email addresses in a table that exist more than once:
http://www.petefreitag.com/item/169.cfm
SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )
http://stackoverflow.com/questions/10908212/select-all-checkbox-by-javascript-or-console
var allInputs = document.getElementsByTagName("input");
for (var i = 0, max = allInputs.length; i < max; i++){
if (allInputs[i].type === 'checkbox')
allInputs[i].checked = true;
}
<!--http://www.webdevdoor.com/javascript-ajax/javascript-function-check-uncheck-checkboxes-->
@AlexanderMike
AlexanderMike / lxml_test.py
Created February 17, 2016 21:29
Testing LXML parsing in Python for espn.com, MLB 2015 standings
'''Notes from an experiment in XML using Windows 7 and Python 2.7 trying to
follow example from:
http://docs.python-guide.org/en/latest/scenarios/scrape/#.
1) to get lxml on Windows machine had to install wheel file for libxml2.dll as
pip install failed repeatedly (also Visual C++ 9.0)
2) The tried to parse MLB 2015 stats from this page:
http://espn.go.com/mlb/standings/_/group/overall
where xpath was //*[@id="main-container"]/div/section/div[2]/div/div[2]/table/tbody/tr[1]/td[2]
however, this failed because browser xpath is not raw, and browser inserted a tbody where none existed in
source code. Therefore, my queries failed until I went element by element!'''