Skip to content

Instantly share code, notes, and snippets.

View fethica's full-sized avatar
:octocat:

Fethi El Hassasna fethica

:octocat:
View GitHub Profile
@fethica
fethica / gist:4740230
Last active December 12, 2015 07:58
JavaScript: Detect IE in jQuery
if($.browser.msie){//if it's Microsoft Internet Explorer
alert($.browser.version);//Browser version
}
@fethica
fethica / JavaScript: Change a class every 2 seconds
Last active December 14, 2015 02:59
A simple jQuery function to change a class every 2 seconds.
function switchClass(){
var delay = 2000;
var colors = new Array ("red", "grey", "green", "blue");
var i = 0;
setInterval(function(){
$('span').removeClass(colors[i]);
i++;
@fethica
fethica / gist:5053305
Created February 28, 2013 00:58
Style a button with Sass
border: 1px solid darken($base-color, 20%);
text-shadow: 0 -1px 0 darken($base-color, 10%);
@include box-shadow(inset 0 1px 0 lighten($base-color, 20%));
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fethica
fethica / bdi.css
Created May 1, 2013 23:10
Simulate the <bdi></bdi> tag in IE and older browsers, to mix english content with right to left languages (arabic) More info: http://www.w3.org/International/questions/qa-bidi-css-markup
.bdi{
direction: rtl;
unicode-bidi: embed;
}
@fethica
fethica / indentOutput.cpp
Created May 30, 2013 01:58
Indent output to ofstream.
void indentedOutput(ostream &outStream, const char *message, bool &newline)
{
while (char cur = *message) {
if (newline) {
outStream << " ";
newline = false;
}
outStream << cur;
if (cur == '\n') {
newline = true;
@fethica
fethica / clickableDIV.js
Created June 19, 2013 23:49
Make Entire Div Clickable
$(".myBox").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
@fethica
fethica / UITextView.m
Created June 30, 2013 00:57
Dynamic UITextView height
textView.text = @"some text";
CGRect rect = textView.frame;
rect.size.height = textView.contentSize.height;
textView.frame = rect;
@fethica
fethica / UITextView.m
Created June 30, 2013 00:58
Size-to-Fit Text in UITextView
#define kDefaultFontSize 24.0
myTextView.text = @"Some long string that will be in the UITextView";
myTextView.font = [UIFont systemFontOfSize:kDefaultFontSize];
//setup text resizing check here
if (myTextView.contentSize.height > myTextView.frame.size.height) {
int fontIncrement = 1;
while (myTextView.contentSize.height > myTextView.frame.size.height) {
myTextView.font = [UIFont systemFontOfSize:kDefaultFontSize-fontIncrement];
@fethica
fethica / clearfix.scss
Created July 18, 2013 04:04
Clear floats with Sass
.group {
zoom: 1;
&:before,
&:after {
content: '';
display: table;
}
&:after {
clear: both;
}