Skip to content

Instantly share code, notes, and snippets.

View samermurad's full-sized avatar

Samer Murad samermurad

View GitHub Profile
@samermurad
samermurad / iOSPrintAllFonts.m
Created June 26, 2017 07:50
iOS Print all fonts
for (NSString* famName in [UIFont familyNames]) {
NSLog(@"== %@",famName);
for (NSString* nameInFam in [UIFont fontNamesForFamilyName:famName]) {
NSLog(@"==== %@",nameInFam);
}
}
@samermurad
samermurad / RCTWebView.m
Last active January 21, 2018 17:04
REACT NATIVE 0.44.2!!!!!!!!!!!!!!!!!!! This gist fixes the error "Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined" for iframes
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTWebView.h"

Keybase proof

I hereby claim:

  • I am samermurad on github.
  • I am samermurad (https://keybase.io/samermurad) on keybase.
  • I have a public key ASBT9YNuSzPnwnxv1eLOT3iK1d5u1JHHtZSq_cpLn1eRYgo

To claim this, I am signing this object:

@samermurad
samermurad / gitHashExtractorIOS.sh
Last active October 16, 2018 10:31
Add Git Hash to iOS App plist: Put this code under a new "run script" in Project>Target>Run Phases> Create new run script
#!/bin/sh
gitHash=$(/usr/libexec/PlistBuddy -c "Print :GitHash" "${PROJECT_DIR}/${INFOPLIST_FILE}")
exitCode=$?
if [ $exitCode == 0 ]; then
gitHash=$(git rev-parse HEAD | cut -c1-10)
/usr/libexec/PlistBuddy -c "Set :GitHash $gitHash" "${PROJECT_DIR}/${INFOPLIST_FILE}"
else
gitHash=$(git rev-parse HEAD | cut -c1-10)
/usr/libexec/PlistBuddy -c "Add :GitHash string $gitHash" "${PROJECT_DIR}/${INFOPLIST_FILE}"
fi
@samermurad
samermurad / MediaDisplayer.js
Created November 21, 2018 11:09
A react-native Media Display screen that can display videos, images, audio files and pdfs, it is taken from a project that I wrote, so obviously some items are project related.
import React, { Component } from 'react'
import { View, TouchableOpacity, StyleSheet,Image,Animated, Platform, BackHandler, Button } from 'react-native'
import { connect } from 'react-redux'
import {Actions} from 'react-native-router-flux'
import { colors,fonts,images, styles as appStyles } from '../assets'
import { Screen, NAVIGATION_BAR_HEIGHT, STATUS_BAR_HEIGHT } from '../consts'
import { mediaType } from '../enums'
import Interactable from 'react-native-interactable'
import { CachedImage } from 'react-native-cached-image'
import { Player as AudioPlayer } from 'react-native-audio-toolkit'
@samermurad
samermurad / cryptor.js
Last active January 10, 2020 13:57
Nodejs Basic aes256 encrypt decrypt implementation
const crypto = require('crypto');
const TAG = 'cryptor || '
/**
* @typedef CryptResult
* @property {string} iv
* @property {string} crypt
*/
@samermurad
samermurad / tmMsg.js
Created January 10, 2020 17:59
Nodejs Request send Telegram Message through a bot
const requrest = require('request')
const BOT_TOKEN = '<YOUR_TOKEN_HERE>'
const CHAT_ID = 0 // <YOUR_CHAT_ID>
const tmMsg = (text) => {
const options = {
method: 'POST',
url: `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ chat_id: CHAT_ID, text })
@samermurad
samermurad / outlinedProgress.html
Created May 19, 2020 15:02
HTML/JS/CSS Inverted Progress Text progress bar
<!DOCTYPE html>
<html>
<head>
<title> Test Progress</title>
</head>
<style type="text/css">
.progress {
position: relative;
display: flex;
height: 100px;
@samermurad
samermurad / tmpCache.js
Last active September 30, 2020 13:00
Tmp Cache for NodeJs scripts, very useful for small program where you might want to persist some data for later reuse
// Written by Samer Murad
const path = require('path');
const fs = require('fs');
const os = require('os');
class TmpCache {
constructor(ID) {
this.FILE_ID = ID;
@samermurad
samermurad / lodashGetNonNull.js
Created November 16, 2020 10:31
lodash getNonNull
const _ = require('lodash');
/**
* File adds a "getNonNull" function to the set of the lodash functions
* function works exactly like `_.get` with one simple exception
* the _.getNonNull returns the default value for null values as well
* just make sure to require this file on your main js/ts file
*
* Example:
* var foo = { bar: undefined: bar1: null }
* with _.get: