Skip to content

Instantly share code, notes, and snippets.

Avatar

Mario Gudelj twoblokeswithapostie

View GitHub Profile
@twoblokeswithapostie
twoblokeswithapostie / gist:9359477
Created Mar 5, 2014
Code using Momentjs for finding, today, this weekend, this months and next month to and from dates
View gist:9359477
// JavaScript code that finds dates for today, this weekend, this month, next month
// This weekend = next Sat and Sun
// This month = today to end of this month
// Next month = 1st of next month = end of next month
// Useful on Business Catalyst web app search form for searching from-to dates
// Requires jquery and moment.js
$(document).ready(function(){
$('#today_nav').on("click", function(){
@twoblokeswithapostie
twoblokeswithapostie / gist:9b3e7314ffc9de6e7bb94ff174594e3b
Created Mar 31, 2017
Boto3 suddenly stops authenticating with valid credentials
View gist:9b3e7314ffc9de6e7bb94ff174594e3b
Update system date with:
sudo ntpdate us.pool.ntp.org
That'll fix it!
@twoblokeswithapostie
twoblokeswithapostie / organisation_structured_data_example
Created Sep 8, 2016
Structured data example for an organisation
View organisation_structured_data_example
<div class="contact-details" itemscope="" itemtype="http://schema.org/Organization"><span itemprop="name" class="hide">Shimmering Careers</span><p><b style="font-size: 1.2em; line-height: 1.6em;">Our Offices:</b></p><p itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress"><span itemprop="streetAddress">1777 Borel Place, Suite 440</span>, <span itemprop="addressLocality">San Mateo</span>, <span itemprop="addressRegion">CA</span><span itemprop="postalCode"> 94402</span></p><p itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress"><span itemprop="streetAddress">1220 University Drive, Suite 104</span>, <span itemprop="addressLocality">Menlo Park</span>, <span itemprop="addressRegion">CA</span><span itemprop="postalCode"> 94025</span></p><p><b>Phone:</b>&nbsp;<a data-original-title="" href="tel:650-464-0085" title=""><span itemprop="telephone">650-464-0085</span></a></p><p><span><b>Toll-Free:&nbsp;</b></span><a data-original-title="" href="tel:1-877-796-9737" title="Toll-fr
View gist:84b43f046c9099a57ce7
// jQuery shuffle plugin usage $('el').shuffle();
(function($){
$.fn.shuffle = function() {
var elements = this.get();
var copy = [].concat(elements);
var shuffled = [];
var placeholders = [];
@twoblokeswithapostie
twoblokeswithapostie / gist:ba738b283134ad91d664
Last active Aug 29, 2015
Delete a list of CRM records from BC by reading a CSV file
View gist:ba738b283134ad91d664
from suds import WebFault
from suds.client import Client
from bc_api.models.crm import *
import csv
def delete_from_bc(site, entityId):
url = str(site.secure_site_url + 'catalystwebservice/catalystcrmwebservice.asmx?WSDL')
client = Client(url)
try:
response = client.service.Contact_DeleteByEntityID(
@twoblokeswithapostie
twoblokeswithapostie / gist:0eafef3888506190a977
Created Jun 15, 2015
BC to Bootstrap form converter - INCOMPLETE but almost there
View gist:0eafef3888506190a977
from bs4 import BeautifulSoup
## TODO: Add wrapper for non-input fields and embed fields into labels
def exctract_field(el):
print el
inputs = el.find_all('input')
if inputs:
return inputs, "input"
selects = el.find_all('select')
View find_posdcast_files_in_business_catalyst_rss_feed
# Extracts MP3 file links from Business Catalyst RSS feed
from urllib import urlopen
import re
source = urlopen('http://www.businesscatalyst.com/RSSRetrieve.aspx?ID=41&Type=RSS20').read()
link = re.compile('&lt;a href=(.*)\.mp3')
find_link = re.findall(link, source)
for link in find_link:
print "Link: %s \n" %link
View php_eval_injection_clean_in_python
import os
to_replace = """eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmco...9DQp9"));"""
for dname, dirs, files in os.walk("/Users/mariogudelj/code/device.com/public_html/"):
for fname in files:
fpath = os.path.join(dname, fname)
with open(fpath) as f:
s = f.read()
found = s.find(to_replace)
if(found != -1):
print fpath