Skip to content

Instantly share code, notes, and snippets.

View asiviero's full-sized avatar

Andre Siviero asiviero

  • Montréal, Québec
View GitHub Profile
#!/bin/sh
#
# Get the issue based on a WEB-\d+ regex and prepend it to the commit msg
issue=$(git symbolic-ref HEAD | sed -n 's/^.*\(WEB-[0-9][0-9]*\).*$/\1/p')
if [ -n "$issue" ]; then
echo -n "$issue " | cat - $1 > /tmp/out && mv /tmp/out $1
fi
@asiviero
asiviero / imageToGrayScale.swift
Last active August 29, 2015 14:24
A function to render a UIImage to grayscale
// Using it:
// imageview.image = imageToGrayScale(imageview.image!)
func imageToGrayScale(image: UIImage) -> UIImage {
var imageRect = CGRectMake(0,0,CGFloat(CGImageGetWidth(image.CGImage)),CGFloat(CGImageGetHeight(image.CGImage)))
var colorSpace = CGColorSpaceCreateDeviceGray()
var context = CGBitmapContextCreate(nil, CGImageGetWidth(image.CGImage), CGImageGetHeight(image.CGImage), 8, 0, colorSpace, CGBitmapInfo.ByteOrderDefault)
CGContextDrawImage(context, imageRect, image.CGImage)
//
// BorderedView.swift
// Guinder
//
// Created by Andre Siviero on 02/07/15.
// Copyright (c) 2015 Resultate. All rights reserved.
// License: MIT
import Foundation
import UIKit
@asiviero
asiviero / backgroundimage.swift
Created June 10, 2015 18:57
Background image to view in Swift
UIGraphicsBeginImageContext(self.view.frame.size);
var image = UIImage(named: "image")
image?.drawInRect(self.view.bounds)
UIGraphicsEndImageContext()
// This could also be another view, connected with an outlet
self.view.backgroundColor = UIColor(patternImage: image!)
package cz.destil.settleup.gui;
/*
* This is a small fix from MultiSpinner class as shown in:
* http://stackoverflow.com/questions/5015686/android-spinner-with-multiple-choice
*
* When every choice is selected in the original code, it also displays the default
* text. This is an updated version to make it work properly
*/
@asiviero
asiviero / skew.css
Created July 22, 2014 21:56
Skewing Bootstrap buttons with a little help from jQuery
/* Skew the button */
.btn {
transform: rotate(15deg);
-ms-transform: rotate(15deg); /* IE 9 */
-webkit-transform: rotate(15deg); /* Opera, Chrome, and Safari */
}
/* Skew back its contents */
.btn .to-skew {
transform: rotate(-15deg);
-ms-transform: rotate(-15deg); /* IE 9 */
@asiviero
asiviero / child_window.js
Created November 7, 2013 01:43
Open a child window on Alloy/Titanium
$.child_window.open();
@asiviero
asiviero / button_text.js
Last active December 27, 2015 12:09
Using a padding-like style to position text in a button. Add eventListeners to View object instead of Button.
$.button_view.addEventListener('click', function(e){
alert("Button Clicked");
});
@asiviero
asiviero / padding_example.tss
Last active December 27, 2015 11:59
Padding-like effect on Alloy/Titanium. Views are used as containers to produce an effect like padding using TSS positioning
"#element_container" : {
width : "200dp",
height : "200dp",
},
"#element_padded" : {
top : "20dp",
bottom : "20dp",
left : "20dp",
right : "20dp",
width : Ti.UI.FILL,