Skip to content

Instantly share code, notes, and snippets.

@sportebois
sportebois / ApplicationDomainLoader.as
Created October 14, 2013 00:34
Loader override to workaround the swf loading issues on iOS when migrating from Air 3.5 to Air 3.9 (to be iOS7 compliant)
package com.yourdomain.utils.loader
{
import flash.display.Loader;
import flash.filesystem.File;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.utils.getTimer;
/**
@sportebois
sportebois / isFileUploadSupported.js
Created October 18, 2013 19:37
Detect if you're using an old version of Safari on iOS that do not support file upload (input="file"), i.e. if your iOS version is older than 6
/**
* @return Boolean
*/
function fileUploadIsSupported() {
'use strict';
// Look for mobile iOS 4 or 5
return !(/(iPhone|iPad|iPod)(;)?(\s\w;)?(\s)?(CPU)?(\s)?(\sOS\s)(3|4|5)/.test(navigator.userAgent));
}
@sportebois
sportebois / How-to-change-Flash-Builder-langage.md
Created October 20, 2013 22:20
How to change the langage of Flash Builder IDE

Flash Builder does not provide any setting to select the langage of your choice. The used locale is based on your OS locale. To select the locale of your choice (either to get the message in your own locale, or to get the default english error message, which are often more useful), you can just add a locale argument to your Flash Builder shortcut/alias :

Your default Flash Builder shortcut should be somethinf like this :

"C:\Program Files\Adobe\Adobe Flash Builder 4.7 (64 Bit)\FlashBuilder.exe"

You only have to add this argument :

@sportebois
sportebois / ExpressionEvaluator.as
Created November 23, 2013 20:57
Using SQLite to eval expressions
package
{
import flash.data.SQLConnection;
import flash.data.SQLResult;
import flash.data.SQLStatement;
import flash.events.SQLErrorEvent;
import flash.filesystem.File;
public class ExpressionEvaluator
{
@sportebois
sportebois / bookmarklet_JiraNbOfDays.js
Last active August 29, 2015 14:08
Parse a Jira plan view and extract the number of work days
javascript:alert("nb de jours: " + _.reduce($(".js-issue:not(.ghx-filtered) span.aui-badge").map(function(ind, item) {
console.log(item.innerText);
var res = item.innerText.match(/(\d+)?w/i);
var nbWeeks = res? 144000*parseInt(res[1]) : 0;
res = item.innerText.match(/(\d+)?d/i);
var nbDays = res? 28800*parseInt(res[1]) : 0;
res = item.innerText.match(/(\d+)?h/i);
var nbHours = res? 3600*parseInt(res[1]) : 0;
res = item.innerText.match(/(\d+)?m/i);
var nbMins = res? 60*parseInt(res[1]) : 0;
@sportebois
sportebois / bkmrk_diff_days.js
Last active August 29, 2015 14:09
Quick days diff
var s = document.createElement('script');
s.src = '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js';
document.body.appendChild(s);
s.onload = function() {
var testDate = window.prompt('Date à comparer:', 'aaaa-mm-dd');
var result = 'Il y a '+ ~~(moment.duration(moment(testDate).diff()).as('days')) + ' jours entre maintenant et '+ testDate;
window.alert(result);
};
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@sportebois
sportebois / best-tests.R
Last active August 29, 2015 14:14
Coursera - R Programming - Assignment 3 (Hospital Quality) test suites
library(testthat)
assert.best <- function () {
message("# Starting to test best(..)")
expect_equal(expected = "CYPRESS FAIRBANKS MEDICAL CENTER", object = best("TX", "heart attack"))
expect_equal(expected = "FORT DUNCAN MEDICAL CENTER", object = best("TX", "heart failure"))
expect_equal(expected = "JOHNS HOPKINS HOSPITAL, THE", object = best("MD", "heart attack"))
@sportebois
sportebois / getEc2InstanceId.sh
Last active August 29, 2015 14:23
Retrieve EC2 instance ID from the command line
curl http://169.254.169.254/latest/meta-data/instance-id
@sportebois
sportebois / getOAuthToken.py
Created January 25, 2017 16:31
Get OAUth token for Github
#!/usr/bin/env python
import requests
import argparse
parser = argparse.ArgumentParser(description='Generate a Github OAuth token.')
parser.add_argument('--user', metavar='u', dest='user', required=True, help='Github username')
parser.add_argument('--password', dest='password', required=True, help='Github password')
parser.add_argument('--2fa', dest='mfaToken', required=True, help='Github 2FA code')
args = parser.parse_args()