Skip to content

Instantly share code, notes, and snippets.

View scott-laursen's full-sized avatar

Thomas Laursen scott-laursen

View GitHub Profile
var q = require('q');
if (debug) {
q.onerror = function(err) {
console.log(err); // auto-links source map refs in stack trace
};
}
somePromiseThatThrowsAnError
.then(function() { /* do stuff */ })
function hex2a(hex) {
var str = '';
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
return str;
}
//Raw cookie
var cookie = "B417B464CA63FE780584563D2DA4709B03F6195189044C26A29770F3203881DD90B1428139088D945CF6807CA408F201DABBADD59CE1D740F853A894692273F1CA83EC3F26493744E3D25D720374E03393F71E21BE2D96B6110CB7AC12E44447FFBD810D3D57FBACA8DF5249EB503C3DFD255692409F084650EFED205388DD8C08BF7B941E1AC1B3B70B9A8E09118D756BEAFF25834E72357FD40E80E76458091224FAE8";
//Define a function scope, variables used inside it will NOT be globally visible.
(function () {
var
//the HTTP headers to be used by all requests
httpHeaders,
//the message to be shown to the user
message,
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
alias tree='find . -print | sed -e "s;[^/]*/;|____;g;s;____|; |;g"'
# http://mac.tutsplus.com/tutorials/terminal/speed-up-your-terminal-workflow-with-command-aliases-and-profile/
# The alias that takes me here - to editing these very aliases
alias edit_profile="open -e ~/.bash_profile"
# This alias reloads this file
alias reload_profile='. ~/.bash_profile'
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1>Test page</h1>
// I was unhappy about there was close to no control over the "pageControl"
// in scrollableViews, so I hacked my own
// -----
// Configuration
var pageColor = "#c99ed5";
PagingControl = function(scrollableView){
var container = Titanium.UI.createView({
height: 60
@scott-laursen
scott-laursen / gist:4000351
Created November 2, 2012 11:30 — forked from pamelafox/gist:1261016
Sending JS errors to server
window.onerror = function(message, url, line_num) {
// Standard error information
var error = '\n JS Error: ' + message + ' from ' + url + ':' + line_num;
error += '\n URL: ' + document.URL;
// User agent info, using https://github.com/caseyohara/user-agent
var user_agent = new UserAgent();
error += '\n Browser: ' + user_agent.browser_name + ' ' + user_agent.browser_version + ' | OS: ' + user_agent.os + ' | Platform: ' + user_agent.platform;
@scott-laursen
scott-laursen / MessageController.js
Created May 20, 2012 09:10 — forked from aaronksaunders/MessageController.js
pattern for Appcelerator MVC, Work in Progress
// All windows needed by controller
var MessageWindow, app = require('/common/globals');
/**
* constructor
*/
exports.MessageController = function(messageWindow) {
MessageWindow = messageWindow;
app.GlobalUpdate("messageController", this);
@scott-laursen
scott-laursen / gist:2420845
Created April 19, 2012 13:03 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@scott-laursen
scott-laursen / beacon.inlined.js
Created April 4, 2012 07:13 — forked from rakeshpai/beacon.inlined.js
Trying out with contents inlined
var _errs=["##EC##"];
window.onerror=function(){_errs.push(arguments)};
(function(f,n){function r(d,a){d=d.contentWindow||d.contentDocument;d.document&&(d=d.document);d.open();d.write(a);d.close()}function s(d,a){a=(""+a).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&quot;");return"<input type='hidden' name='"+d+"' value='"+a+"' />"}function o(d){l&&clearTimeout(l);l=setTimeout(t,200);d._when=p;q.push(d);try{if("ot"==m){for(var a,h=d.callee,e=/function\s*([\w\-$]+)?\s*\(/i,c=[],b,k;h&&10>c.length;)b=e.test(h.toString())?RegExp.$1||"{anonymous}":"{anonymous}",
k=Array.prototype.slice.call(h.arguments||[]),c[c.length]=b+"("+i(k)+")",h=h.caller;a=c.join("\n");d._stack=a}}catch(g){}}function t(){var d=[],a,b,e,c,f=0,k,g=function(a,c){d.push(s(a+f,c))};try{for(;a=q.shift();){b=k=a.m||a[0]||a;e=a.u||a[1];c=a.l||a[2];if(!(k&&k instanceof Error)&&b&&"string"==typeof b&&e&&c&&("Error loading script"===b&&/Firefox/.test(navigator.userAgent)||/originalCreateNotification/.test(b)?f--:(g("type","onerr"),g("mes