Skip to content

Instantly share code, notes, and snippets.

View DiyahM's full-sized avatar

Hadiyah Mujhid DiyahM

View GitHub Profile
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:orientation="vertical">
@DiyahM
DiyahM / search-answer.html
Created September 24, 2015 02:23
Answer to google book search answer
<!DOCTYPE html>
<html>
<head>
<title>Books</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$(function() {
var i = 0;
var searchTerm = '';
function getBooks(subject, startIndex){
<!DOCTYPE html>
<html>
<head>
<title>Books</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$(function() {
var i = 0;
var searchTerm = '';
function getBooks(subject, startIndex){
//page 3 changes
var myList = ['apple', 'orange' 'banana'];
var fruit = myList[2];
//page 5 changes
//question should change to 'What is the value returned in the above function printFavoriteColor?'
//This should be a text answer instead of multiple choice
function printFavoriteColor(){
var colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
var randomString = "";
@DiyahM
DiyahM / sample_apex_trigger
Last active May 4, 2017 01:57
Salesforce Apex Trigger Example
//Apex trigger
trigger Accepted on Training__c (before update) {
for (Training__c training : Trigger.new) {
Training__c oldTraining = Trigger.oldMap.get(training.id);
Boolean oldAccepted = oldTraining.Accepted__c.equals('YES');
Boolean newAccepted = training.Accepted__c.equals('YES');
if (!oldAccepted && newAccepted) {
public void onLoginSuccess() {
MyTwitterApp.getRestClient().getUserCredentials(new JsonHttpResponseHandler () {
@Override
public void onSuccess(JSONObject jsonUser) {
User user = User.fromJson(jsonUser);
UserModel currentUser = new UserModel(user.getScreenName(), user.getProfileImageUrl());
currentUser.save();
SharedPreferences pref = getSharedPreferences("myPrefs", MODE_PRIVATE);
Editor edit = pref.edit();
edit.putString("current_user", currentUser.getId().toString());
@DiyahM
DiyahM / Rakefile
Created October 23, 2012 18:23
Add to Rakefile for Turnip to work
if defined? RSpec # otherwise fails on non-live environments
task(:spec).clear
desc "Run all specs/features in spec directory"
RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |t|
t.pattern = './spec/**/*{_spec.rb,.feature}'
end
namespace :spec do
desc "Run the code examples in spec/acceptance"
RSpec::Core::RakeTask.new(:acceptance => 'db:test:prepare') do |t|
@DiyahM
DiyahM / Newb
Created October 19, 2012 18:15
Thunderbolt Labs Newbie Script for New Rails Projects
set -e
gem install bundler
bundle install --binstubs bin
createuser -s -e replacemewithusername
rake db:create
rake db:migrate
rake db:seed