Skip to content

Instantly share code, notes, and snippets.

@himalay
himalay / explain.sh
Last active August 21, 2018 21:37 — forked from jacksonp/explain.sh
# Add this to ~/.bash_profile or ~/.bashrc
explain () {
if [ "$#" -eq 0 ]; then
while read -p "Command: " cmd; do
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
done
echo "Bye!"
elif [ "$#" -eq 1 ]; then
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1"
else

Header 1

Header 2

Header 3 ### (Hashes on right are optional)

Header 4

Header 5

Markdown plus h2 with a custom ID ## {#id-goes-here}

Link back to H2

This is a paragraph, which is text surrounded by whitespace. Paragraphs can be on one

@himalay
himalay / CROP.md
Last active August 29, 2015 14:17 — forked from FokkeZB/CROP.md
Image (cropping) CommonJS lib for Titanium CROP.md Often I need to display a user-provided picture in an ImageView in such a way that the whole ImageView is filled with as much of the picture possible. This is how I do it: var image = require('image'); Ti.Media.showCamera({ mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO], success: function (e) { myImage…

Often I need to display a user-provided picture in an ImageView in such a way that the whole ImageView is filled with as much of the picture possible.

This is how I do it:

var image = require('image');

Ti.Media.showCamera({
        mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
 success: function (e) {
@himalay
himalay / README.md
Last active August 29, 2015 14:17 — forked from FokkeZB/README.md
Setting default unit of measurement.

To make sure your lay-outs look pretty much the same on all devices, including the thousands of different Android resolutions and densities, it's always best to use the 'dp' unit. However, typing '10dp' instead of 10 is quite a pain. A pain you can easily take away by changing the default unit in your tiapp.xml.

@himalay
himalay / app.js
Last active August 29, 2015 14:17 — forked from FokkeZB/app.js
How to decide what window to open first in Titanium Alloy. You can remove all markup from the index.xml view (the file itself must be there!) and then create another controller based on your logic.
/* /Resources/app.js - Generated by Alloy, here to understand the flow */
var Alloy = require("alloy"), _ = Alloy._, Backbone = Alloy.Backbone;
Alloy.createController("index");
@himalay
himalay / singletap.js
Last active August 29, 2015 14:17 — forked from FokkeZB/singletap.js
Snippet from Blain Hamon on how to prevent Titanium from queing up multiple tap events
function handleOnce(funct) {
var flag = false;
return function(e) {
if (flag) return;
flag = true;
setTimeout(function() {
flag = false;
}, 0);
funct(e);
@himalay
himalay / app.js
Last active August 29, 2015 14:17 — forked from FokkeZB/app.js
Code Revisions 2 Stars 8 Forks 1 Embed URL HTTPS clone URL You can clone with HTTPS or SSH. Embedding a YouTube video in Titanium
var win = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
url: 'http://www.youtube.com/embed/' + myVideoID + '?autoplay=1&autohide=1&cc_load_policy=0&color=white&controls=0&fs=0&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0',
enableZoomControls: false,
scalesPageToFit: false,
scrollsToTop: false,
showScrollbars: false
});
@himalay
himalay / index.tss
Last active August 29, 2015 14:17 — forked from FokkeZB/index.tss
Who said you can't do padding in Titanium (Alloy)?
"#wrapper": {
// Set wrapper to adjust it's size to it's contents
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
// Set stuff like borders and backgrounds on the wrapper
backgroundColor: "red"
}
@himalay
himalay / share.js
Last active August 29, 2015 14:17 — forked from FokkeZB/share.js
A simple example of using Android intents to share texts, URLs and files like you could do using 0x82's ShareKit module (https://marketplace.appcelerator.com/apps/741) or any other similar module (TiSocial: https://github.com/viezel/TiSocial.Framework) for iOS
function share(options) {
if (OS_ANDROID) {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND
});
intent.putExtra(Ti.Android.EXTRA_SUBJECT, options.title);
@himalay
himalay / app.tss
Last active August 29, 2015 14:17 — forked from FokkeZB/app.tss
Hide titlebar on Android launch/splash screen
// app/styles/app.tss
"Window": {
navBarHidden: false
}