This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@digital_object_identifier = current_user.digital_object_identifiers.build | |
@digital_object_identifier.urls << Url.new | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def correct_user | |
@digital_object_identifier = current_user.digital_object_identifiers.find(params[:id]) | |
redirect_to root_url if @digital_object_identifier.nil? | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// tsh - A tiny shell program with job control | |
// | |
// <Put your name and login ID here> | |
// | |
using namespace std; | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |