Skip to content

Instantly share code, notes, and snippets.

View px-amaac's full-sized avatar

Aaron McIntyre px-amaac

View GitHub Profile
@px-amaac
px-amaac / A
Last active August 29, 2015 14:10
_step.html.erb
<% if step.title != nil %>
<p>
<%= step.title %>
<%= step.problem %>
<%= step.solution %>
<%= link_to 'Show', tutorial_step_path(tutorial_id, step) %>
<%= link_to 'Destroy', tutorial_step_path(tutorial_id, step), method: :delete, data: { confirm: 'Are you sure?' } %>
</p>
<% end %>
@px-amaac
px-amaac / _step.html.erb
Created December 8, 2014 00:48
I have a partial and it displays a step. The Destroy link is broken giving me the error about not having the tutorial id that is required. The partial is rendered in the show action of another view. How do I get the required field to the partial so it can be submitted as a parameter. The last file is how i manage it in the Create action.
<% if step.title != nil %>
<p>
<%= step.title %>
<%= step.problem %>
<%= step.solution %>
<%= link_to 'Destroy', tutorial_step_path, method: :delete, data: { confirm: 'Are you sure?' } %>
</p>
<% end %>
class TutorialsController < ApplicationController
before_action :set_tutorial, only: [ :show ]
before_action :correct_user, only: [ :show, :edit, :update, :destroy ]
before_action :authenticate_user!
...
...
...
private
@px-amaac
px-amaac / A
Created November 20, 2014 08:52
Author.joins(:articles).where(articles: { author: author })
@px-amaac
px-amaac / BActivity.java
Created November 7, 2014 23:52
App showing OS launching activity on the stack after crash.
public class BActivity extends Activity implements View.OnClickListener {
private Button mLaunchMainButton;
private Button mLaunchBButton;
private Button mDoIt;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("bActivity", "otCreate");
setContentView(R.layout.activity_my);
mLaunchMainButton = (Button) findViewById(R.id.launch_main);
@px-amaac
px-amaac / gist:be669ee4c587b6b91ee5
Created October 30, 2014 00:05
App crashing twice.
10-29 16:50:16.923 11430-11430/com.devaa.debugstaging E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.devaa.debugstaging, PID: 11430
java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.<init>(Uri.java:467)
at android.net.Uri$StringUri.<init>(Uri.java:457)
at android.net.Uri.parse(Uri.java:429)
at com.devaa.app.activities.PDPActivity$AddToListOnClickListener.removeFromList(PDPActivity.java:483)
at com.devaa.app.activities.PDPActivity$AddToListOnClickListener.onClick(PDPActivity.java:446)
at android.view.View.performClick(View.java:4630)
at android.view.View$PerformClick.run(View.java:19331)
@px-amaac
px-amaac / SHA1.java
Created October 27, 2014 19:40
Run this to get the SHA1 for your particular signature. I use for google maps, google plus and facebook and others to ensure that i have the right key
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.testing.yourPackageName",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
textView.setText(Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
@px-amaac
px-amaac / logcat
Created October 22, 2014 17:13
Activity lifecycle testing app
10-22 09:20:39.483 3359-3359/devaamci.testlifecycle E/myActivity﹕ onCreate
10-22 09:20:39.483 3359-3359/devaamci.testlifecycle E/myActivity﹕ onStart
10-22 09:20:39.493 3359-3359/devaamci.testlifecycle E/myActivity﹕ onResume
10-22 09:20:39.533 3359-3359/devaamci.testlifecycle I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: (CL3869936)
OpenGL ES Shader Compiler Version: 17.01.11.SPL
Build Date: 01/17/14 Fri
Local Branch:
Remote Branch:
Local Patches:
Reconstruct Branch:
public class Version implements Parcelable {
@Expose
private String versionname;
@Expose
private Integer versionid;
@Expose
private Integer pageid;
@Expose
private Integer pagenumber;
public class Location implements Parcelable{
@Expose
private Integer id;
@Expose
private Coords coords;
@Expose
private Double distance;
public Location(Parcel in) {