Skip to content

Instantly share code, notes, and snippets.

View elnaqah's full-sized avatar

Ahmed Elnaqah elnaqah

View GitHub Profile
@elnaqah
elnaqah / Test1
Last active April 7, 2021 13:02
AsyncTest
func execute(_ block: @escaping ()-> Void) {
block()
}
print("A")
execute {
print("B")
}
print("C")
func getText(preprocess: @escaping (String) -> String) {
self.text = "Requesting..."
NetworkHandler.getText { [weak self] (success, text, error) in
guard let self = self else { return }
guard success, let text = text else {
DispatchQueue.main.async {
self.text = error ?? "Something went wrong."
}
return
}
class Job {
func run(completion: @escaping () -> Void) {
sleep(5)
completion()
}
}
let job = Job()
print("A")
job.run {
@elnaqah
elnaqah / RTF In textView
Created February 24, 2014 00:40
load rtf file in UItextView
NSURL *rtfPath = [[NSBundle mainBundle] URLForResource: @"description_ar" withExtension:@"rtf"];
NSAttributedString *attributedStringWithRtf = [[NSAttributedString alloc] initWithFileURL:rtfPath options:@{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType} documentAttributes:nil error:nil];
self.textView.attributedText=attributedStringWithRtf;
@elnaqah
elnaqah / gist:8872912
Created February 7, 2014 22:03
share arabic text on whatsapp from your ios application
NSString * titleWithoutSpaces=[self.item.title stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *whatsappURL = [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?text=%@-%@",titleWithoutSpaces,link]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
@elnaqah
elnaqah / gist:5070979
Last active August 29, 2023 04:42
cube with texture webgl tutorial
<html>
<head>
<title>Learning WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>
<script type="text/javascript" src="webgl-utils.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
@elnaqah
elnaqah / gist:5049691
Created February 27, 2013 17:17
webgl_lec1 added animation
<html>
<head>
<title>Learning WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>
<script type="text/javascript" src="webgl-utils.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
@elnaqah
elnaqah / gist:5049062
Created February 27, 2013 16:08
webgl lec1 example with color added
<html>
<head>
<title>Learning WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
@elnaqah
elnaqah / webgl_lec1
Created February 27, 2013 15:33
this is a simple webgl example
<html>
<head>
<title>Learning WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;