Skip to content

Instantly share code, notes, and snippets.

View basememara's full-sized avatar

Basem basememara

View GitHub Profile
import Foundation
import PlaygroundSupport
/// A thread-safe array.
public class SynchronizedArray<Element> {
private let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent)
private var array = [Element]()
public init() { }
@basememara
basememara / Badge.swift
Last active August 6, 2018 09:54 — forked from yonat/Badge.swift
Rounded UILabel and UIButton, Badged UIBarButtonItem
//
// Badge.swift
// Extensions for Rounded UILabel and UIButton, Badged UIBarButtonItem.
//
// Usage:
// let label = UILabel(badgeText: "Rounded Label");
// let button = UIButton(type: .System); button.rounded = true
// let barButton = UIBarButtonItem(badge: "42", title: "How Many Roads", target: self, action: "answer")
//
// Created by Yonat Sharon on 06.04.2015.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let row = self.tableView.indexPathForSelectedRow?.row,
let identifier = segue.identifier else { return }
switch (identifier, segue.destinationViewController) {
case (SPPostDetailViewController.segueIdentifier, let controller as SPPostDetailViewController):
controller.model = models[row]
default: return
}
}
@basememara
basememara / gist:5420184
Last active December 16, 2015 10:29
SF MVC Navigation View (2-level)
@model SitefinityWebApp.Mvc.Models.NavigationViewModel
@if (Model.DisplayParentTitle)
{
@Html.Raw(string.Format(Model.TitleFormat, Model.RootPage.Title))
}
<ul class="@Model.CssClass">
@for (int i = 0; i < Model.RootPage.Items.Count; i++)
{
@basememara
basememara / main.js
Created February 27, 2013 15:15
RequireJS: Avoid double jQuery load and version conflict in main.js
;(function () {
var paths = { ... };
//HANDLE JQUERY IF LOADED ALREADY TO AVOID OVERWRITING EXISTING JQUERY PROPERTIES AND PLUGINS
//CHECK FOR OLD VERSIONS OF JQUERY
var oldjQuery = !!(window.jQuery && !!window.jQuery.fn.jquery.match(/^1\.[0-4]/));
//LOAD JQUERY IF NOT AVAILABLE OR BELOW MIN
if (!window.jQuery || oldjQuery) {
paths.jquery = [
@basememara
basememara / app.html
Created September 8, 2012 12:51 — forked from bebraw/app.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>App name goes here</title>
<!-- Load some CSS here. -->
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<!-- Optional part. Define some global opts. You can set these easily via PHP or so. -->