Skip to content

Instantly share code, notes, and snippets.

View iamraafay's full-sized avatar
👨‍💻

Mohammad Abdurraafay (Raafay) iamraafay

👨‍💻
View GitHub Profile
anonymous
anonymous / gist:1269799
Created October 7, 2011 08:42
ObjectMapper Example
#import <Foundation/Foundation.h>
#import "JSONKit.h"
#import "ObjectMapper.h"
#import "TwitterSearchResult.h"
#import "Result.h"
#import "Metadata.h"
int main (int argc, const char * argv[])
{
@seansu4you87
seansu4you87 / KIFStep.m
Last active October 1, 2015 02:38
KIF enter text in UITextField inside UIWebView
If you are the only controlling the HTML, change it so that your input field has default values for accessibility. You can do this via several of the attributes. If you don't have access to the HTML...
You can inject javascript into your webview and change the title attribute of the <input> tags, giving them a default and static accessibilityLabel.
NSString *result = [self.webView stringByEvaluatingJavaScriptFromString:@"var inputs = document.getElementsByTagName('input');"
"for (var index = 0; index < inputs.length; index++){inputs[index].title = 'input ' + index;}"
];
Here I give the nth <input> tag an accessibility label of "input n".
@trey
trey / happy_git_on_osx.md
Last active September 19, 2024 16:23
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

@kcharwood
kcharwood / gist:4739785
Last active December 12, 2015 07:49
Custom AFOperation
-(void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *, id))success
failure:(void (^)(AFHTTPRequestOperation *, NSError *))failure {
void (^newSuccessBlock)(AFHTTPRequestOperation*, id) =
^(AFHTTPRequestOperation *operation, id responseObject){
NSError * customError = nil;
//Do some custom error processessing
if(customError){
if(nil != failure)
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@davimacedo
davimacedo / curl.sh
Last active June 23, 2021 21:33
Example of importing data with cloud functions. See a live example at https://www.back4app.com/database/davimacedo/parse-import-example
curl -X POST \
-H "X-Parse-Application-Id: LL9oIdzIkmwl5xyowQQu0fTmXyUWfet9RuAzwHfj" \
-H "X-Parse-REST-API-Key: R3S8PYQKuzeV4c8MUeO5ved46C50MEp56boDHW1O" \
-H "Content-Type: application/json" \
-d @data.json \
https://parseapi.back4app.com/functions/import
@matsuda
matsuda / memoryAddress.swift
Last active October 10, 2024 04:39
Get memory address in Swift
///
/// https://stackoverflow.com/a/29741007
///
let s = Struct() // Struct
withUnsafePointer(to: s) {
print(String(format: "%p", $0)
}
///
/// http://stackoverflow.com/a/36539213/226791
@bleft
bleft / UIButton+Extension.swift
Last active March 12, 2021 19:04
UIButton with centered Image and Text
// with the help of: https://gist.github.com/phpmaple/9458264
extension UIButton {
func centerImageAndButton(_ gap: CGFloat, imageOnTop: Bool) {
guard let imageView = self.imageView,
let titleLabel = self.titleLabel else { return }
let sign: CGFloat = imageOnTop ? 1 : -1;
let imageSize = imageView.frame.size;
@timonus
timonus / programmatic-dynamic-images.m
Last active January 1, 2024 12:08
Programmatically create iOS 13 dynamic images
- (UIImage *)dynamicImage
{
UITraitCollection *const baseTraitCollection = /* an existing trait collection */;
UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]];
UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]];
__block UIImage *lightImage;
[lightTraitCollection performAsCurrentTraitCollection:^{
lightImage = /* draw image */;
@tykurtz
tykurtz / grokking_to_leetcode.md
Last active November 16, 2024 05:08
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window