Skip to content

Instantly share code, notes, and snippets.

View alexcu's full-sized avatar

Alex Cummaudo alexcu

View GitHub Profile
@alexcu
alexcu / ajax.js
Created August 13, 2017 06:59
AJAX in 14 lines of JavaScript
function ajax(url, callback, data, x) {
try {
x = new(this.XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0')
x.open(data ? 'POST' : 'GET', url, 1)
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
x.setRequestHeader('Content-type', 'application/json')
x.onreadystatechange = function () {
x.readyState > 3 && callback && callback(x.responseText, x)
}
x.send(JSON.stringify(data))
@alexcu
alexcu / bookmarklet_put.js
Last active March 31, 2017 01:09
FutureLearn Scraper
(function(){var s=document.createElement('script');s.src='https://gist.githubusercontent.com/alexcu/9204ea1c7ccfa4e42d443ab35f3d406e/raw/b11a51f15a7656b8746000616435ae779a5d21ed/put.js';document.body.appendChild(s);})();
@alexcu
alexcu / SpamReport.applescript
Created November 26, 2016 05:22
Service to report spam to Apple
--
-- Implements phishing suggestions by Apple
-- http://www.apple.com/legal/more-resources/phishing/
--
using terms from application "Mail"
-- Strip the domain from an email address
on domainOf(address)
set atIndex to offset of "@" in address
set domain to strings (atIndex + 1) thru -1 of address
return domain
@alexcu
alexcu / FileParser.swift
Created April 21, 2016 00:10
Simple cross platform file parser for Swift
// Only import only funcs and structs we need to use
#if os(Linux)
// Linux uses Glibc
import struct Glibc.FILE
import func Glibc.fopen
import func Glibc.fgets
import func Glibc.fclose
#else
// OS X uses Darwin
import struct Darwin.C.FILE
@alexcu
alexcu / .overcommit.yml
Last active March 15, 2016 00:58
Doubtfire Overcommit Config
#
# Standard Doubtfire Overcommit Config
# See https://gist.github.com/alexcu/6e05d64d04b32bb42b4d
#
CommitMsg:
ALL:
on_warn: fail
EmptyMessage:
enabled: true
MessageFormat:
@alexcu
alexcu / CONTRIBUTING.md
Last active December 9, 2015 13:06
Sample contributing file

Contributing

We follow a Gitflow workflow

Forking

If you do not have direct write access, please fork this repository.

When you are happy with your changes, submit a pull request for code review.