Skip to content

Instantly share code, notes, and snippets.

View hamada147's full-sized avatar
🎯
Focusing

Ahmed Moussa hamada147

🎯
Focusing
View GitHub Profile
@hamada147
hamada147 / crypt.class.php
Last active September 10, 2015 09:07 — forked from joshhartman/crypt.class.php
Rijndael 256-bit Encryption (CBC) Class
<?php
class Crypt {
private $key;
function __construct($key){
$this->setKey($key);
}
@hamada147
hamada147 / imgur.php
Last active September 21, 2015 08:34 — forked from scottydelta/imgur.php
A php script to upload images to Imgur anonymously using Imguy API V3. The input is an image and Output is a direct ink.
<?php
$client_id = 'xxxxxxxx';
$file = file_get_contents("test-image.png");
$url = 'https://api.imgur.com/3/image.json';
$headers = array("Authorization: Client-ID $client_id");
$pvars = array('image' => base64_encode($file));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL=> $url,
@hamada147
hamada147 / NSObjectFromNSDictionary.m
Last active June 10, 2018 13:52
Create NSObject in runtime from an array of NSDictionary
- (NSArray *)getRecrodsFromDictionary: (NSDictionary*)dictionary {
// the following include the array that I want to turn into objects
NSArray * response = [self parseKey:@"responseDetails" fromDictionary:dictionary];
NSMutableArray * rows = [[NSMutableArray alloc] init];
if ([response count] != 0) {
// 1. get all NSDictionary keys
NSDictionary * temp = response[0];
NSArray * keys = [temp allKeys];
// 2. create a class
@hamada147
hamada147 / get NSObject property attribute values.m
Created June 26, 2018 08:30
While creating an NSObject in Run time I faced an issue that creating only Ivar in the created class will make it only valid for the first time use which is more like a weak reference then it will deallocate automatically which would be very helpful if you are going to use it one time only but I was going to reuse created NSObject which made thi…
unsigned propertyCount = 0;
// replace BanksModel with the class name you want to find out its attributes
objc_property_t *properties = class_copyPropertyList([BanksModel class], &propertyCount);
for (int prop = 0; prop < propertyCount; prop++) {
// for all property attributes
unsigned int attributeCount = 0;
objc_property_attribute_t * attributes = property_copyAttributeList(properties[prop], &attributeCount);
for (unsigned int attr = 0; attr < attributeCount; attr++) {
NSLog(@"Attribute %d: name: %s, value: %s", attr, attributes[attr].name, attributes[attr].value);
}
@hamada147
hamada147 / Functions.c
Created July 10, 2018 15:34
Error in this code happen inside Infaragistics Framework -[IGGridViewColumnDefinition resolveValueForObject:inDataSource:] + 112.
@implementation MainWidgetViewController
- (NSArray *)getArrayOfRecrodsFrom: (NSArray *)response {
NSMutableArray * rows = [[NSMutableArray alloc] init];
if ([response count] != 0) {
// 1. get all NSDictionary keys
NSDictionary * temp = response[0];
NSArray * keys = [temp allKeys];
if (!NSClassFromString(self.ServiceName)) {
@hamada147
hamada147 / Functions.c
Created July 10, 2018 15:37
Error in this code happen inside Infaragistics Framework -[IGGridViewColumnDefinition resolveValueForObject:inDataSource:] + 112. I'm creating an NSObject in runtime and setting the datasource value to the retuned NSArray of getArrayOfRecrodsFrom function. If I commented the lines indicated in the function the code runs fine with no issues but w…
@implementation MainWidgetViewController
- (NSArray *)getArrayOfRecrodsFrom: (NSArray *)response {
NSMutableArray * rows = [[NSMutableArray alloc] init];
if ([response count] != 0) {
// 1. get all NSDictionary keys
NSDictionary * temp = response[0];
NSArray * keys = [temp allKeys];
if (!NSClassFromString(self.ServiceName)) {
@hamada147
hamada147 / Utils.swift
Last active November 11, 2018 09:49
Add ++ & -- operators to Int in Swift 4
infix operator ++
infix operator --
extension Int {
/// decress the value by one
///
/// - Parameter num: value to decress
static prefix func --(_ num: inout Int) -> Int {
num -= 1
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dood="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/DooDecompReceiveOrderExternalComposite" xmlns:mod="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/model/" xmlns:mod1="http://xmlns.oracle.com/apps/scm/doo/processOrder/model/">
<soapenv:Header />
<soapenv:Body>
<dood:process>
<dood:OrchestrationOrderRequest>
<!--Optional:-->
<mod:SourceTransactionIdentifier>moussa.ahmed95@gmail.com</mod:SourceTransactionIdentifier>
<mod:SourceTransactionSystem>OPS</mod:SourceTransactionSystem>
<mod:SourceTransactionNumber>100006</mod:SourceTransactionNumber>
<?php
$soap_request = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dood="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/DooDecompReceiveOrderExternalComposite" xmlns:mod="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/model/" xmlns:mod1="http://xmlns.oracle.com/apps/scm/doo/processOrder/model/">
<soapenv:Header />
<soapenv:Body>
<dood:process>
<dood:OrchestrationOrderRequest>
<!--Optional:-->
<mod:SourceTransactionIdentifier>moussa.ahmed95@gmail.com</mod:SourceTransactionIdentifier>
/**
*
* @author Ahmed Moussa
*/
public class JavaApplication1 {
String name;
int age;
public JavaApplication1() {