Skip to content

Instantly share code, notes, and snippets.

@Arood
Arood / commit
Created May 8, 2017 14:22
git status/add/commit in one command
#!/bin/bash
status=$(git -c color.status=always status -s)
if [ "$status" == "" ]; then
printf "Nothing to commit\n"
exit 1
fi
printf "%s\n\nEnter your commit message, or cancel with Ctrl+C:\n" "$status"
@Arood
Arood / gist:e418a5548c72f82538a9
Created August 29, 2014 10:04
Takes screenshots of a UI control in Titanium and all its parents
var Loopy = function(control, list) {
if (!control || control.apiName.substr(0,5) !== "Ti.UI") {
var html = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "layers.html");
var markup = '<html><head></head><body>';
var toWrap = '';
list.forEach(function(item) {
@Arood
Arood / gist:92046dca9434ef798cfe
Last active August 29, 2015 14:01
Send form data to Jira issue as comment
<?php
$username = 'xxx';
$password = 'xxx';
$host = 'http://xxx';
$issue = 'KEY-000';
if (count($_POST) > 0) {
$body = "";
@Arood
Arood / server.js
Created November 21, 2013 10:30
Quick web server for static files
var fs = require('fs'),
http = require('http');
http.createServer(function (req, res) {
fs.readFile(__dirname + "/." + req.url.split("?")[0], function (err,data) {
if (err) {
res.writeHead(404);
res.end(JSON.stringify(err));
return;
}
@Arood
Arood / animate.js
Created May 25, 2013 13:18
A wrapper for http://billdawson.github.io/ti-android-animation/, to make the API more like the regular Ti.UI.Animation
/**
* A wrapper for http://billdawson.github.io/ti-android-animation/,
* to make the API more like the regular Ti.UI.Animation
*
* Notes:
* - I haven't added a wrapper for "curving" yet
* - Added "scale", "translateX" and "translateY" as separate properties that can be used instead of "transform" on iOS
* - You can only set "top" and "left" on Android, "right" or "bottom" doesn't work (since the position is animated in X or Y)
* - AnchorPoint doesn't seem to work on Android
*
@Arood
Arood / deploy
Created April 21, 2013 20:22
Almost like my watch-script, but will only run once, and will minify the code as well.
#!/bin/sh
JS_PATH="_js"
FINAL_JS="scripts.js"
SASS_PATH="_sass"
FINAL_CSS="."
echo " ≫ Building and minifying assets."
@Arood
Arood / watch
Created April 21, 2013 20:11
Watches for changes in JavaScript and Sass-folders
#!/bin/sh
JS_PATH="_js"
FINAL_JS="scripts.js"
SASS_PATH="_sass"
FINAL_CSS="."
sha=0
previous_sha=0
@Arood
Arood / images2android.sh
Created October 10, 2012 18:11
Convert iPhone-resources to Android (for Titanium)
type mogrify >/dev/null 2>&1 || { echo >&2 "» This script requires mogrify. Please install ImageMagick first!"; exit 1; }
rm -rf Resources/android/images
mkdir Resources/android/images
mkdir Resources/android/images/res-xhdpi
mkdir Resources/android/images/res-mdpi
echo " » Copying the splash screen"
cp Resources/iphone/Default.png Resources/android/images/res-mdpi/default.png
cp Resources/iphone/Default@2x.png Resources/android/images/res-xhdpi/default.png
@Arood
Arood / gist:2113129
Created March 19, 2012 13:55
Validate a URI
# Modified https://gist.github.com/9281 to validate a remote URI instead.
# Wouldn't surprise me if a better CLI-tool is already available, but hey,
# we might improve it later. Also: Pretty colors!
task :validate, :site_uri do | t, args|
require 'net/http'
require 'w3c_validators'
include W3CValidators