Skip to content

Instantly share code, notes, and snippets.

View px-amaac's full-sized avatar

Aaron McIntyre px-amaac

View GitHub Profile
class Address < ActiveRecord::Base
before_save {|user| user.email = email.downcase}
has_one :color, through: :color_relationship
has_one :zip_code, through: :zip_code_relationship
has_one :zip_code_relationship, :dependent => :destroy
has_one :color_relationship, :dependent => :destroy
attr_accessor :code
attr_accessor :f_color
def new
@digital_object_identifier = current_user.digital_object_identifiers.build
@digital_object_identifier.urls << Url.new
end
@px-amaac
px-amaac / FROM lOG
Last active December 26, 2015 18:08
Started POST "/urls" for 127.0.0.1 at 2013-10-28 00:18:27 -0700
Processing by UrlsController#create as HTML
Parameters: {"utf8"=>"√", "authenticity_token"=>"Actwx4PzZoH2Zb3F2x1ZFKzTV/b2F
pFfTltkFBUHj2o=", "url"=>{"url"=>"wew.wew.wew"}, "commit"=>"Set New Url"}
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT "users".* FROM "users" WHERE "users
"."id" = 2 ORDER BY "users"."id" ASC LIMIT 1←[0m
Completed 404 Not Found in 40ms
ActiveRecord::RecordNotFound (Couldn't find DigitalObjectIdentifier without an I
D):
def correct_user
@digital_object_identifier = current_user.digital_object_identifiers.find(params[:id])
redirect_to root_url if @digital_object_identifier.nil?
end
from Materials import Materials
class Book(Materials):
def __init__(self, d):
super().__init__(d[0], d[1], d[2], d[9])
d.pop(9)
for i in range(3):
d.pop(0)
self.data = d
def __str__(self):
@px-amaac
px-amaac / testing
Last active December 31, 2015 07:49
class Transition(object):
def __init__(self, state, given, prob):
self.state = state
self.given = given
self.prob = prob
def __str__(self):
return "P({}|{})={}".format(self.state, self.given, self.prob)
def disp(self):
//
// tsh - A tiny shell program with job control
//
// <Put your name and login ID here>
//
using namespace std;
#include <stdio.h>
#include <stdlib.h>
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
//leave this empty
}
@Override
public void onScrollStateChanged(AbsListView listView, int scrollState) {
if (scrollState == SCROLL_STATE_IDLE) {
if (listView.getLastVisiblePosition() >= listView.getCount() - 1 - threshold) {
package com.example.app;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_item"
android:icon="@drawable/icon"
android:showAsAction="ifRoom"
android:title="@string/menu_item">
</item>
</menu>