Skip to content

Instantly share code, notes, and snippets.

View ricardolpd's full-sized avatar

Ricardo Duarte ricardolpd

View GitHub Profile
@zcaceres
zcaceres / Eyeballing-This.md
Last active August 17, 2023 23:38
Understanding Binding and 'this' in Javascript by zach.dev

How to Eyeball Your ‘This’ Context in Javascript

The early programmer struggles with the Javascript keyword this. But understanding your this context is easier than it seems.

This is all about where a function is invoked. Often, early programmers worry about where the function was declared. Perhaps the function was declared in a specific file or a particular object. Surely this changes it's this!

Nope.

Private members in ES6 classes

"Let's create an ES6 class!" you say. "Let's give it a private variable x."

class Foo {
  constructor(x) {
    this.x = x;
  }
  getX() {
anonymous
anonymous / contentblocks.rb
Created March 21, 2015 23:29
Gives you a mechanism in Jekyll to pass content up from pages into their parent layouts. It's kind of like having Rails' content_for available for Jekyll.
# Plugin: jekyll-contentblocks
# Author: Rusty Geldmacher
# Git: https://github.com/rustygeldmacher/jekyll-contentblocks
# Instructions: https://github.com/rustygeldmacher/jekyll-contentblocks#usage
module Jekyll
module ContentBlocks
VERSION = "0.0.3"
module Common
def get_content_block_name(tag_name, block_name)
block_name = (block_name || '').strip
@sey
sey / NFViewController.m
Created February 6, 2014 23:02
UITextField cursor positioning
//
// NFViewController.m
// TextFieldTest
//
// Created by Florian Sey on 06/02/14.
// Copyright (c) 2014 NeoFacto. All rights reserved.
//
#import "NFViewController.h"
@DrAma999
DrAma999 / gist:6554189
Created September 13, 2013 18:18
Method to be used inside a VC subclass or VC abstract class to avoid the status bar overlapping feature in iOS7. Actually tested only for single VC not added in hierachy. To use it you should embed all your view subviews into another view called tankView. It should be called before the view controller views has the opportunity to layout its view.
//This should be added before the layout of the view
- (void) adaptToTopLayoutGuide {
//Check if we can get the top layoutguide
if (![self respondsToSelector:@selector(topLayoutGuide)]) {
return;
}
//tankView is a contaner view
NSArray * array = [self.tankView referencingConstraintsInSuperviews]; //<--For this method get the Autolayout Demistified Book Sample made by Erica Sadun
[self.view removeConstraints:array];
NSArray * constraintsVertical = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topLayoutGuide]-0-[tankView]|" options:0 metrics:nil views:@{@"tankView": self.tankView, @"topLayoutGuide":self.topLayoutGuide}];
@foozmeat
foozmeat / openssl-build.sh
Last active May 22, 2024 17:56
A shell script to build openssl for iOS and Mac. It currently builds: Mac -> i386 & x86_64 // iOS -> armv7, arm64 // iOS Simulator -> i386 & x86_64.
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
@mbinna
mbinna / RunUnitTests.sh
Last active October 25, 2017 12:59
Run Xcode Application Tests from the command line
#!/bin/sh
# Launch application using ios-sim and set up environment to inject test bundle into application
# Source: http://stackoverflow.com/a/12682617/504494
if [ "$RUN_APPLICATION_TESTS_WITH_IOS_SIM" = "YES" ]; then
test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
environment_args="--setenv DYLD_INSERT_LIBRARIES=/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection --setenv XCInjectBundle=$test_bundle_path --setenv XCInjectBundleInto=$TEST_HOST"
ios-sim launch $(dirname $TEST_HOST) $environment_args --args -SenTest All $test_bundle_path
echo "Finished running tests with ios-sim"
@turtlesoupy
turtlesoupy / SFSChickenScreen.m
Created September 16, 2012 09:18
Ultra chicken CAEmitterLayer particle system
//
// Created by tdimson on 9/5/12.
#import <QuartzCore/QuartzCore.h>
#import "SFSChickenScreen.h"
@implementation SFSChickenScreen {
__weak CAEmitterLayer *_chickenEmitter;
CGFloat _decayAmount;