Skip to content

Instantly share code, notes, and snippets.

View obahareth's full-sized avatar
🚗
Building @ejaro

Omar Bahareth obahareth

🚗
Building @ejaro
View GitHub Profile
View Browser-based-approach.js
$("a#bookmark").click(function(e)
{
e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
var bookmarkUrl = this.href;
var bookmarkTitle = this.title;
if ($.browser.mozilla) // For Mozilla Firefox Bookmark
{
window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
@obahareth
obahareth / .htaccess
Created August 8, 2013 14:02
Cross Browser Font Declaration
View .htaccess
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
@obahareth
obahareth / Asset.js
Created August 15, 2013 23:55
Detect If An Image Has Been Loaded
View Asset.js
$("#myImg").load(function()
{
alert('I loaded!');
}).each(function()
{
if(this.complete)
$(this).load();
});
@obahareth
obahareth / Directions
Last active January 2, 2016 09:09 — forked from ebinnion/.m file
View Directions
Declare an array that will hold the coordinates within the viewDidLoad function/method. Then fill the array with the coordinates. Then define a MKPolygon pointer that will use that array. Last, add the overlay to the map.
View BuildConfig.java
package com.deviant.security.shield;
public final class BuildConfig {
public static final String BUILD_TYPE = "debug";
public static final boolean DEBUG;
public static final String FLAVOR = "";
public static final String PACKAGE_NAME = "com.deviant.security.shield";
public static final int VERSION_CODE = 4;
public static final String VERSION_NAME = "2.2";
View gist:707a02d6fab49fa6e86c
/* Taken zigmob's (http://forums.macrumors.com/showthread.php?t=1742566) workaround a step further
And added some triggers to clean up these dodgy character combinations (ff, fi, fl).
Still crashes on initial message read but saves having to manually run the sql query eve time a message contains the character combinations */
-- Working well for me so far --
CREATE TRIGGER insert_Ff AFTER INSERT ON ZWAMESSAGE
BEGIN
UPDATE ZWAMESSAGE
SET ZTEXT = replace( ZTEXT, 'ff', 'f f')
WHERE ZWAMESSAGE.ZTEXT like '%ff%';
@obahareth
obahareth / 0_reuse_code.js
Created August 29, 2014 07:36
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@obahareth
obahareth / setup_os_x.sh
Last active October 22, 2023 12:57
A script to setup OS X with the apps and formulas I use.
View setup_os_x.sh
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
# Tap sources we need
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew tap caskroom/versions
@obahareth
obahareth / speed_up_terminal_launch.sh
Last active May 25, 2022 12:41
Speed up launch of Terminal or iTerm 2
View speed_up_terminal_launch.sh
# Apparently Apple keeps system logs in this folder as .asl files. They're
# loaded into terminal sessions and can slow things down when there's a lot of
# them.
#
# Taken from:
# https://ariejan.net/2011/11/08/fixing-a-slow-starting-terminal-or-iterm2-on-mac-os-x/
sudo rm /private/var/log/asl/*.asl
@obahareth
obahareth / resizer.rb
Last active October 23, 2015 10:11
Resize Images Using MiniMagick While Preserving Subdirectory Structure
View resizer.rb
require 'fileutils'
require 'mini_magick'
# Get all files of any type within the 4x folder, within any subdirectory
sources = Dir.glob(File.join('**', '4x', '**', '*.png'))
# Create our target directories, and the size factor for that directory
target_directories = [
{ name: '2x', size_factor: 0.5 },
{ name: '1x', size_factor: 0.25 }