Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / app.tss
Created April 8, 2015 10:00
So here is a really simple example that will get you started. To try this create a new default Alloy app and then use the bold filenames to create a new file and then copy the code in, add new files as required. Important; removed the contents of the index.tss but leave the file - just in case anything conflicts, will not kill anything, just may…
"Window": {
backgroundColor: '#fff'
},
"Label": {
color: '#000',
font: {
fontWeight: 'bold'
}
}
@himalay
himalay / auto-wall
Last active June 22, 2024 19:00
Sets random wallpaper every 30 minutes using feh(A lightweight and powerful image viewer).
#!/usr/bin/bash
img=(`find ~/pictures/wallpapers/ -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image' | cut -d':' -f1`)
while true
do
feh --bg-scale "${img[$RANDOM % ${#img[@]} ]}"
sleep 30m
done

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 / 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
@himalay
himalay / cheatsheet.md
Created July 23, 2015 17:05
Markdown Cheat Sheet

Markdown Cheat Sheet

This is a sample markdown file to help you write Markdown quickly :)

If you use the fabulous [Sublime Text 2/3 editor][ST] along with the [Markdown Preview plugin][MarkdownPreview], open your ST2 Palette with CMD+⇧+P then choose Markdown Preview in browser to see the result in your browser.

Text basics

this is italic and this is bold . another italic and another bold

<style type="text/css">
.tooltip{
display: inline;
position: relative;
}
.tooltip:hover:after{
background: #333;
background: rgba(0,0,0,.8);
// ==UserScript==
// @name Twitter Mobile - Enter to send message
// @version 0.4
// @description This script allows user to send message by pressing the enter key on Twitter Mobile DM
// @author himalay
// @namespace https://himalay.com.np
// @include *://mobile.twitter.com/messages/*
// @run-at document-end
// ==/UserScript==