Skip to content

Instantly share code, notes, and snippets.

View luisdelarosa's full-sized avatar

Louie de la Rosa luisdelarosa

View GitHub Profile

CocoaPods + Xcode Continuous Integration

Script:

cd ${SRCROOT}
if [ -e "Pods" ]
then
pod install
else
touch Pods
@jeremyquinn
jeremyquinn / NSManagedObject+KeyedSubscript.h
Created May 25, 2013 16:53
This is a Category on NSManagedObject, that enables subscript access to properties.
//
// NSManagedObject+KeyedSubscript.h
//
// Created by Jeremy Quinn on 25/05/2013.
// Copyright (c) 2013 FiveOne.org. All rights reserved.
//
#import <CoreData/CoreData.h>
@interface NSManagedObject (KeyedSubscript)
- (id)initWithBeer:(BHBeer *)beer
{
NSAssert(beer != nil, @"beer is required");
self = [super init];
if (self) {
self.beer = beer;
}
return self;
}
package com.jwo.example.sampleform;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@codebutler
codebutler / FieldValidator.java
Created May 10, 2012 21:16
Simple helper to validate android form fields
import android.app.Activity;
import android.content.Context;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.humaorie.dollar.Dollar;
import static com.humaorie.dollar.Dollar.$;

Using Swift Package Manager with iOS

Step 1:

File > New > Project...

Step 2:

Create a Package.swift file in your root project directory, add dependencies, then run swift package fetch on the command line in the same directory. We’re not going to run swift build because it will just complain.

@mattetti
mattetti / rails_json_session.rb
Last active September 23, 2020 07:04
This is a monkey patch to change Rails 4's default session/signed cookie serializer from Marshal to JSON for security and compatibility reasons. Note that this is a hack, a pretty terrible one and you should only use it if you know what you're doing. Also, I only wrote this patch for my own personal use, so don't be surprised if it doesn't work …
# Hack to change the Rails cookie serializer from Marshal to JSON and therefore allow the session
# to be shared between different languages but also avoid that someone knowing the
# cookie secret key could execute arbitrary code on the server by unmarshalling
# modified Ruby code added to the session/permanent cookie.
#
# Note that all users will beed to login again since both the remember me cookie and the session cookies
# won't be valid. Note also that the remember me cookie is tested multiple times per request even when it fails.
# for performance reasons you might want to delete it if these extra cycles are too costly for you.
#
# Rails 4 (not tested on Rails 3).
@mchambers
mchambers / reflect.swift
Last active March 5, 2021 09:20
Basic Reflection in Swift.
// Let's define a basic Swift class.
class Fruit {
var type=1
var name="Apple"
var delicious=true
}
// We can get at some info about an instance of an object using reflect(), which returns a Mirror.
reflect(Fruit()).count
reflect(Fruit())[1].0
@luisdelarosa
luisdelarosa / K Factor Test PETG.gcode
Created March 10, 2019 05:26
Linear advance K Factor Test for use with PETG filament
;K Line Test created by Sebastianv650
; from https://mattshub.com/2017/10/02/linear-advance/
; updated for PETG temperatures by luisdelarosa (@louielouie)
; hotend 240C
; bed 85C
M107
M83 ; extruder relative mode
M104 S240 ; set extruder temp
M140 S85 ; set bed temp
@JakeWharton
JakeWharton / BaseActivity.java
Created July 6, 2012 01:17
Scoped event bus which automatically registers and unregisters with the lifecycle.
package com.squareup.example;
public abstract BaseActivity extends SherlockActivity {
private final ScopedBus scopedBus = new ScopedBus();
protected ScopedBus getBus() {
return scopedBus;
}
@Override public void onPause() {